Re: Equivalent queries and the planner

From: Neil Conway <neilc(at)samurai(dot)com>
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-16 01:29:39
Message-ID: 1129426179.8219.44.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2005-14-10 at 09:43 -0400, John D. Burger wrote:
> I believe these queries are exactly equivalent, but I presume the
> planner doesn't know that.

> explain select gazPlaceID from gazPlaces
> where gazPlaceID not in (select gazPlaceID from gazContainers);

> explain select gazPlaceID from gazPlaces
> except select gazPlaceID from gazContainers;

Yeah, query optimization for set operations is currently quite
primitive; the above transformation is not yet implemented.

> In general, there are lots of ways to express the same abstract
> information need in SQL, and I assumed that there were some set of
> (probably incomplete) equivalencies encoded somewhere. Is this so?

I don't know of a canonical list of planner transformations. There are
some presentations on planner internals that touch on this, which is
better than nothing:

http://neilc.treehou.se/optimizer.pdf
http://conferences.oreillynet.com/presentations/os2003/lane_tom.pdf

-Neil

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-10-16 03:50:36 Re: Question/problem with create view and restore a backup with such a view
Previous Message Chris Travers 2005-10-16 01:04:54 Re: On "multi-master"