Re: [HACKERS] Re: [SQL] cursor and update + view

From: Vadim Mikheev <vadim(at)krs(dot)ru>
To: Jan Wieck <jwieck(at)debis(dot)com>
Cc: s-fery(at)kkt(dot)sote(dot)hu, hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Re: [SQL] cursor and update + view
Date: 1998-12-01 04:26:18
Message-ID: 36636FEA.584583EE@krs.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas G. Lockhart 1998-12-01 06:00:43 Re: [HACKERS] sbufdesc' padding...
Previous Message Vadim Mikheev 1998-12-01 02:51:58 Re: [HACKERS] COMMIT

Browse pgsql-sql by date

  From Date Subject
Next Message S.Ramaswamy 1998-12-01 09:16:36 Re: [SQL] Odd characters in inserted data...
Previous Message Chauncey THorn 1998-12-01 02:23:36