Re: Equivalent queries and the planner

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: "John D(dot) Burger" <john(at)mitre(dot)org>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Equivalent queries and the planner
Date: 2005-10-15 14:24:08
Message-ID: 20051015142405.GC14113@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Oct 14, 2005 at 09:43:57AM -0400, John D. Burger wrote:
> (By the way, gazPlaces.gazPlaceID below is a primary key, so should be
> unique - I think that's required for these to be equivalent. I tested
> the two queries on small data sets, and they do indeed return the same
> results.)

I think that you also have to be sure that gazPlaceID is never NULL.
AFAIK the PostgreSQL doesn't track that sort of thing at all at the
planning/optimisation stage.

You're right, sometimes statements are equivalent but usually there is
some corner case (like NULLs, duplicate values, etc) that screw it up
for the general case. Teaching the planner all that is something not
yet done.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2005-10-15 14:27:18 Re: Windows Installation error
Previous Message Jan Wieck 2005-10-15 14:06:48 Re: Oracle buys Innobase