pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: jwieck@debis.com
To: djackson@cpsgroup.com
Cc: jwieck@debis.com
Cc: caffeine@toodarkpark.org
Cc: selkovjr@mcs.anl.gov
Cc: pierre@desertmoon.com
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Joining bug????
Date: Wed, 28 Oct 1998 18:56:08 +0100 (MET)
Message-ID: <m0zYZpI-000EBPC@orion.SAPserv.Hamburg.dsh.de> (raw)
In-Reply-To: <F10BB1FAF801D111829B0060971D839F4AD59E@cpsmail>

>
> > > try making a view.  from what others have said, views save the query
> > plan
> > > and have usually, at least for me, been _alot_ faster than normal
> > queries.
> >
> >     Views don't save query plans. They are parsetree templates in
> >     query rewrite rules.
> >
> So, could you explain what counts for the speed increase.  Is the parse
> stage really that costly?

    BTW:  You  might want to take a look at the new documentation
    of the rule system to understand how views work in detail.

    It could only be the parse stage. After the  rule  system  is
    through  with the query, the parsetree given to the optimizer
    is exactly the same  as  if  you  typed  in  the  query  that
    accesses the real tables.  Having a view

        CREATE VIEW v1 AS SELECT t1.a, t2.b FROM t1, t2
            WHERE t1.a = t2.a;

    and doing a

        SELECT * FROM v1 WHERE a = 'something';

    is 100% the same as

        SELECT t1.a, t2.b FROM t1, t2
            WHERE t1.a = 'something'
              AND t1.a = t2.a;

    The  optimizer  will  get exactly the same parsetree and will
    generate the same plan then. So the timing difference  cannot
    be in the optimizer or executor.

    But  it's  interesting.  I'll  do some tests on it and try to
    find out whether parsing of complicated WHERE clauses is that
    costly  that  it  can be the reason. Seems the rule system is
    quicker than the parser :-)


Jan

--

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





view thread (16+ messages)  latest in thread

Message-ID: <m0zYZpI-000EBPC@orion.SAPserv.Hamburg.dsh.de>
Permalink:  ../m0zYZpI-000EBPC@orion.SAPserv.Hamburg.dsh.de/
Also on:    postgresql.org/message-id/m0zYZpI-000EBPC@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: jwieck@debis.com, djackson@cpsgroup.com, caffeine@toodarkpark.org, selkovjr@mcs.anl.gov, pierre@desertmoon.com
  Subject: Re: [SQL] Joining bug????
  In-Reply-To: <m0zYZpI-000EBPC@orion.SAPserv.Hamburg.dsh.de>
  References: <F10BB1FAF801D111829B0060971D839F4AD59E@cpsmail> <m0zYZpI-000EBPC@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