-
Notifications
You must be signed in to change notification settings - Fork 882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: hypertable_size is really expensive for large hypertables #6006
Comments
@mkindahl not sure if we'll have a big gain rewriting it in C since the real problem is the underlying Other idea is implement a variation of this function to do an approximate calculation of the relations using the 452071 (leader) fabrizio=# SELECT hypertable_name, hypertable_size(format('%I', hypertable_name)::regclass)
FROM timescaledb_information.hypertables;
hypertable_name | hypertable_size
-----------------+-----------------
conditions | 1004732416
(1 row)
Time: 857,838 ms
452071 (leader) fabrizio=# ALTER FUNCTION _timescaledb_functions.relation_size(REGCLASS) STABLE PARALLEL SAFE ROWS 1;
ALTER FUNCTION hypertable_size(REGCLASS) STABLE PARALLEL SAFE;
ALTER FUNCTION hypertable_detailed_size(REGCLASS) STABLE PARALLEL SAFE ROWS 1;
ALTER FUNCTION _timescaledb_functions.hypertable_local_size(name, name) STABLE PARALLEL SAFE ROWS 1;
ALTER FUNCTION
Time: 48,748 ms
ALTER FUNCTION
Time: 28,435 ms
ALTER FUNCTION
Time: 27,730 ms
ALTER FUNCTION
Time: 27,852 ms
452071 (leader) fabrizio=# SELECT hypertable_name, hypertable_size(format('%I', hypertable_name)::regclass)
FROM timescaledb_information.hypertables;
hypertable_name | hypertable_size
-----------------+-----------------
conditions | 1004732416
(1 row)
Time: 584,942 ms This small changes decreased the total time from 857,838 ms to 584,942 ms ~32% performance improvement. |
PR for this #6463 |
What type of bug is this?
Performance issue
What subsystems and features are affected?
Command processing
What happened?
When running
hypertable_size
on really large tables it can become excessively expensive. In particular for tables with a large number of chunks. In particular, when chunk sizes do not change for anything but the most recent chunks.TimescaleDB version affected
2.12.0
PostgreSQL version used
15.3
What operating system did you use?
Ubuntu 22.04 x64
What installation method did you use?
Source
What platform did you run on?
On prem/Self-hosted
Relevant log output and stack trace
No response
How can we reproduce the bug?
Tasks
The text was updated successfully, but these errors were encountered: