Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 162B69FC4D7 for ; Fri, 22 Jun 2007 12:04:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 32811-07 for ; Fri, 22 Jun 2007 12:04:34 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 4B5119FC4E3 for ; Fri, 22 Jun 2007 12:04:34 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 75EC33141E; Fri, 22 Jun 2007 17:04:32 +0200 (MET DST) From: Rainer Bauer X-Newsgroups: pgsql.interfaces.odbc Subject: Why is UseDeclareFetch so slow? Date: Fri, 22 Jun 2007 17:06:11 +0200 Organization: Hub.Org Networking Services Lines: 33 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org X-Newsreader: Forte Agent 4.2/32.1117 To: pgsql-odbc@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.294 tagged_above=0 required=5 tests=AWL=0.293, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200706/50 X-Sequence-Number: 9039 Hello, based on the problem I had here I thought it would be interesting to know why UseDeclareFetch is slowing my query down dramatically. I have a table containing 50 tuples and retrieve all 50 tuples with a bound column select statement: SELECT * FROM tblItem WHERE intItemIDCnt = ? This takes 8 seconds (over a slow DSL connection with 150ms ping). Tom Lane suggested enabling UseDeclareFetch and the performance drop was significant: Instead of 8 seconds, the query now takes 30-32 seconds. I also tested enabling UseServerSidePrepare (without UseDeclareFetch) and the query was executed in 7 seconds. After rewriting the query to use an IN clause it now works perfect: SELECT * FROM tblItem WHERE intItemIDCnt IN (...) The result is retrieved in 400ms (UseServerSidePrepare=950ms and UseDeclareFetch=1242ms). The only thread I found discussing the UseDeclareFetch/UseServerSidePrepare options was . So my questions are 1) Is there any chance the driver itself could be enhanced like Dimitri suggested here: ? 2) When should UseServerSidePrepare be used? 3) When should UseDeclareFetch be used? Rainer