X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C296C54FDF for ; Fri, 11 Mar 2005 09:31:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59916-01 for ; Fri, 11 Mar 2005 09:31:06 +0000 (GMT) Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net [194.217.242.91]) by svr1.postgresql.org (Postfix) with ESMTP id 47CD453D6E for ; Fri, 11 Mar 2005 09:31:05 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-33.mail.demon.net with esmtp (Exim 4.42) id 1D9gU5-000EIi-BJ; Fri, 11 Mar 2005 09:31:06 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 403241669E; Fri, 11 Mar 2005 09:31:00 +0000 (GMT) Message-ID: <42316552.4030306@archonet.com> Date: Fri, 11 Mar 2005 09:30:58 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "erne_dev @ Bellsouth.net" Cc: pgsql-odbc@postgresql.org Subject: Re: Queries run twice References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.062 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200503/44 X-Sequence-Number: 5062 erne_dev @ Bellsouth.net wrote: > Running version 8.0 server under WinXP, client is Builder/ADO application > connecting through ODBC. Found a reference to exactly the same problem on > this msg http://archives.postgresql.org/pgsql-odbc/2005-02/msg00033.php. Is > this a PostgreSQL bug? Or is it ODBC driver? Well, if the reply to that message is right, I think it's an unfortunate interaction between ADO/PostgreSQL. > My application also works with > MySQL and this doesn't happen when connecting to a MySQL server so I don't > think is has to do with the ADO components. Could you turn query-logging on in MySQL and just check? That would help to pin things down precisely. > Like the poster of that message > my query gets executed twice, one as I specified the second time without the > WHERE clause, so the whole Table is returned causing a lot of network > traffic and slowing things down...What is the 'parse statement' mentioned on > that message? Is that a PostgreSQL setting? There is a "parse statements" option in the ODBC driver's settings http://gborg.postgresql.org/project/psqlodbc/genpage.php?doc-config What I think is happening, is that for some reason the ADO code wants to know the types of the columns (even though it presumably already has this information in the first query). So - it issues the query without the WHERE and then doesn't actually fetch any rows, just checks what types are returned. Now, one difference between PostgreSQL and many other databases is that if you ask for 1 million rows, we return all those straight away. Many others keep the results server-side and only pass them to the client when asked for. Why return them all at once? 1. It frees up resources server-side for other clients 2. If the client asked for 1 million rows, then it presumably wants all of them, otherwise it would have said so. The problem occurs when you have application-generated code which is thinking in more of a dbf/file oriented way. It should really do "SELECT ... LIMIT 0" Anyway, that's only speculation - if you turn on MySQL statement logging and it still shows the second query, that's the problem. If it doesn't that suggests it's something in the ODBC driver. -- Richard Huxton Archonet Ltd