Re: Multiple inserts without COPY

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Multiple inserts without COPY
Дата
Msg-id 21228.1078374155@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Multiple inserts without COPY  (Mark Lubratt <mark.lubratt@indeq.com>)
Ответы Re: Multiple inserts without COPY
Список pgsql-admin
Mark Lubratt <mark.lubratt@indeq.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

В списке pgsql-admin по дате отправления:

Предыдущее
От: Mark Lubratt
Дата:
Сообщение: Multiple inserts without COPY
Следующее
От: Mark Lubratt
Дата:
Сообщение: Re: Multiple inserts without COPY