BorderLayoutBoxedLayoutOpenLayoutMaximum textMedium textSmall text


Register
Thursday, September 02, 2010
MyStreamMinimize
Print  

Key Lookup Threshold Part 2

Posted by Jason on Monday, February 09, 2009 to query optimizer, SQL performance tuning
1407 Views | 1 Comments | Article Rating

Grant Fritchey(@gfritchey) posed this question to me on twitter after my posted on the key lookup threshold post.

@statisticsio Interesting post. Do you think that threshold is dependent on the data involved? Or maybe on the size of the key?8:28 AM Feb 5th from TwitterGadget in reply to statisticsio

I kind of assumed so which is why I did char(1000). However, I have just tested with char(1). The numbers are interesting. Please refer to the original post for repro code.

 

 IOIO
RowsCHAR(1000)CHAR(1)
Scan4229
1 row44
5 rows1212
10 rows2222
25 rows5252
50 rows114102
100 rows217202
250 Rows526502
500 Rows10431003
1000 Rows41414007

 

The threshold is crossed much earlier because the scan is smaller. This is a small table especially with CHAR(1) so take this test with a grain of salt. Run your own tests when you are working with large production data.

I would also venture to guess that as the complexity of the query increases the threshold gets lower especially on more complex queries like when grouping especially when grouping and outer joining.

A covering index is probably the best solution in most cases unless you need to touch all rows even then, it might be better,.

email it! |   |   |   |  | 
Permalink     1 Comments  

Rate this Post:
COMMENTS:

Good article.

posted @ Thursday, February 19, 2009 11:19 AM by Jason Strate


Name (required)

Email (required)

Website


Simple BBCode can be used like [url=http://example.com]Example[/url] and [B]

Copyright 2006 by Statistics IO, My SQL Server Blog