pg_buffercache: Change page_num type to bigint
authorTomas Vondra <[email protected]>
Tue, 8 Apr 2025 09:52:02 +0000 (11:52 +0200)
committerTomas Vondra <[email protected]>
Tue, 8 Apr 2025 10:38:42 +0000 (12:38 +0200)
The page_num was defined as integer, which should be sufficient for the
near future (with 4K pages it's 8TB). But it's virtually free to return
bigint, and get a wider range. This was agreed on the thread, but I
forgot to tweak this in ba2a3c2302f1.

While at it, make the data types in CREATE VIEW a bit more consistent.

Discussion: https://postgr.es/m/CAKZiRmxh6KWo0aqRqvmcoaX2jUxZYb4kGp3N%3Dq1w%2BDiH-696Xw%40mail.gmail.co

contrib/pg_buffercache/pg_buffercache--1.5--1.6.sql
contrib/pg_buffercache/pg_buffercache_pages.c
doc/src/sgml/pgbuffercache.sgml

index 85a23c651642320c058ed619e92ce3b68c430be4..458f054a691791272188c04177abf4d2759a0076 100644 (file)
@@ -12,7 +12,7 @@ LANGUAGE C PARALLEL SAFE;
 -- Create a view for convenient access.
 CREATE VIEW pg_buffercache_numa AS
    SELECT P.* FROM pg_buffercache_numa_pages() AS P
-   (bufferid integer, os_page_num int4, numa_node int4);
+   (bufferid integer, os_page_num bigint, numa_node integer);
 
 -- Don't want these to be available to public.
 REVOKE ALL ON FUNCTION pg_buffercache_numa_pages() FROM PUBLIC;
index 54c83601418a87f116b623cb083f0932aa068027..c9ceba604b1b03e7024f5752e7513dae88ca7af9 100644 (file)
@@ -72,7 +72,7 @@ typedef struct
 typedef struct
 {
    uint32      bufferid;
-   int32       page_num;
+   int64       page_num;
    int32       numa_node;
 } BufferCacheNumaRec;
 
@@ -414,7 +414,7 @@ pg_buffercache_numa_pages(PG_FUNCTION_ARGS)
        TupleDescInitEntry(tupledesc, (AttrNumber) 1, "bufferid",
                           INT4OID, -1, 0);
        TupleDescInitEntry(tupledesc, (AttrNumber) 2, "os_page_num",
-                          INT4OID, -1, 0);
+                          INT8OID, -1, 0);
        TupleDescInitEntry(tupledesc, (AttrNumber) 3, "numa_node",
                           INT4OID, -1, 0);
 
@@ -522,7 +522,7 @@ pg_buffercache_numa_pages(PG_FUNCTION_ARGS)
        values[0] = Int32GetDatum(fctx->record[i].bufferid);
        nulls[0] = false;
 
-       values[1] = Int32GetDatum(fctx->record[i].page_num);
+       values[1] = Int64GetDatum(fctx->record[i].page_num);
        nulls[1] = false;
 
        values[2] = Int32GetDatum(fctx->record[i].numa_node);
index ef5732942f792913bcfe10a2bff3abf590e6dd01..537d6014942429dbc1340f4af920a419e113d729 100644 (file)
 
      <row>
       <entry role="catalog_table_entry"><para role="column_definition">
-       <structfield>os_page_num</structfield> <type>int</type>
+       <structfield>os_page_num</structfield> <type>bigint</type>
       </para>
       <para>
        number of OS memory page for this buffer