Small optimization set tuple block/tableOid once

Поиск
Список
Период
Сортировка
Искать

Small optimization set tuple block/tableOid once

От:
Ranier Vilela <ranier.vf@gmail.com>
Дата:
Вложения:
Hi.

Inspired by [1]
There is an opportunity for optimization according to the commit:
" Due to splitting the block id into two 16 bit integers, BlockIdSet() is more expensive than one might think. Doing it once per returned tuple shows up as a small but reliably reproducible cost. It's simple enough to set the block number just once per block in pagemode, so do so."

By moving the invariants out of the loop, it really is an improvement.

Then the following sources can be optimized:
contrib/pg_visibility/pg_visibility.c
contrib/pgstattuple/pgstatapprox.c
src/backend/access/heap/heapam.c
src/backend/access/heap/heapam_handler.c
src/backend/access/heap/pruneheap.c
src/backend/access/heap/vacuumlazy.c
src/backend/commands/dbcommands.c

Attached all patchs.

best regards,
Ranier Vilela

Re: Small optimization set tuple block/tableOid once

От:
Ranier Vilela <ranier.vf@gmail.com>
Дата:
Вложения:
rebased heapam.c and heapam_handler.c

best regards,
Ranier Vilela

Re: Small optimization set tuple block/tableOid once

От:
David Rowley <dgrowleyml@gmail.com>
Дата:
On Thu, 3 Apr 2025 at 23:09, Ranier Vilela  wrote:
> rebased heapam.c and heapam_handler.c

This doesn't work. The tids are not being set in all cases.

patched:
select tableoid,ctid,oid from pg_class TABLESAMPLE BERNOULLI (100);
 tableoid |  ctid   |  oid
----------+---------+-------
     1259 | (0,0)   | 16409
     1259 | (0,0)   | 16403
     1259 | (0,0)   | 16412
     1259 | (0,0)   | 16407
     1259 | (0,0)   | 16415
     1259 | (0,0)   | 16418
     1259 | (0,0)   | 16434
...

master:
 tableoid |  ctid   |  oid
----------+---------+-------
     1259 | (0,10)  | 16409
     1259 | (0,11)  | 16403
     1259 | (0,12)  | 16412
     1259 | (0,13)  | 16407
     1259 | (0,15)  | 16415
     1259 | (0,16)  | 16418
     1259 | (0,17)  | 16434
...

David


FAQ