Re: COPY and indices?

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: COPY and indices?
Дата
Msg-id CAOR=d=2YPLXQGi7RF+vL1ge59tR-oTsMS5qJETWNDw9QoevJdA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: COPY and indices?  (hamann.w@t-online.de)
Список pgsql-general
On Tue, Mar 13, 2012 at 12:51 AM,  <hamann.w@t-online.de> wrote:
>
> Scott Marlowe wrote:
> 2012/3/12 François Beausoleil <francois@teksol.info>:
>> Hi all,
>>
>> When using COPY FROM STDIN to stream thousands of rows (20k and more hourly), what happens with indices? Are they
updatedonly once after the operation, or are they updated once per row? Note that I'm not replacing the table's data:
I'mappending to what's already there. I suspect batching writes will be faster than writing each individual row using
anINSERT statement. 
>
> Copy is faster, but if a single row fails (dup key etc) the whole copy fails.
>
> Hi Scott,
>
> my impression: it would be even faster to drop the indices, do the bulk copy,
> and rebuild the indices after the fact.

That depends.  If you've got 100M rows already in place and you're
adding 1000 rows, it's likely cheaper to leave the indexes in place.
OTOH, if you've 1M rows already in place and are adding 100M it's
almost certainly cheaper to drop the indexes and recreate them.  So
dropping and recreating the indexes isn't necessarily faster,
depending on how big the table already is.

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

Предыдущее
От: François Beausoleil
Дата:
Сообщение: Re: COPY and indices?
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: COPY and indices?