Re: Inserting heap tuples in bulk in COPY

Поиск
Список
Период
Сортировка
От Kohei KaiGai
Тема Re: Inserting heap tuples in bulk in COPY
Дата
Msg-id CADyhKSVjY5_WJfH18uK-5-WD4VPbnpVhdP+CZo-5w0hZY02qUA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Inserting heap tuples in bulk in COPY  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Ответы Re: Inserting heap tuples in bulk in COPY
Список pgsql-hackers
Hi Heikki,

I checked your patch, then I have a comment and two questions here.

The heap_prepare_insert() seems a duplication of code with earlier
half of existing heap_insert(). I think it is a good question to
consolidate these portion of the code.

I'm not clear the reason why the argument of
CheckForSerializableConflictIn() was
changed from the one in heap_insert(). Its source code comment describes as:       :    * For a heap insert, we only
needto check for table-level SSI locks.    * Our new tuple can't possibly conflict with existing tuple locks, and    *
heappage locks are only consolidated versions of tuple locks; they do    * not lock "gaps" as index page locks do.  So
wedon't need to identify    * a buffer before making the call.    */ 
Is it feasible that newly inserted tuples conflict with existing tuple
locks when
we expand insert to support multiple tuples at once?
It is a bit confusing for me.

This patch disallow multiple-insertion not only when before-row
trigger is configured,
but volatile functions are used to compute a default value also.
Is it a reasonable condition to avoid multiple-insertion?
All the datums to be delivered to heap_form_tuple() is calculated in
NextCopyFrom,
and default values are also constructed here; sequentially.
So, it seems to me we have no worry about volatile functions are not
invoked toward
each tuples. Or, am I missing something?

Thanks,

2011/9/14 Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>:
> On 13.08.2011 17:33, Tom Lane wrote:
>>
>> Heikki Linnakangas<heikki.linnakangas@enterprisedb.com>  writes:
>>>
>>> The patch is WIP, mainly because I didn't write the WAL replay routines
>>> yet, but please let me know if you see any issues.
>>
>> Why do you need new WAL replay routines?  Can't you just use the existing
>> XLOG_HEAP_NEWPAGE support?
>>
>> By any large, I think we should be avoiding special-purpose WAL entries
>> as much as possible.
>
> I tried that, but most of the reduction in WAL-size melts away with that.
> And if the page you're copying to is not empty, logging the whole page is
> even more expensive. You'd need to fall back to retail inserts in that case
> which complicates the logic.
>
>> Also, I strongly object to turning regular heap_insert into a wrapper
>> around some other more complicated operation.  That will likely have
>> bad consequences for the performance of every other operation.
>
> Ok. I doubt it makes any noticeable difference for performance, but having
> done that, it's more readable, too, to duplicate the code.
>
> Attached is a new version of the patch. It is now complete, including WAL
> replay code.
>
> --
>  Heikki Linnakangas
>  EnterpriseDB   http://www.enterprisedb.com
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>
>



--
KaiGai Kohei <kaigai@kaigai.gr.jp>


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

Предыдущее
От: Marti Raudsepp
Дата:
Сообщение: [PATCH] Caching for stable expressions with constant arguments v3
Следующее
От: Dean Rasheed
Дата:
Сообщение: Re: Inserting heap tuples in bulk in COPY