mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 11:03:36 +08:00
Add number of compressed hypertables to stat
This change includes telemetry fixes which extends HypertablesStat with num_hypertables_compressed. It also updates the way how the number of regular hypertables is calculated, which is now treated as a non-compressed and not related to continuous aggregates.
This commit is contained in:
parent
d5f5d92790
commit
11ef10332e
@ -391,49 +391,20 @@ hypertable_scan_limit_internal(ScanKeyData *scankey, int num_scankeys, int index
|
||||
return ts_scanner_scan(&scanctx);
|
||||
}
|
||||
|
||||
/* Number of user-created hypertables (doesn't count internal hypertables for compression or
|
||||
* continuous aggs) */
|
||||
int
|
||||
ts_number_of_user_hypertables()
|
||||
/* Is a user hypertable without compression or continuous aggs */
|
||||
static bool
|
||||
hypertable_is_user_table(Hypertable *ht)
|
||||
{
|
||||
int count = 0;
|
||||
ScanIterator iterator =
|
||||
ts_scan_iterator_create(HYPERTABLE, AccessExclusiveLock, CurrentMemoryContext);
|
||||
ContinuousAggHypertableStatus status = ts_continuous_agg_hypertable_status(ht->fd.id);
|
||||
|
||||
ts_scanner_foreach(&iterator)
|
||||
{
|
||||
TupleInfo *ti = ts_scan_iterator_tuple_info(&iterator);
|
||||
Hypertable *ht = ts_hypertable_from_tupleinfo(ti);
|
||||
|
||||
if (!hypertable_is_compressed_or_materialization(ht))
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Number of hypertables with compression enabled */
|
||||
int
|
||||
ts_number_compressed_hypertables()
|
||||
{
|
||||
int count = 0;
|
||||
ScanIterator iterator =
|
||||
ts_scan_iterator_create(HYPERTABLE, AccessExclusiveLock, CurrentMemoryContext);
|
||||
|
||||
ts_scanner_foreach(&iterator)
|
||||
{
|
||||
TupleInfo *ti = ts_scan_iterator_tuple_info(&iterator);
|
||||
Hypertable *ht = ts_hypertable_from_tupleinfo(ti);
|
||||
|
||||
if (ht->fd.compressed_hypertable_id != INVALID_HYPERTABLE_ID)
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
return !ht->fd.compressed && status != HypertableIsMaterialization;
|
||||
}
|
||||
|
||||
static ScanTupleResult
|
||||
hypertable_tuple_add_stat(TupleInfo *ti, void *data)
|
||||
{
|
||||
HypertablesStat *stat = data;
|
||||
Hypertable *ht = ts_hypertable_from_tupleinfo(ti);
|
||||
bool isnull;
|
||||
Datum datum;
|
||||
|
||||
@ -453,6 +424,7 @@ hypertable_tuple_add_stat(TupleInfo *ti, void *data)
|
||||
break;
|
||||
default:
|
||||
Assert(replication_factor >= 1);
|
||||
Assert(!ht->fd.compressed);
|
||||
stat->num_hypertables_distributed++;
|
||||
if (replication_factor > 1)
|
||||
stat->num_hypertables_distributed_and_replicated++;
|
||||
@ -461,9 +433,16 @@ hypertable_tuple_add_stat(TupleInfo *ti, void *data)
|
||||
}
|
||||
else
|
||||
{
|
||||
stat->num_hypertables_regular++;
|
||||
/* Number of user-created hypertables (doesn't count internal hypertables
|
||||
* for compression or continuous aggs) */
|
||||
if (hypertable_is_user_table(ht))
|
||||
stat->num_hypertables_user++;
|
||||
}
|
||||
|
||||
/* Number of hypertables with compression enabled */
|
||||
if (TS_HYPERTABLE_HAS_COMPRESSION(ht))
|
||||
stat->num_hypertables_compressed++;
|
||||
|
||||
return SCAN_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -63,13 +63,10 @@ enum Anum_create_hypertable
|
||||
|
||||
#define Natts_create_hypertable (_Anum_create_hypertable_max - 1)
|
||||
|
||||
extern int ts_number_of_user_hypertables(void);
|
||||
|
||||
extern int ts_number_compressed_hypertables(void);
|
||||
|
||||
typedef struct HypertablesStat
|
||||
{
|
||||
int num_hypertables_regular;
|
||||
int num_hypertables_user;
|
||||
int num_hypertables_compressed;
|
||||
int num_hypertables_distributed_members;
|
||||
int num_hypertables_distributed;
|
||||
int num_hypertables_distributed_and_replicated;
|
||||
|
@ -185,24 +185,26 @@ get_size(int64 size)
|
||||
static char *
|
||||
get_num_hypertables()
|
||||
{
|
||||
// HypertablesStat stat;
|
||||
HypertablesStat stat;
|
||||
StringInfo buf = makeStringInfo();
|
||||
|
||||
// memset(&stat, 0, sizeof(stat));
|
||||
// ts_number_of_hypertables(&stat);
|
||||
//
|
||||
// appendStringInfo(buf, "%d", stat.num_hypertables_total);
|
||||
memset(&stat, 0, sizeof(stat));
|
||||
ts_number_of_hypertables(&stat);
|
||||
|
||||
appendStringInfo(buf, "%d", ts_number_of_user_hypertables());
|
||||
appendStringInfo(buf, "%d", stat.num_hypertables_user);
|
||||
return buf->data;
|
||||
}
|
||||
|
||||
static char *
|
||||
get_num_compressed_hypertables()
|
||||
{
|
||||
HypertablesStat stat;
|
||||
StringInfo buf = makeStringInfo();
|
||||
|
||||
appendStringInfo(buf, "%d", ts_number_compressed_hypertables());
|
||||
memset(&stat, 0, sizeof(stat));
|
||||
ts_number_of_hypertables(&stat);
|
||||
|
||||
appendStringInfo(buf, "%d", stat.num_hypertables_compressed);
|
||||
return buf->data;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user