Received: from mailsys01.intnet.net (antares.intnet.net [198.252.32.143]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4T3Q4E22662 for ; Mon, 28 May 2001 23:26:05 -0400 (EDT) (envelope-from joe@conway-family.com) Received: from [24.0.42.111] (HELO jecw2k1) by mailsys01.intnet.net (CommuniGate Pro SMTP 3.3.2) with SMTP id 8858273; Mon, 28 May 2001 22:54:45 -0400 Message-ID: <002901c0e7ea$d7ac9830$0705a8c0@jecw2k1> From: "Joe Conway" To: "Tom Lane" Cc: References: <002901c0e733$5e683590$0705a8c0@jecw2k1> <15650.991084313@sss.pgh.pa.us> Subject: Re: Re: [INTERFACES] remote database queries Date: Mon, 28 May 2001 19:55:37 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200105/1150 X-Sequence-Number: 9440 > [ Redirected away from the entirely inappropriate pgsql-interfaces list ] oops . . . sorry! > Until we fix that (maybe for 7.2, maybe not) your existing hack is > probably pretty reasonable. You could save some cycles by avoiding > conversion to text, though --- instead return an opaque datum that is > pointer-to-tuple-slot and let the dblink_tok function extract fields > from the tuple. Look at SQL function support and the FieldSelect > expression node type for inspiration. Thanks -- I'll take a look. > I think this would work if the planner weren't so enthusiastic about > trying to collapse the sub-SELECT query together with the main query. > Unfortunately it doesn't check to see if any set-valued functions are > involved before it collapses 'em --- leaving you with a set-valued > function call in the WHERE clause. Not sure if this is worth fixing, > considering that using set-valued functions in this way is just a > band-aid that doesn't have a long life expectancy. I'd certainly bow to your wisdom in this area, but I was thinking it would be useful (at times) to force a FROM clause sub-select to be treated as if it were a "real" table (probably not the best way to express this, but hopefully you get the idea). In MSSQL I've found many situations where putting intermediate results into a temp table, and then joining to it, is significantly faster than letting the optimizer do it's best. But the fact that MSSQL will return record sets from a stored procedure help makes this tolerable/manageable -- i.e. the whole ugly mess can be rolled into one nice neat strored procedure call. If the FROM clause sub-select could be treated, in a sense, like an on-the-fly temp table in PostgreSQL, a similar result is possible. And if the whole ugly mess is rolled up behind a view, no one has to know except the especially curious ;-) > > If you just need a hack with a short life expectancy, here's a hack that > I recommend not reading right before dinner ... might make you lose your > appetite ;-). Build the view as a dummy UNION: *Very* few things make me lose my appetite -- and this worked perfectly! Thank you. -- Joe