Hi,
We massively imported 1.5 million rows in a software database table a couple of weeks ago. Since that time, the queries in the search screen perform pourly. I caught those requests and figured out an index that would help them. In my tests the index helped the queries a lot but in the application it didn’t change anything. I found out that the queries, when ran in a sp_prepexec, didn’t use the new index, even if I updated the statistics. What am I missing here?
The queries :
declare @p1 int
exec sp_prepexec @p1 output,N'@P0 int,@P1 int,@P2 int,@P3 int,@P4 int,@P5 varchar(8000)',N'SELECT COUNT(*) FROM (SELECT TOP (301) 1 as countCol FROM ab_abcontact qRoot WHERE qRoot.Subtype IN (@P0,@P1,@P2,@P3,@P4) AND qRoot.KeywordDenorm LIKE @P5 COLLATE French_CI_AI
AND qRoot.StateDenorm = 10063 AND qRoot.CountryDenorm = 10039 AND qRoot.Retired = 0) countTable',5,8,9,11,13,'%fix auto beauport%'
select @p1
Returns in 3975ms.
SELECT COUNT(*) FROM (SELECT TOP (301) 1 as countCol FROM ab_abcontact qRoot WHERE qRoot.Subtype IN (5,8,9,11,13) AND qRoot.KeywordDenorm LIKE '%fix auto beauport%' COLLATE French_CI_AI AND qRoot.StateDenorm = 10063 AND qRoot.CountryDenorm = 10039 AND qRoot.Retired = 0) countTable;
Returns in 59ms.
Thanks a lot,
Jean-Michel
Jean-Michel