Re: Slow cross-machine read on one table - Mailing list pgsql-general

From Craig Ringer
Subject Re: Slow cross-machine read on one table
Date
Msg-id 499255A8.1020402@postnewspapers.com.au
Whole thread Raw
In response to Slow cross-machine read on one table  ("Rob Richardson" <Rob.Richardson@rad-con.com>)
List 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

pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Deleting conflicting rows when creating a foreign key
Next
From: Hiroshi Inoue
Date:
Subject: Re: encoding of PostgreSQL messages