G
Greg
I am trying to fill strongly typed datasets with data from a SQLServer
DB. The data is used as a datsource for drop down lists. The data
adapters are configured to perform only selects, no inserts, updates,
or deletes. When I call the Fill method to load the dataset, CPU Usage
goes to 100%. These simple queries take forever to complete. We are
only dealing with a few hundred rows. My windows form takes minutes to
load because of the poor performance. The select statements require 2
inner joins to aquire the required data columns. Similar fills using
selects with a single inner join perforn OK. I tried running the SQl
Profiler to analyze the problem. When I run the query from SQL Query
Analyzer, SQL Profiler shows a duration of 30. When run from withing
the C# .net application duration jumps to 9000 or 300 times slower.
Reads stay the same. SQL execution plan is the same when using Query
analyzer versus the application. It appears the SQL Data Provider is
the source of the poor performance. Here is the SQL Select that
performs poorly:
SELECT H.HLAHighResID, H.HighResName, H.HLALowResID, L.LowResName
FROM ValidValues_HLAHighRes H
INNER JOIN ValidValues_HLACategories C ON H.HLACategoryID =
C.HLACategoryID
INNER JOIN ValidValues_HLALowRes L ON H.HLALowResID = L.HLALowResID
WHERE (C.CategoryName = 'A')
Execution Tree
--------------
Nested Loops(Inner Join, OUTER REFERENCES[H].[HLALowResID]))
|--Nested Loops(Inner Join, WHERE[H].[HLACategoryID]=[C].
[HLACategoryID]))
| |--Index Seek(OBJECT[test].[dbo].[ValidValues_HLACategories].
[IX_ValidValues_HLACategories_1] AS [C]), SEEK[C].
[CategoryName]='A') ORDERED FORWARD)
| |--Clustered Index Scan(OBJECT[test].[dbo].
[ValidValues_HLAHighRes].[PK_ValidValues_HLAHighRes] AS [H]))
|--Clustered Index Seek(OBJECT[test].[dbo].[ValidValues_HLALowRes].
[PK_ValidValues_HLALowRes] AS [L]), SEEK[L].[HLALowResID]=[H].
[HLALowResID]) ORDERED FORWARD)
Here is the SQL Select that performs OK even though duration doubles:
SELECT L.HLALowResID, L.LowResName
FROM ValidValues_HLALowRes L
INNER JOIN ValidValues_HLACategories C ON L.HLACategoryID =
C.HLACategoryID
WHERE (C.CategoryName = 'A') ORDER BY L.LowResName
Execution Tree
--------------
Sort(ORDER BY[L].[LowResName] ASC))
|--Nested Loops(Inner Join, WHERE[C].[HLACategoryID]=[L].
[HLACategoryID]))
|--Index Seek(OBJECT[test].[dbo].[ValidValues_HLACategories].
[IX_ValidValues_HLACategories_1] AS [C]), SEEK[C].
[CategoryName]='A') ORDERED FORWARD)
|--Clustered Index Scan(OBJECT[test].[dbo].
[ValidValues_HLALowRes].[PK_ValidValues_HLALowRes] AS [L]))
Thes are quite similar excpet for an extra INNER JOIN. What can the
souce of this poor perfomance be? Why does CPU get pegged at 100% when
I run these selects from the application? I thought trhe SQL Data
Provider was the preferred choice when accessing a SQL Server DB.
Should I try an OLE Data Adapter?
DB. The data is used as a datsource for drop down lists. The data
adapters are configured to perform only selects, no inserts, updates,
or deletes. When I call the Fill method to load the dataset, CPU Usage
goes to 100%. These simple queries take forever to complete. We are
only dealing with a few hundred rows. My windows form takes minutes to
load because of the poor performance. The select statements require 2
inner joins to aquire the required data columns. Similar fills using
selects with a single inner join perforn OK. I tried running the SQl
Profiler to analyze the problem. When I run the query from SQL Query
Analyzer, SQL Profiler shows a duration of 30. When run from withing
the C# .net application duration jumps to 9000 or 300 times slower.
Reads stay the same. SQL execution plan is the same when using Query
analyzer versus the application. It appears the SQL Data Provider is
the source of the poor performance. Here is the SQL Select that
performs poorly:
SELECT H.HLAHighResID, H.HighResName, H.HLALowResID, L.LowResName
FROM ValidValues_HLAHighRes H
INNER JOIN ValidValues_HLACategories C ON H.HLACategoryID =
C.HLACategoryID
INNER JOIN ValidValues_HLALowRes L ON H.HLALowResID = L.HLALowResID
WHERE (C.CategoryName = 'A')
Execution Tree
--------------
Nested Loops(Inner Join, OUTER REFERENCES[H].[HLALowResID]))
|--Nested Loops(Inner Join, WHERE[H].[HLACategoryID]=[C].
[HLACategoryID]))
| |--Index Seek(OBJECT[test].[dbo].[ValidValues_HLACategories].
[IX_ValidValues_HLACategories_1] AS [C]), SEEK[C].
[CategoryName]='A') ORDERED FORWARD)
| |--Clustered Index Scan(OBJECT[test].[dbo].
[ValidValues_HLAHighRes].[PK_ValidValues_HLAHighRes] AS [H]))
|--Clustered Index Seek(OBJECT[test].[dbo].[ValidValues_HLALowRes].
[PK_ValidValues_HLALowRes] AS [L]), SEEK[L].[HLALowResID]=[H].
[HLALowResID]) ORDERED FORWARD)
Here is the SQL Select that performs OK even though duration doubles:
SELECT L.HLALowResID, L.LowResName
FROM ValidValues_HLALowRes L
INNER JOIN ValidValues_HLACategories C ON L.HLACategoryID =
C.HLACategoryID
WHERE (C.CategoryName = 'A') ORDER BY L.LowResName
Execution Tree
--------------
Sort(ORDER BY[L].[LowResName] ASC))
|--Nested Loops(Inner Join, WHERE[C].[HLACategoryID]=[L].
[HLACategoryID]))
|--Index Seek(OBJECT[test].[dbo].[ValidValues_HLACategories].
[IX_ValidValues_HLACategories_1] AS [C]), SEEK[C].
[CategoryName]='A') ORDERED FORWARD)
|--Clustered Index Scan(OBJECT[test].[dbo].
[ValidValues_HLALowRes].[PK_ValidValues_HLALowRes] AS [L]))
Thes are quite similar excpet for an extra INNER JOIN. What can the
souce of this poor perfomance be? Why does CPU get pegged at 100% when
I run these selects from the application? I thought trhe SQL Data
Provider was the preferred choice when accessing a SQL Server DB.
Should I try an OLE Data Adapter?