RE: temp table on commit delete rows performance issue

Поиск
Список
Период
Сортировка
От Floris Van Nee
Тема RE: temp table on commit delete rows performance issue
Дата
Msg-id 1015a04ccde24dd8a0779e6f7cbdfda9@Optiver.com
обсуждение исходный текст
Ответ на Re: temp table on commit delete rows performance issue  (feichanghong <feichanghong@qq.com>)
Список pgsql-hackers
> It seems that in your patch, WAL logging is skipped for all tables, not just
> temporary tables.

This code path is only used in two cases though:
* For the temporary tables ON COMMIT DROP
* For truncating tables that were created in the same transaction, or which
were already truncated in the same transaction (this is some special case
in the TRUNCATE command)
In both cases I believe it's not necessary to log the lock, as the table doesn't exist
on replica yet or the exclusive lock has already been obtained and logged previously.
Regular TRUNCATE commands go through a completely different code path,
as these need to be rollbackable if the transaction aborts.

> Upon further consideration, do we really need to acquire AccessExclusiveLocks
> for temporary tables? Since temporary tables can only be accessed within the
> current session, perhaps we can make the following optimizations:

This one I'm less sure of if it's correct in all cases. Logically it makes sense that no other
backends can access it, however I see some threads [1] that suggest that it's technically
possible for other backends to take locks on these tables, so it's not *that* obvious there
are no edge cases.

[1] https://postgrespro.com/list/thread-id/2477885



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

Предыдущее
От: Paul Jungwirth
Дата:
Сообщение: Re: SQL:2011 application time
Следующее
От: James Coleman
Дата:
Сообщение: Re: Seq scan instead of index scan querying single row from primary key on large table