| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Mark Lubratt <mark(dot)lubratt(at)indeq(dot)com> |
| Cc: | pgsql-admin(at)postgresql(dot)org |
| Subject: | Re: Multiple inserts without COPY |
| Date: | 2004-03-04 04:22:35 |
| Message-ID: | 21228.1078374155@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-admin |
Mark Lubratt <mark(dot)lubratt(at)indeq(dot)com> writes:
> The deletes look something like
> delete from CL where CL_id = i
> where i could be a list of several hundred integers. Again, right now
> I iterate through the list.
Consider
delete from CL where CL_id in (i,j,k,...);
If you have hundreds of target values, it might be better to put them in
a temp table and go
delete from CL where CL_id in (select id from temp_table);
The latter should be reasonably quick in 7.4, but be warned that it'll
suck in prior releases.
> MySQL has a multiple insert feature where you simply append a bunch of
> (j, k)'s separated by a comma. Does PostgreSQL have anything like
> this?
That is SQL-spec syntax, but we've not gotten around to implementing it.
COPY is a lot faster for bulk inserts.
> I was hoping I might be able to use COPY, but I see that's
> really only for psql.
Huh? You can use COPY FROM STDIN in most of our client libraries,
certainly so with libpq. What are you using?
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Mark Lubratt | 2004-03-04 05:12:46 | Re: Multiple inserts without COPY |
| Previous Message | Mark Lubratt | 2004-03-04 02:50:27 | Multiple inserts without COPY |