You are here: Re: Query optimization via table properties? « MsSQL Server « IT news, forums, messages
Re: Query optimization via table properties?

Posted by Erland Sommarskog on 07/26/06 21:55

Ed Murphy (emurphy42@socal.rr.com) writes:
> Query #1:
>
> select <list of fields>
> from C
> join B on C.b_key = B.b_key
> join A on B.a_key = A.a_key
> where A.o_key = <some value>
>
> Query #2:
>
> select <list of fields>
> from C
> where b_key in (
> select b_key
> from B
> where a_key in (
> select a_key
> from A
> where o_key = <some value>
> )
> )
>
> #1 (and other things with the same general pattern) are used in
> literally thousands of places in this one client's system, and is
> much nicer to write, but seems to be rather slower than #2. Is
> there any way to tweak the tables to tell the system something
> like "hey, B, whenever you're joined to A, you should seriously
> consider waiting for A to be filtered down to a manageable level
> first"? And similarly for C/B.
>
> MS SQL 2000, SP3, 6.5 compat mode. These are set in stone until
> we upgrade the accounting software (highly non-trivial).

No, in SQL 2000 there is no such thing. In SQL 2005 there is something
called plan guides which permits you force the exact query plan for a
query - without having to modify the query itself.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация