Re: Bulk Inserts
От | Adrian Klaver |
---|---|
Тема | Re: Bulk Inserts |
Дата | |
Msg-id | 9ffb5586-4217-b131-bed8-53b16feb5740@aklaver.com обсуждение исходный текст |
Ответ на | Re: Bulk Inserts (Souvik Bhattacherjee <kivuosb@gmail.com>) |
Ответы |
Re: Bulk Inserts
|
Список | pgsql-general |
On 8/10/19 7:47 PM, Souvik Bhattacherjee wrote: > Hi Adrian, > > Thanks for the response. > > > Yes, but you will some code via client or function that batches the > > inserts for you. > > Could you please elaborate a bit on how EXP 1 could be performed such > that it uses bulk inserts? I guess it comes down to what you define as bulk inserts. From your OP: EXP 1: inserts with multiple txn: insert into tab2 (attr1, attr2) (select attr1, attr2 from tab1 where attr2 = 10); insert into tab2 (attr1, attr2) (select attr1, attr2 from tab1 where attr2 = 20); If the selects are returning more then one row then you are already doing bulk inserts. If they are returning single rows or you want to batch them then you need some sort of code to do that. Something like(pseudo Python like code): attr2_vals= [(10, 20, 30, 40), (50, 60, 70, 80)] for val_batch in attr2_vals: BEGIN for id in val_batch: insert into tab2 (attr1, attr2) (select attr1, attr2 from tab1 where attr2 = id) COMMIT > > Best, > -SB -- Adrian Klaver adrian.klaver@aklaver.com
В списке pgsql-general по дате отправления: