-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathts_stats.sql
More file actions
71 lines (69 loc) · 3.27 KB
/
Copy pathts_stats.sql
File metadata and controls
71 lines (69 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
-- This file and its contents are licensed under the Apache License 2.0.
-- Please see the included NOTICE for copyright information and
-- LICENSE-APACHE for a copy of the license.
-- Chunk statistics. This function takes three optional parameters:
-- - compressed_relid: if provided, returns stats for the specified compressed chunk only; otherwise, returns stats for all chunks.
-- - uncompressed_relid: if provided, returns stats for the specified user chunk only; if compressed_relid is also provided, both must agree.
-- - since: if provided, returns stats for operations that occurred since the specified timestamp; otherwise, returns all stats.
--
CREATE OR REPLACE FUNCTION _timescaledb_functions.chunk_statistics(
compressed_relid regclass DEFAULT NULL,
uncompressed_relid regclass DEFAULT NULL,
since timestamptz DEFAULT NULL
)
RETURNS TABLE (
compressed_relid oid,
uncompressed_relid oid,
-- Compression
compressed_batch_count bigint,
compressed_block_count bigint,
compressed_batch_rows_min bigint,
compressed_batch_rows_max bigint,
compressed_batch_rows_sum bigint,
compressed_batch_rows_sqsum double precision,
compressed_batch_bytes_min bigint,
compressed_batch_bytes_max bigint,
compressed_batch_bytes_sum bigint,
compressed_batch_bytes_sqsum double precision,
compressed_block_bytes_min bigint,
compressed_block_bytes_max bigint,
compressed_block_bytes_sum bigint,
compressed_block_bytes_sqsum double precision,
-- DML totals (cumulative, from cmd_totals)
total_batches_deleted bigint,
total_batches_decompressed bigint,
total_tuples_decompressed bigint,
total_batches_scanned bigint,
total_batches_checked_by_bloom bigint,
total_batches_pruned_by_bloom bigint,
total_batches_without_bloom bigint,
total_batches_bloom_false_positives bigint,
total_batches_filtered_compressed bigint,
total_batches_filtered_decompressed bigint,
-- DML last operation snapshot (from cmd_last_op)
last_op_batches_deleted bigint,
last_op_batches_decompressed bigint,
last_op_tuples_decompressed bigint,
last_op_batches_scanned bigint,
last_op_batches_checked_by_bloom bigint,
last_op_batches_pruned_by_bloom bigint,
last_op_batches_without_bloom bigint,
last_op_batches_bloom_false_positives bigint,
last_op_batches_filtered_compressed bigint,
last_op_batches_filtered_decompressed bigint,
-- Operation counts
n_selects bigint,
n_inserts bigint,
n_updates bigint,
n_deletes bigint,
-- Timestamps
first_update timestamptz,
last_update timestamptz
)
AS '@MODULE_PATHNAME@', 'ts_stats_chunks'
LANGUAGE C STABLE;
-- Logical reset: clears all cached chunks under the segment lock.
CREATE OR REPLACE FUNCTION _timescaledb_functions.chunk_statistics_reset()
RETURNS VOID
AS '@MODULE_PATHNAME@', 'ts_stats_reset'
LANGUAGE C VOLATILE;