query optimization on prepared statement through connection vi libpq

From: "Kevin Fallis" <kfallis(at)tazznetworks(dot)com>
To: <pgsql-interfaces(at)postgresql(dot)org>, <pgsql-performance(at)postgresql(dot)org>
Subject: query optimization on prepared statement through connection vi libpq
Date: 2006-12-01 18:04:06
Message-ID: 07FDEE0ED7455A48AC42AC2070EDFF7C014F7A89@corpsrv2.tazznetworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Background:

I have a connection pool around the libpq connection framework that I
have set up that has a working knowledge of SQL statements that have
been prepared. It tracks if statements have been prepared or not and if
they haven't it will prepare them so I can optimize statements going
through that connection. When the statement is prepared, I am assuming
the query planner does all the magic to figure out indexes to use and
whatnot. I am also assuming that at some point in time, if an ANALYZE
or VACUUM ANALYZE is performed, all connections in my connection pool
would re-optimize the plans so I get the best usage of indexes for the
size of the entries in any table I am connected with.

Problem:

It appears that my connections (there could be many with prepared
statements associated with them) are not falling to indexes that should
otherwise be hit in a heavy load, high record count activity against a
table. I can see that sequential scans are rampant when in fact these
selects should be indexed. I have VACUUMED, swept and windexed the hell
out of the tables and still I am seeing sequential scans.

Is there any reason I should consider a threading mechanism that
re-prepares statements to reform the query plan info? And..should not
the ANALYZE adjust existing prepared queries for me?

Kevin Fallis

kfallis(at)tazznetworks(dot)com

913.488.4705

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Kevin Fallis 2006-12-01 19:10:34 FW: query optimization on prepared statement through connection vi libpq
Previous Message Leandro Lucarella 2006-12-01 15:44:22 Re: Keep-alive support