X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 23DC2475F09; Mon, 7 Apr 2003 16:08:10 -0400 (EDT) Received: from sabre.velocet.net (sabre.velocet.net [216.138.209.205]) by postgresql.org (Postfix) with ESMTP id 5A6CB475F39; Mon, 7 Apr 2003 16:08:09 -0400 (EDT) Received: from stark.dyndns.tv (H162.C233.tor.velocet.net [216.138.233.162]) by sabre.velocet.net (Postfix) with ESMTP id 01D59137F2C; Mon, 7 Apr 2003 16:08:05 -0400 (EDT) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) id 192cuS-0007gF-00; Mon, 07 Apr 2003 16:08:04 -0400 To: Tom Lane Cc: pgsql-hackers@postgresql.org, pgsql-interfaces@postgresql.org Subject: Re: [INTERFACES] More protocol discussion: breaking down query processing References: <24009.1049325358@sss.pgh.pa.us> In-Reply-To: <24009.1049325358@sss.pgh.pa.us> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 07 Apr 2003 16:08:04 -0400 Message-ID: <87smsuvzob.fsf@stark.dyndns.tv> Lines: 30 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-22.6 required=5.0 tests=BAYES_01,IN_REP_TO,REFERENCES,USER_AGENT_GNUS_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/242 X-Sequence-Number: 37732 Yay, this would be very cool. Two small things to keep in mind during design, though they aren't necessarily things needed in a first implementation: 1) There's an alternate form of the execute step that provides an array of sets of bind values and executes the original query many times, once for each set of bind values. This is essential for performing large batch data updates efficiently. Usually this would be for insert or update statements, I'm not sure if other databases even allow it for select queries, though I could imagine it being useful. 2) There could be an option to delay optimization until the bind stage. This would be an option the interface layer or application would provide in cases where either the query is unlikely to be repeated (such as if it was called from a higher level function that does the parse and bind step together) or is likely to be heavily affected by the input parameters (if the application programmer knows something special about the data distribution). Oh, and I'm sure it's obvious, but there would be no problem having multiple open cursors, right? So an application could prepare all the queries it's going to ever execute during initialization, then execute query 1, and for each row it fetches from 1 execute query 2 with calculated values. For some reason this isn't working with the PHP interface currently, I assume that's just a bug in the PHP driver, not in libpq. -- greg