Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
RekGRpth committed Oct 18, 2024
1 parent 982f422 commit e14a616
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/gp_activetable.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ gp_fetch_active_tables(bool is_init)
{
HTAB *local_table_stats_map = NULL;
HASHCTL ctl;
char *active_oid_list;
char *sql_command;

Assert(Gp_role == GP_ROLE_DISPATCH);

Expand All @@ -385,22 +385,13 @@ gp_fetch_active_tables(bool is_init)
else
{
/* step 1: fetch active oids from all the segments */
active_oid_list = pull_active_list_from_seg();

ereport(DEBUG1,
(errcode(ERRCODE_INTERNAL_ERROR), errmsg("[diskquota] active_old_list = %s", active_oid_list)));
sql_command = pull_active_list_from_seg();

/* step 2: fetch active table sizes based on active oids */

StringInfoData sql_command;
initStringInfo(&sql_command);
appendStringInfo(&sql_command, "with s as (select (diskquota.diskquota_fetch_table_stat(1, '%s'::oid[])).* from gp_dist_random('gp_id')) select \"TABLE_OID\", array_agg(\"TABLE_SIZE\" order by \"GP_SEGMENT_ID\") \"TABLE_SIZE\" from s group by 1 order by 1",
active_oid_list);

load_table_size(local_table_stats_map, sql_command.data, is_init);
load_table_size(local_table_stats_map, sql_command, is_init);

pfree(active_oid_list);
pfree(sql_command.data);
pfree(sql_command);
}
return local_table_stats_map;
}
Expand Down Expand Up @@ -1056,7 +1047,7 @@ pull_active_list_from_seg(void)
uint32 count = 0;

initStringInfo(&buffer);
appendStringInfo(&buffer, "{");
appendStringInfo(&buffer, "with s as (select (diskquota.diskquota_fetch_table_stat(1, '{");

/* first get all oid of tables which are active table on any segment */
sql = "select * from diskquota.diskquota_fetch_table_stat(0, '{}'::oid[])";
Expand Down Expand Up @@ -1084,7 +1075,7 @@ pull_active_list_from_seg(void)
}
cdbdisp_clearCdbPgResults(&cdb_pgresults);

appendStringInfo(&buffer, "}");
appendStringInfo(&buffer, "}'::oid[])).* from gp_dist_random('gp_id')) select \"TABLE_OID\", array_agg(\"TABLE_SIZE\" order by \"GP_SEGMENT_ID\") \"TABLE_SIZE\" from s group by 1 order by 1");

return buffer.data;
}

0 comments on commit e14a616

Please sign in to comment.