Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 17,844 of 19,505    |
|    Erland Sommarskog to le_mo_mo@yahoo.com    |
|    Re: Query Large Table    |
|    21 Jul 10 23:31:04    |
      9a1292ed       From: esquel@sommarskog.se              Mo (le_mo_mo@yahoo.com) writes:       > I have a relatively large table which has around five million records.       > When I run a query like:       >       > Select A, B, C where A='AA' and B='BB'       >       > the query takes a long time to complete which is slowing down the web       > front end.       >       > My question is how to go about indexing the table to make this query       > faster? I have added two (Non Clustered and clustered) indexes to this       > table but do not see any improvement in performance. Any       > recommendations is greatly appreciated.              For this particular query, the best index (assuming that the table has       more columns that these three) would be one of:               CREATE INDEX best_ix ON tbl(A, B) INCLUDE (C)        CREATE INDEX best_ix ON tbl(B, A) INCLUDE (C)              But if (A, B) are selective enough, an index on those two alone may be       sufficient. I'm a little wary of adding covering indexes for such queries,       since if someone later adds the column D to the result set, the index is       not covering anymore, just unecessarily large.       --       Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se              Links for SQL Server Books Online:       SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx       SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx       SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca