yugabyte/yugabyte-db
Voir sur GitHub[YSQL] `pg_total_relation_size` and `pg_table_size` return the same result for a table
Open
#23 181 ouverte le 11 juil. 2024
2025.1.2_blockerarea/ysqlgood first issuekind/enhancementpriority/medium
Métriques du dépôt
- Stars
- (8 229 stars)
- Métriques de merge PR
- (Merge moyen 17j 21h) (92 PRs mergées en 30 j)
Description
Jira Link: DB-12121
Description
pg_total_relation_size should return the size including index size.
/*
* Compute the on-disk size of all files for the relation,
* including heap data, index data, toast data, FSM, VM.
*/
static int64
calculate_total_relation_size(Relation rel)
{
int64 size;
/*
* Aggregate the table size, this includes size of the heap, toast and
* toast index with free space and visibility map
*/
size = calculate_table_size(rel);
...
/*
* Add size of all attached indexes as well
*/
size += calculate_indexes_size(rel);
return size;
}
We modified calculate_table_size to work for YB in D17169 / 2e767c443d80ac1144bfe75739dff84801f763b0.
static int64
calculate_table_size(Relation rel)
{
int64 size = 0;
ForkNumber forkNum;
if (IsYBRelation(rel))
{
....
HandleYBStatus(YBCPgGetTableDiskSize(YbGetRelfileNodeId(rel),
MyDatabaseId, (int64_t *)&size, &num_missing_tablets));
...
return size;
}
...
However, we missed modifying calculate_indexes_size, so it tries to check how much space an index is occupying on the local disk, instead of requesting the size from DocDB.
A similar fix would probably work here.
Issue Type
kind/enhancement
Warning: Please confirm that this issue does not contain any sensitive information
- I confirm this issue does not contain any sensitive information.