Re: Nested query problem

From: Michael A Chase tech (mchase_at_ix.netcom.com)
Date: 12/13/04


Date: Mon, 13 Dec 2004 06:24:38 -0800
To: Hardy Merrill <HMerrill@dhcr.state.ny.us>

On 12/13/2004 06:09 AM, Hardy Merrill said:

> I realize I'm splitting hairs here, and I'm no database expert, but I'm
> curious about your answer to this - wouldn't this be even slightly more
> efficient to write the WHERE clause conditions as most restricting
> first? In other words,
>
> SELECT feature.id
> FROM feature,
> reporter
> WHERE reporter.attributes_id = ? <=== most restrictive 1st
> AND feature.reporter_id = reporter.id <=== next most
> restrictive
>
> I was once told (or read?) that it is most efficient to put the most
> restrictive conditions first in the WHERE - is that right? I've always
> tended to put my joins towards the end of the WHERE when I have other
> criteria that I'm looking for - just curious to know if I've been doing
> it wrong.

The general answer is that it all depends. A RDBMS builds its search
plans based on a lot of factors; the order of the arguments may or may
not be one of them.

-- 
Mac :})
** I usually forward private questions to the appropriate mail list. **
Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.


Relevant Pages

  • Re: Nested query problem
    ... >> efficient to write the WHERE clause conditions as most restricting ... > Give a hobbit a ring and he eats fish for an age. ...
    (perl.dbi.users)
  • Re: UNSUBSCRIBING
    ... Eventually the list admin ... I think it's been three months since the last such request. ... Give a hobbit a ring and he eats fish for an age. ...
    (perl.dbi.users)
  • Re: DBD-Oracle question for Win2000
    ... provides pre-compiled packages to install using PPM. ... Give a hobbit a ring and he eats fish for an age. ...
    (perl.dbi.users)
  • Re: MySQL UPDATE Question...
    ... > clue what language you are speaking. ... > development and automation work for our group. ... Give a hobbit a ring and he eats fish for an age. ...
    (perl.dbi.users)
  • Re: How to test status of handler sth?
    ... > either failing or I lost the handle (sth). ... Give a hobbit a ring and he eats fish for an age. ...
    (perl.dbi.users)