Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
janets20
Starting Member
12 Posts |
Posted - 2010-09-08 : 23:37:20
|
Hi, I was asked in a interview a scenario.A table has a index on a city name.Rows are filtered using the City name in where clause.There can be many customers in that city.How do we optimize that query.RegardsJanet |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-09-09 : 00:29:07
|
it would be helpful to know WHAT query...but based on what you've told us, it already is optimized.you want an index on your WHERE condition, and you've told us it already exists.so the answer is, it either already is optimized, or we don't have enough information |
 |
|
Kristen
Test
22859 Posts |
Posted - 2010-09-09 : 02:37:46
|
If there are many customers in a city - we are talking MANY right? then maybe the point is that the City index is no longer Selective.In which case we need to index on some other criteria in the WHERE clause.Always worth asking what answer they were expecting. If, on reflection, its stupid or they don't really know the answer or whatever it may be a good indication that its not a good place to work as you already know more than they do! |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-09-09 : 03:21:06
|
You can make the other columns in the select as INCLUDEd in the index, so you don't have to LOOKUP them later. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
|
|