From: | "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Change xl_hash_vacuum_one_page.ntuples from int to uint16 |
Date: | 2023-01-10 10:08:33 |
Message-ID: | b0e20c40-cb7a-fc1c-c607-2a78dac5021e@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi hackers,
While working on [1], I noticed that xl_hash_vacuum_one_page.ntuples is an int.
Unless I'm missing something, It seems to me that it would make more sense to use an uint16 (like this is done for
gistxlogDelete.ntodelete for example).
Please find attached a patch proposal to do so.
While that does not currently change the struct size:
No patch:
(gdb) ptype /o struct xl_hash_vacuum_one_page
/* offset | size */ type = struct xl_hash_vacuum_one_page {
/* 0 | 4 */ TransactionId snapshotConflictHorizon;
/* 4 | 4 */ int ntuples;
/* total size (bytes): 8 */
}
With patch:
(gdb) ptype /o struct xl_hash_vacuum_one_page
/* offset | size */ type = struct xl_hash_vacuum_one_page {
/* 0 | 4 */ TransactionId snapshotConflictHorizon;
/* 4 | 2 */ uint16 ntuples;
/* XXX 2-byte padding */
/* total size (bytes): 8 */
}
It could reduce it when adding new fields (like this is is done in [1]).
We would get:
No patch:
(gdb) ptype /o struct xl_hash_vacuum_one_page
/* offset | size */ type = struct xl_hash_vacuum_one_page {
/* 0 | 4 */ TransactionId snapshotConflictHorizon;
/* 4 | 4 */ int ntuples;
/* 8 | 1 */ _Bool isCatalogRel;
/* XXX 3-byte padding */
/* total size (bytes): 12 */
}
With patch:
(gdb) ptype /o struct xl_hash_vacuum_one_page
/* offset | size */ type = struct xl_hash_vacuum_one_page {
/* 0 | 4 */ TransactionId snapshotConflictHorizon;
/* 4 | 2 */ uint16 ntuples;
/* 6 | 1 */ _Bool isCatalogRel;
/* XXX 1-byte padding */
/* total size (bytes): 8 */
}
Means saving 4 bytes in that case.
Looking forward to your feedback,
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
Attachment | Content-Type | Size |
---|---|---|
v1-0001-xl_hash_vacuum_one_page_ntuples_as_uint16.patch | text/plain | 726 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Dean Rasheed | 2023-01-10 10:11:50 | Re: Add proper planner support for ORDER BY / DISTINCT aggregates |
Previous Message | Peter Eisentraut | 2023-01-10 09:57:36 | Re: Collation version tracking for macOS |