Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154]) by hub.org (8.10.1/8.11.0) with ESMTP id e9JNnLJ65799; Thu, 19 Oct 2000 19:49:21 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.1/8.11.1) with ESMTP id e9JNnA512801; Thu, 19 Oct 2000 19:49:10 -0400 (EDT) To: "Michael Richards" cc: pgsql-hackers@postgreSQL.org, pgsql-sql@postgreSQL.org Subject: Re: Conditional query plans. In-reply-to: <39EF613E.000005.22998@frodo.searchcanada.ca> References: <39EF613E.000005.22998@frodo.searchcanada.ca> Comments: In-reply-to "Michael Richards" message dated "Thu, 19 Oct 2000 17:01:50 -0400" Date: Thu, 19 Oct 2000 19:49:09 -0400 Message-ID: <12798.971999349@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200010/761 X-Sequence-Number: 7791 "Michael Richards" writes: > The second and probably less optimal plan would be to create a hash > of these 25 answers and do a sequential scan on users updating rows > where id is found in that hash. Given the presence of the "materialize" nodes, I don't think this query plan is quite as nonoptimal as you think, especially for ~25 rows out of the subplan. It's a linear search over a 25-entry table for each outer row, but so what? With hundreds or thousands of rows out of the subquery, it'd be nice to have a smarter table lookup method, agreed, but here it hardly matters. Something that's been on the todo list for a long time is to try to convert WHERE foo IN (SELECT ...) queries into some kind of join, instead of a subselect. With that approach we'd be able to use merge or hash strategies to match up inner and outer rows, which'd work a lot better when there are large numbers of rows involved. It might actually happen for 7.2... regards, tom lane