Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

Different execution plan for same query but for different condition value

$
0
0

Hi All,

I'm facing a strange situation where same query for different condition not working.

1--

Select  top 10 * from revenuefact(nolock) 
where feecode ='OW4'
2--
Select  top 10 * from revenuefact(nolock)
where feecode ='BTE'

1st query is returning result easily but 2nd query is taking too long. Column feecode has already Non-clustered index and Clustered index is also available for another col RevenueSID.I was surprised when checked the query execution plan for both the above queries  which is quite different (as per attached below). Can anyone suggest me the reason behind it.

And solution for the same. One more thing that data for feecode BTE is inserting through different source instead of others feecode and table contains more than 300 million rows.

Plan1:-



Viewing all articles
Browse latest Browse all 12963

Trending Articles