From: | Alex Hunsaker <badalex(at)gmail(dot)com> |
---|---|
To: | Divakar Singh <dpsmails(at)yahoo(dot)com> |
Cc: | Steve Singer <ssinger(at)ca(dot)afilias(dot)info>, jd(at)commandprompt(dot)com, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Postgres insert performance and storage requirement compared to Oracle |
Date: | 2010-10-27 19:45:06 |
Message-ID: | AANLkTi=0PkVscoYkMn-nETn16LAL4N-C8jzwGWffn7uV@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Wed, Oct 27, 2010 at 08:00, Divakar Singh <dpsmails(at)yahoo(dot)com> wrote:
> I am attaching my code below.
> Is any optimization possible in this?
> Do prepared statements help in cutting down the insert time to half for this
> kind of inserts?
In half? not for me. Optimization possible? Sure, using the code you
pasted (time ./a.out 100000 <method>):
PQexec: 41s
PQexecPrepared: 36s
1 insert statement: 7s
COPY: 1s
psql: 256ms
Basically the above echoes the suggestions of others, use COPY if you can.
Find the source for the above attached. Its just a very quick
modified version of what you posted. [ disclaimer the additions I
added are almost certainly missing some required error checking... ]
[ psql is fast because the insert is really dumb: insert into aaaa (a,
b, c, d, e, f, g, h, j, k, l, m, n, p) select 1, 'asdf', 'asdf',
'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf', 'asdf',
'asdf', 'asdf', 'asdf' from generate_series(1, 100000); ]
Attachment | Content-Type | Size |
---|---|---|
pq_ex.c | text/x-csrc | 5.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Jesper Krogh | 2010-10-27 19:47:23 | Re: Postgres insert performance and storage requirement compared to Oracle |
Previous Message | Justin Pitts | 2010-10-27 19:44:52 | Re: temporary tables, indexes, and query plans |