From: | Mike Christensen <mike(at)kitchenpc(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: When does Postgres cache query plans? |
Date: | 2012-09-05 23:06:55 |
Message-ID: | CABs1bs0N7==qWCxj7n7TBLRpm8Qoqv_cEtFU7Ai6GAUVDeZowA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Sep 5, 2012 at 3:51 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Mike Christensen <mike(at)kitchenpc(dot)com> writes:
>> I'm curious under what circumstances Postgres will cache an execution
>> plan for a query.
>
> If you're writing raw SQL, never. The assumption is that the
> application knows its usage pattern a lot better than the server does,
> and if the application is going to re-execute the same/similar statement
> a lot of times, the app ought to make use of a prepared statement for
> that.
>
> Some client-side code (such as the JDBC driver) will make use of
> prepared statements under the hood, so a lot depends on context.
> But sending plain SQL with PQexec() does not result in any cached plan.
Excellent, that's pretty much what I figured (and would expect)..
It seems SQL Server and Oracle have some weird caching behavior that's
hard to understand and/or predict.. Postgres also seems to be unique
in the fact it even has a PREPARE statement.. MS SQL and Oracle only
provide that feature through the API..
Mike
From | Date | Subject | |
---|---|---|---|
Next Message | David Johnston | 2012-09-06 01:15:41 | Re: regexp_matches question |
Previous Message | Sergio Basurto | 2012-09-05 23:02:49 | Re: regexp_matches question |