Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 386B79FA250 for ; Thu, 4 Jan 2007 10:03:43 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 43023-01 for ; Thu, 4 Jan 2007 10:03:01 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from serveurmail01.codata.be (125.123.146.82.ipv4.evonet.be [82.146.123.125]) by postgresql.org (Postfix) with ESMTP id 1F22C9F938C for ; Thu, 4 Jan 2007 10:03:01 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by serveurmail01.codata.be (Postfix) with ESMTP id E2EB31838822 for ; Thu, 4 Jan 2007 15:02:58 +0100 (CET) X-DSPAM-Result: Innocent X-DSPAM-Processed: Thu Jan 4 15:02:55 2007 X-DSPAM-Confidence: 0.6164 X-DSPAM-Probability: 0.0000 X-DSPAM-Signature: 459d090f305881410093335 X-DSPAM-Factors: 27, X-Virus-Scanned: amavisd-new at Received: from serveurmail01.codata.be ([127.0.0.1]) by localhost (serveurmail01.codata.be [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CUAMe3oHtcj9 for ; Thu, 4 Jan 2007 15:02:55 +0100 (CET) Received: from [127.0.0.1] (38-179-112-217.fix.adsl.belcenter.be [217.112.179.38]) by serveurmail01.codata.be (Postfix) with ESMTP id 13FD71838820 for ; Thu, 4 Jan 2007 15:02:55 +0100 (CET) Message-ID: <459D090C.4000405@freesurf.fr> Date: Thu, 04 Jan 2007 15:02:52 +0100 From: Arnaud Lesauvage User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: pgsql-odbc@postgresql.org Subject: Slow query : join between jet and postgresql table Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 0701-0, 03/01/2007), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/4 X-Sequence-Number: 8543 Hi list ! I have a problem with a query in Access2000, which takes very long to run. It queries a linked Jet table (in an Access2000 backend) joined to a linked ODBC table (in a PostgreSQL backend). Postgresql's version is 8.2, PsqlODBC is 8.02.0200. The query itself is very basic : SELECT * FROM myAccessTable AS A INNER JOIN myPsqlTable AS P ON A.field1 = P.field2 WHERE A.condition = ; The field1 on the Access table has an index (non-unique). The Postgresql Table is more complex : it is a view that I link via ODBC. In this view, the field2 is unique, and is recognized by Access2000 as such (Access creates a Primary Key on this field). Running EXPLAIN ANALYZE on this view without conditions take ~500ms. If I add a condition on field 2, it runs in ~0.3ms. This view is linked via VBA code using this connection string : ODBC; DRIVER={PostgreSQL Unicode}; SERVER=myserver; PORT=5432; DATABASE=mydb; UID=xxx; PWD=xxx; UseDeclareFetch=1; Fetch=1000; TrueIsMinus1=1; BoolsAsChar=0; TextAsLongVarchar=1; RowVersioning=1; There are not a lot of rows returned (~5000). The first rows appear quite fast (~5 seconds), but if I want to go to the end of the result set, it takes some minutes. During this time, If I check PostgreSQL's status, it looks like for each line, it declares a cursor (DECLARE SQL000blabla with hold for "SELECT field2, myview.field2 FROM myview WHERE field2 = 'somevalue'"), and then FETCHes the result. This postgresql backend takes 100% of one CPU. IO usage is null, memory usage is quite low (~50MB). Is this normal behaviour ? How can I speed up this query ? Thanks a lot for your help on this ! -- Arnaud