Received: from dune.krs.ru (dune.krs.ru [195.161.16.38]) by hub.org (8.9.1/8.9.1) with ESMTP id AAA09811 for ; Tue, 1 Dec 1998 00:38:44 -0500 (EST) (envelope-from vadim@krs.ru) Received: from krs.ru (localhost.krs.ru [127.0.0.1]) by dune.krs.ru (8.8.8/8.8.7) with ESMTP id LAA12321; Tue, 1 Dec 1998 11:26:18 +0700 (KRS) (envelope-from vadim@krs.ru) Sender: root@dune.krs.ru Message-ID: <36636FEA.584583EE@krs.ru> Date: Tue, 01 Dec 1998 11:26:18 +0700 From: Vadim Mikheev Organization: OJSC Rostelecom (Krasnoyarsk) X-Mailer: Mozilla 4.5 [en] (X11; I; FreeBSD 2.2.6-RELEASE i386) X-Accept-Language: ru, en MIME-Version: 1.0 To: Jan Wieck CC: s-fery@kkt.sote.hu, hackers@postgreSQL.org Subject: Re: [HACKERS] Re: [SQL] cursor and update + view References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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