Re: Slow cross-machine read on one table

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Rob Richardson <Rob(dot)Richardson(at)rad-con(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Slow cross-machine read on one table
Date: 2009-02-11 04:35:52
Message-ID: 499255A8.1020402@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rob Richardson wrote:
> The slow access seems to be happening with a single table. Here's the
> query:

Can you post EXPLAIN ANALYZE output?

> This query took about 75 seconds.
>
> I ran PGAdmin on the same machine that the application is running on,
> and executed the same query on the same database. It took about 30
> milliseconds.

In your application, are you using server-side prepared statements with
query parameters for some of the values in that query?

Try testing through PGAdmin / psql using PREPARE (with the same
parameter placeholders as your app uses) then EXECUTE, instead of a
straight SELECT.

If you get much slower execution that way, it'll be because the planner
doesn't know specific values for the parameter placeholders when
planning the query, so it can't make use of knowledge gained from table
statistics like "almost all values in the 'archived' column are zero'.

--
Craig Ringer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Hiroshi Inoue 2009-02-11 05:20:47 Re: encoding of PostgreSQL messages
Previous Message Craig Ringer 2009-02-11 04:30:39 Re: Deleting conflicting rows when creating a foreign key