Re: [SQL] Good Optimization

From: wieck(at)debis(dot)com (Jan Wieck)
To: secret(at)kearneydev(dot)com (secret)
Cc: pgsql-sql(at)postgreSQL(dot)org, johnridout(at)ctasystems(dot)co(dot)uk
Subject: Re: [SQL] Good Optimization
Date: 1999-07-07 17:22:57
Message-ID: m111vPN-0003ktC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> There is a simple way to optimize SQL queries involving joins to
> PostgreSQL that I think should be handled by Postgre? If one is joining
> a tables a,b on attribute "x" and if one has something like x=3 then it
> helps A LOT to say: a.x=3 and b.x=3 in addition to saying a.x=b.x ...
> The example below shoulds the radical speed gain of doing this, and I
> think it isn't something real obvious to most people...
>
> Of course it could just be a common thing to do in SQL, anyway, just
> thought I'd let you all know what I discovered.
>
>
>
> Here is an example:
> [...]

Hmmmmm,

wouldn't it be nice to do such things automagically
(rewriter? planner?).

Even if I don't think that it is that trivial as it might
look like. The entire queries qualification is ONE big
expression of cascaded AND and OR nodes. Deciding which
constant expressions could be added again with substituted
Var nodes because there's some "VarX == VarY" and don't
falling into recursion traps isn't easy.

But no expression comparing two Var's of different RTE's can
be put down into an execution subtree. And that is what
reduces the amount of data to get joined. I think this is
worth the efford.

I think the best place for it will be at the top of the
optimizer. It's more an optimization issue even if
implemented in rewriting technique.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#========================================= wieck(at)debis(dot)com (Jan Wieck) #

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 1999-07-07 18:00:57 Re: [SQL] Good Optimization
Previous Message Bruce Momjian 1999-07-07 16:45:07 Re: [SQL] Good Optimization