Hello Team!
There's been an ongoing issue with pg_relation_size (and pg_total_relation_size) on
append-optimized tables, where these functions may not return accurate results. This is because
the appendonly_am relation_size function relies on an EOF marker, and returns the logical size of
the file. For example, if there have been a number of aborted transactions for the given table,
the actual size on disk might be much larger than the logical size. This is in contrast both to
heap tables and to the expected behavior, which is to return the physical size on disk.
On the other hand, several other code paths rely on the current behavior, and simply changing the
AM function would be inadvisable.
Instead we propose that pg_relation_size for AO tables should not call out to the AM handler and
instead should implement its own logic for measuring file size on disk of AO tables. One possible
implementation might be to leverage ao_foreach_extent_file with a callback that stats each file.
This has the obvious implication of changing the reported size of AO tables, and so I believe
should be done before GPDB7 goes GA.
I would love any feedback on this change, as well as any context on the current implementation
anyone might have to offer. Thank you for your help!
Sincerely,
Andrew (VMware)