From: Richard Huxton <dev@archonet.com>
To: erne_dev @ Bellsouth.net <erne_dev@bellsouth.net>
Cc: pgsql-odbc@postgresql.org
Subject: Re: Queries run twice
Date: Fri, 11 Mar 2005 09:30:58 +0000
Message-ID: <42316552.4030306@archonet.com> (raw)
In-Reply-To: <FIEALGGOPOGCKJEBMHJIIEGNCHAA.erne_dev@bellsouth.net>
References: <FIEALGGOPOGCKJEBMHJIIEGNCHAA.erne_dev@bellsouth.net>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: dev@archonet.com, erne_dev@bellsouth.net
Subject: Re: Queries run twice
In-Reply-To: <42316552.4030306@archonet.com>
References: <FIEALGGOPOGCKJEBMHJIIEGNCHAA.erne_dev@bellsouth.net> <42316552.4030306@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox