| From: | Daniel McGreal <daniel(dot)mcgreal(at)redbite(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | Alban Hertroys <haramrae(at)gmail(dot)com>, Radosław Smogura <rsmogura(at)softperience(dot)eu>, pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Prepared statements performance |
| Date: | 2012-05-10 14:50:18 |
| Message-ID: | CACAnjQzwyD2OFM7GNqCLtx0idak4RnBg4wTrAV5Fh9gTU35rDQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Doing the same tests from psql gives:
1. ~2.5 seconds for INSERT/VALUES
2. ~10 seconds for prepared statement executes
3. ~15 seconds for multiple INSERTs
Dan.
On Thu, May 10, 2012 at 3:42 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Alban Hertroys <haramrae(at)gmail(dot)com> writes:
> > On 10 May 2012 15:05, Radosław Smogura <rsmogura(at)softperience(dot)eu> wrote:
> >> May I ask what kind of planning may occur during insert?
>
> > Well, for example, if there's a unique constraint on the table then
> > the database will have to check that the newly inserted values don't
> > conflict with values that are already in the table. It needs to plan
> > an efficient strategy for that, which depends on the values being
> > inserted.
>
> There is no planning associated with checking unique constraints; that's
> just a matter for the index mechanisms.
>
> I think the real point here is that a simple INSERT/VALUES has such a
> trivial plan that there is hardly any gain to be had by avoiding the
> planning stage. Then the other overhead of a prepared statement
> (looking up the saved plan, checking it's not stale, etc) outweighs
> that. Or at least it could. 3x slower seems a bit fishy; I wonder
> whether there's some client-side inefficiency involved in that.
> Doing performance measurements with pgAdmin seems pretty questionable
> in the first place ...
>
> regards, tom lane
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Albe Laurenz | 2012-05-10 14:50:36 | Re: vacuum, vacuum full and problems releasing disk space |
| Previous Message | Guy Helmer | 2012-05-10 14:42:21 | Re: vacuum, vacuum full and problems releasing disk space |