pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: wieck@debis.com
To: secret@kearneydev.com
Cc: pgsql-sql@postgreSQL.org
Cc: johnridout@ctasystems.co.uk
Subject: Re: [SQL] Good Optimization
Date: Wed, 7 Jul 1999 19:22:57 +0200 (MET DST)
Message-ID: <m111vPN-0003ktC@orion.SAPserv.Hamburg.dsh.de> (raw)
In-Reply-To: <37836A99.6989795E@kearneydev.com>

>     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@debis.com (Jan Wieck) #





view thread (27+ messages)  latest in thread

Message-ID: <m111vPN-0003ktC@orion.SAPserv.Hamburg.dsh.de>
Permalink:  ../m111vPN-0003ktC@orion.SAPserv.Hamburg.dsh.de/
Also on:    postgresql.org/message-id/m111vPN-0003ktC@orion.SAPserv.Hamburg.dsh.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: wieck@debis.com, secret@kearneydev.com, johnridout@ctasystems.co.uk
  Subject: Re: [SQL] Good Optimization
  In-Reply-To: <m111vPN-0003ktC@orion.SAPserv.Hamburg.dsh.de>
  References: <37836A99.6989795E@kearneydev.com> <m111vPN-0003ktC@orion.SAPserv.Hamburg.dsh.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox