Re: Persistent Plan Cache

From: Ivan Voras <ivoras(at)freebsd(dot)org>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Persistent Plan Cache
Date: 2009-09-14 10:30:26
Message-ID: h8l5vi$ul6$2@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Joshua Rubin wrote:
> Hi,
>
> We have a very large, partitioned, table that we often need to query
> from new connections, but frequently with similar queries. We have
> constraint exclusion on to take advantage of the partitioning. This also
> makes query planning more expensive. As a result, the CPU is fully
> loaded, all the time, preparing queries, many of which have been
> prepared, identically, by other connections.
>
> Is there any way to have a persistent plan cache that remains between
> connections? If such a mechanism existed, it would give us a great
> speedup because the CPU's load for planning would be lightened
> substantially.

It's not a great solution, but depending on the specific client
technology you use, it can done on the client-side. For example, I've
done it before in Java and PHP, and the principle extends to any
environment that has any possibility of maintaining "persistent"
connections to the database, if you create a thin wrapper for the
connections.

I have open-sourced such a wrapper for PHP, if you're interested.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message zz_11 2009-09-14 10:49:39 Re: possible wrong query plan on pg 8.3.5,
Previous Message tv 2009-09-14 09:32:45 Re: possible wrong query plan on pg 8.3.5,