Thread: Query is significantly slower on faster machine

Query is significantly slower on faster machine

From
"Andy Lowe"
Date:

Hello-

I've got an application that runs on the same machine as my database.  The application contains a query that was taking significantly too long to run on a test system.  On my development machine, it runs approximately 8-10 times faster, using a database containing identical data.  When I first started looking at the issue, I wondered if different versions of PostgreSQL were running.  Both machines are running the 7.3.2.0 version of the ODBC driver.  But, my development machine is running 7.4-1 and the test machine was running 7.4.1-3.  I experimented with different versions to see if that made a difference.  It didn't.  I went so far as to copy my whole cygwin directory from my development machine to the test machine, just to make sure everything was exactly the same, and the test machine was still taking longer to run the query.  I tried having the application running on the test machine connect to the database on my development machine.  Again, it was very slow.

Both are runing Win2K SP4.  The development machine is a 2Ghz Athlon with 768MB RAM, and the test machine has dual 2.8Ghz Xeons with 2Gig RAM, so it's not like the test machine is slower.

Since I've made sure that the database software was identical (assuming doing a directory copy results in identical software, which seems reasonable), I doubt that there is any kind of configuration difference between the databases on the two machines.  Since connecting to my development database from the test machine results in a slow query, that points to a problem with the test machine.  I have the DSNs set up exactly the same on both machines, so that's not an issue.  But, both systems are running the same version of the ODBC driver, so that shouldn't be a problem either.  My best guess is that there is something wrong with the ODBC connection on the test machine, since that is what is slow, regardless of what database it is connecting to.  However, since the drivers on both machines are identical (yes, I have reinstalled them), I don't see how that's possible.

So, given two seemingly identical configurations, a faster machine takes longer to run a query than a slow machine.  Anyone have any explanations for that or ideas for other things to try?

Thanks in advance,
Andy Lowe
DMetrix Software Engineer
andyl@dmetrix.com

Re: Query is significantly slower on faster machine

From
Tom Lane
Date:
"Andy Lowe" <andyl@dmetrix.com> writes:
> I've got an application that runs on the same machine as my database.  The
> application contains a query that was taking significantly too long to run
> on a test system.  On my development machine, it runs approximately 8-10
> times faster, using a database containing identical data.

My first instinct is to think that you're getting different plans for
the query.  Try EXPLAIN ANALYZE'ing the query on both systems and see
what you get.

            regards, tom lane