pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vadim Mikheev <vadim@krs.ru>
To: Jan Wieck <jwieck@debis.com>
Cc: s-fery@kkt.sote.hu
Cc: hackers@postgreSQL.org
Subject: Re: [HACKERS] Re: [SQL] cursor and update + view
Date: Tue, 01 Dec 1998 11:26:18 +0700
Message-ID: <36636FEA.584583EE@krs.ru> (raw)
References: <m0ziyng-000EBfC@orion.SAPserv.Hamburg.dsh.de>

Jan Wieck wrote:
> 
> Vadim wrote:
> 
> > Subquery --> Join transformation/optimization implemented in
> > rule system will be used for Views only. Being implemented
> > in optimizer it will be used in all cases.
> 
>     Right  for the current rule system, because it looks only for
>     pg_rewrite entries to apply. Since it  is  called  for  every
>     optimizable statement, it could do this as a last step on the
>     querylist to be returned. Even if there  where  no  rules  to
>     apply.
> 
>     I still think that it's the right place to do. Transforming a
>     subselect into a join means to modify the users input,  doing
>     something  different finally.  This is kind of rewriting like
>     for view rules. Reading the debug  output  "After  rewriting"
>     someone  should  be  able to see which relations get scanned,
>     where and which of their attributes are used for what.
...
>     Could  you  give  me  an  example  where a subquery could get
>     translated into a join that produces exactly the same output,
>     no matter if there are duplicates or not?


Sybase' example:

select title, price 
from titles 
where price = 
   (select price 
    from titles 
    where title = "Straight Talk About Computers")

select t1.title, t1.price 
from titles t1, titles t2
where t1.price = t2.price and 
      t2.title = "Straight Talk About Computers"

- yes, executor should ensure that there was only one
record with t2.title equal "Straight Talk About Computers",
this could be flagged in some way...

On the other hand, I'm not sure that we have to concern
about such cases and about "unwise" queries at all -:)
So, forgive me for noise -:)

There are many other things to do and handling subqueries
in FROM is one of them.

Vadim



view thread (11+ messages)

Message-ID: <36636FEA.584583EE@krs.ru>
Permalink:  ../36636FEA.584583EE@krs.ru/
Also on:    postgresql.org/message-id/36636FEA.584583EE@krs.ru

 · 

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: vadim@krs.ru, jwieck@debis.com, s-fery@kkt.sote.hu, hackers@postgreSQL.org
  Subject: Re: [HACKERS] Re: [SQL] cursor and update + view
  In-Reply-To: <36636FEA.584583EE@krs.ru>
  References: <m0ziyng-000EBfC@orion.SAPserv.Hamburg.dsh.de> <36636FEA.584583EE@krs.ru>

* 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