Received: from bastuba.partitur.se (bastuba.partitur.se [193.219.246.194]) by hub.org (8.9.3/8.9.3) with ESMTP id FAA56762 for ; Thu, 8 Jul 1999 05:24:14 -0400 (EDT) (envelope-from kudo@partitur.se) Received: from partitur.se (tb303.partitur.se [193.219.246.230]) by bastuba.partitur.se (8.8.8/8.8.8) with ESMTP id LAA17858; Thu, 8 Jul 1999 11:23:15 +0200 (CEST) (envelope-from kudo@partitur.se) Sender: kudo@partitur.se Message-ID: <37846E02.CB83939C@partitur.se> Date: Thu, 08 Jul 1999 11:23:14 +0200 From: Patrik Kudo Organization: Partitur Informationsteknik X-Mailer: Mozilla 4.51 [en] (X11; I; FreeBSD 3.2-STABLE i386) X-Accept-Language: sv,en MIME-Version: 1.0 To: Jan Wieck CC: maillist@candle.pha.pa.us, pgsql-sql@postgreSQL.org Subject: Re: [SQL] Good Optimization References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Jan Wieck wrote: > > > > > Bruce Momjian wrote: > > >=20 > > > Added to TODO: > > >=20 > > > * In WHERE x=3D3 AND x=3Dy, add y=3D3 > > > > I don't know if I'm way off, but wouldn't removing "x=3Dy" improve > > performance further? > > Maybe in the simple case above. But it will probably change > the result set if someone issues > > SELECT a.x, b.y FROM a, b WHERE a.x >= 10 > AND a.x <= 19 > AND a.x = b.x; > > which should then get rewritten into > > SELECT a.x, b.y FROM a, b WHERE a.x >= 10 > AND a.x <= 19 > AND a.x = b.x > AND b.x >= 10 > AND b.x <= 19; > > This time the "a.x = b.x" is important! Ouch... didn't think that far. However, if an cache is implemented it might be worth the extra overhead to optimize special cases like the one I commented on. Since most systems use a fairly limited set of queries (I suppose...) most of the queries will be cached quite fast. BTW, I just love the work all of you are doing! Postgres is awsome! /Kudo