Skip to content

Commit

Permalink
cache
Browse files Browse the repository at this point in the history
  • Loading branch information
RekGRpth committed Oct 21, 2024
1 parent 2fdc844 commit 5e47ef3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 31 deletions.
2 changes: 1 addition & 1 deletion src/diskquota_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ get_rel_oid_list(bool is_init)
List *oidlist = NIL;
int ret;

#define SELECT_FROM_PG_CATALOG_PG_CLASS "select unnest(array_remove(array[c.oid, indexrelid], null)) from pg_catalog.pg_class c left join pg_catalog.pg_index i on c.oid = indrelid where c.oid >= $1 and relkind in ('r', 'm')"
#define SELECT_FROM_PG_CATALOG_PG_CLASS "select unnest(array_remove(array[c.oid, indexrelid], null)) from pg_catalog.pg_class c left join pg_catalog.pg_index i on c.oid = indrelid where c.oid >= $1 and relkind in ('r', 'm') union distinct select relid from diskquota.show_relation_cache() where relid = primary_table_oid"

ret = SPI_execute_with_args(is_init ? SELECT_FROM_PG_CATALOG_PG_CLASS
" union distinct"
Expand Down
30 changes: 0 additions & 30 deletions src/quotamodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,34 +868,6 @@ refresh_disk_quota_usage(bool is_init)
return;
}

static List *
merge_uncommitted_table_to_oidlist(List *oidlist)
{
HASH_SEQ_STATUS iter;
DiskQuotaRelationCacheEntry *entry;

if (relation_cache == NULL)
{
return oidlist;
}

remove_committed_relation_from_cache();

LWLockAcquire(diskquota_locks.relation_cache_lock, LW_SHARED);
hash_seq_init(&iter, relation_cache);
while ((entry = hash_seq_search(&iter)) != NULL)
{
/* The session of db1 should not see the table inside db2. */
if (entry->primary_table_relid == entry->relid && entry->rnode.node.dbNode == MyDatabaseId)
{
oidlist = lappend_oid(oidlist, entry->relid);
}
}
LWLockRelease(diskquota_locks.relation_cache_lock);

return oidlist;
}

/*
* Incremental way to update the disk quota of every database objects
* Recalculate the table's disk usage when it's a new table or active table.
Expand Down Expand Up @@ -943,8 +915,6 @@ calculate_table_disk_usage(bool is_init)
*/
oidlist = get_rel_oid_list(is_init);

oidlist = merge_uncommitted_table_to_oidlist(oidlist);

foreach (l, oidlist)
{
HeapTuple classTup;
Expand Down

0 comments on commit 5e47ef3

Please sign in to comment.