13 Commits

Author SHA1 Message Date
Sven Klemm
43bb5ba7d1 Optimize approximate_row_count
Rewrite approximate_row_count to SQL instead of PLpgSQL and remove
superfluous JOINs against pg_namespace. Adjust tuple calculation
for PG14 since in PG14 reltuples for partitioned tables is the sum
of it's children so we need to exclude those from calculation to
not doublecount.
2021-09-16 14:57:47 +02:00
Erik Nordström
931da9a656 Refactor and harden size and stats functions
Fix a number of issues with size and stats functions:

* Return `0` size instead of `NULL` in several functions when
  hypertables have no chunks (e.g., `hypertable_size`,
  `hypertable_detailed_size`).
* Return `NULL` when functions are called on non-hypertables instead
  of simply failing with generic error `query returned no rows`.
* Include size of "root" hypertable, which can have non-zero size
  indexes and other objects even if the root table holds no data.
* Make `hypertable_detailed_size` include one additional row for
  storage size of objects on the access node. While the access node
  stores no data, the empty hypertable may still take up some disk
  space.
* Improve test coverage for all size utility functions. In particular,
  add tests on regular tables as well as empty and compressed
  hypertables.
* Several size utility functions that were defined as `PL/pgSQL`
  functions have been converted to simple `SQL` functions since they
  ran only a single SQL query.

The `dist_util` test is moved to the solo test group because,
otherwise, it gives different size output when run in parallel vs. in
isolation.

Fixes #2871
2021-03-23 16:23:56 +01:00
Dmitry Simonenko
e10b437712 Make hypertable_approximate_row_count return row count only
This change renames function to approximate_row_count() and adds
support for regular tables. Return a row count estimate for a
table instead of a table list.
2020-09-02 12:18:34 +03:00
gayyappan
eecc93f3b6 Add hypertable_index_size function
Function to compute the size for a specific
index of a hypertable
2020-08-10 18:00:51 -04:00
gayyappan
c93f963709 Remove chunk_relation_size
Remove chunk_relation_size and chunk_relation_size_pretty
functions
Fix row_number in chunks view
2020-07-30 16:06:04 -04:00
gayyappan
7d3b4b5442 New size utils functions
Add hypertable_detailed_size , chunk_detailed_size,
hypertable_size functions.
Remove hypertable_relation_size,
hypertable_relation_size_pretty, and indexes_relation_size_pretty
Remove size information from hypertables view.
2020-07-29 15:30:39 -04:00
Sven Klemm
f89fd07c5b Remove year from SQL file license text
This changes the license text for SQL files to be identical
with the license text for C files.
2019-01-13 23:30:22 +01:00
Sven Klemm
46d3479757 Add tests for calling functions with NULL arguments 2018-11-23 20:54:27 +01:00
Joshua Lockerman
20ec6914c0 Add license headers to SQL files and test code 2018-10-29 13:28:19 -04:00
Rob Kiefer
41af6ff3ae Fix misreported toast_size in chunk_relation_size funcs
A bug in the SQL for getting the size of chunks would use the
TOAST size of the main/dummy table as the toast size for the
chunks rather than each chunks' own toast size.
2018-07-11 11:54:33 -04:00
Rob Kiefer
c660fcd8ff Add hypertable_approximate_row_count convenience function
Getting an approximate row count for a hypertable involves getting
estimates for all of its chunks rather than just looking up a
single value in the catalog tables. This PR provides a convenience
function for doing the JOINs/summing.
2018-05-18 10:21:43 -04:00
Olof Rensfelt
8cf8d3c377 Improve the size utils functions.
The hypertable, chunk, and index size functions are
now split into main function and a corresponding ´pretty´
function. In chunk_relation_size_pretty() the ranges are
now converted into a human readable form when they are time types.
2017-09-16 09:53:08 +02:00
Olof Rensfelt
e0eeeb9bdb Add hypertable, chunk, and indexes size utils functions. 2017-07-13 14:14:40 +02:00