X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 552DD9FB1F0 for ; Thu, 20 Jul 2006 16:54:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 59848-02-3 for ; Thu, 20 Jul 2006 16:54:56 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 753239FB55B for ; Thu, 20 Jul 2006 15:53:18 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1G3ddv-0000s5-UL for pgsql-jdbc@postgresql.org; Thu, 20 Jul 2006 20:53:03 +0200 Received: from 83.145.96.118 ([83.145.96.118]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 20 Jul 2006 20:53:03 +0200 Received: from Marc.Herbert by 83.145.96.118 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 20 Jul 2006 20:53:03 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Marc Herbert Subject: "prepared" statements (Re: Limit vs setMaxRows issue) Date: Thu, 20 Jul 2006 20:52:49 +0200 Lines: 56 Message-ID: References: <44990D57.9070506@sebster.com> <34158.216.41.12.254.1150906222.squirrel@webmail.webopticon.org> <11362.1150908394@sss.pgh.pa.us> <44B34751.7010704@opencloud.com> <44B38164.1040606@opencloud.com> <44B4823B.6010909@opencloud.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 83.145.96.118 User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4 (Jumbo Shrimp, linux) Cancel-Lock: sha1:UBiIiuDBHYIRADuBA6UPlDjq4ag= X-Archive-Number: 200607/66 X-Sequence-Number: 15492 Oliver Jowett writes: > I am a bit confused about what this discussion is actually about .. do > you have a point to make here? What is it that you want to do that the > current driver doesn't do well? A fair amount of work has gone into > getting query execution working smoothly and efficiently within the > constraints of the API already.. Vague high-level handwaving, > especially without a clear target, doesn't get us anywhere. For > example, it's largely irrelevant to an application whether the query > gets parsed by the server at statement creation or statement execution > .. at worst, it means you see parse errors at a different point. - By the way: Retrieves a ResultSetMetaData object that contains information about the columns of the ResultSet object that will be returned when this PreparedStatement object is executed. Because a PreparedStatement object is precompiled, it is possible to know about the ResultSet object that it will return without having to execute it. Consequently, it is possible to invoke the method getMetaData on a PreparedStatement object rather than waiting to execute it and then invoking the ResultSet.getMetaData method on the ResultSet object that is returned. Similar thing for #getParameterMetadata() - However, in the 3rd edition of the JDBC book: 23.1.3 Using parameter metadata wisely The purpose of a prepared statement is to allow the data source to "prepare" an SQL statement, that is, to compile an SQL statement before it is executed. [..] However, not all data sources prepare a statement the same way, and some do not prepare them at all. If a data source does not precompile SQL statements, the ParameterMetaData methods will not be able to return results until execution [this is a lie because it misses "lazy" implementations, see below]. According to my (limited) understanding of the code, pgjdbc sends a special "describe" request to the server for #getMetadata() in case the statement has not been executed yet, and systematically for #getParameterMetadata(). Neither one seems to cache results, at least not on the driver-side. As you said above, all this looks very well-crafted to be functionally irrelevant to the application. It definitely looks relevant and good to know concerning performance.