DDQ Parameters Poor Performance -
09-13-2006
, 03:49 PM
I have a DDQ using a simple select as the source. It is from a single table,
with no joins, group by or order by.
It uses 4 data parameters to qualify the rows to return.
The table is 16m rows and the estimated rows is at 2.5m in the query, but
only approx 2200 are actually returned.
I have taken the query into QA and created the parameters as local variables
to use in the select but to no avail. If I hard code the values for the
dates into the query it returned the corrected estimated rows, and runs in
seconds.
The query is below with several columns removed for readability.
declare @P1 datetime
declare @P2 datetime
declare @P3 datetime
declare @P4 datetime
set @p1 = 'Sep 12 2006 2:54:06:000PM'
set @p2 = 'Sep 12 2006 2:59:15:000PM'
set @p3 = 'Sep 12 2006 2:54:06:000PM'
set @p4 = 'Sep 12 2006 2:59:15:000PM'
SELECT
[S].[ShipmentPartyInfoID],
[S].[BatchID],
[S].[ShipmentID],
[S].[ShipperAccountID],
....
[S].[AddedDate],
[S].[LastChangedDate],
[S].[UpdateCount]
FROM [ShipmentPartyInfo] [S] WITH (NOLOCK)
WHERE (([S].[AddedDate] BETWEEN @P1 AND @P2) OR ([S].[LastChangedDate]
BETWEEN @P3 AND @P4))
AND [S].[ShipmentID] IS NOT NULL
If I only select a few columns from the table rather than all the columns by
name the query plan used parallelism to bring the rows back.
I have read about parameter sniffing but QA does not resolve the issue as it
appears it would if it was parameter sniffing issue. |