-
Notifications
You must be signed in to change notification settings - Fork 916
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]: Out of Memory on DELETE Query in Hypertable #7776
Comments
Does the hypertable have compressed chunks? |
No. Compression is not enabled.
hypertable_name | num_dimensions | num_chunks | compression_enabled | is_distributed And no compressed chunks.
hypertable_name | chunk_name | is_compressed | primary_dimension | primary_dimension_type | range_start | range_end |
Would enabling compression on chunks have a positive impact on delete performance ? |
Hello @akuzm, since you worked on similar issues before, would you have any pointers ? |
What type of bug is this?
Crash, Performance issue
What subsystems and features are affected?
Query executor
What happened?
Query:
DELETE FROM nmon_cpu_all WHERE time >= '2024-12-14 04:08:02' AND time <= '2024-12-14 04:22:14' AND id_monitoring = 56983;
RAM: 24 GB
Number of chunks: 9337
Hypertable interval: 15 miutes
Continuous aggregate: No
Table creation:
Issue Description:
The execution time for the above DELETE queries has been increasing as the dataset grows, eventually leading to out-of-memory (OOM) failures systematically on any single such DELETE query. When the query is executed:
The TimescaleDB container rapidly consumes all available RAM and gets killed by the host VM's OOM killer.
Docker stats confirm rapid and total host memory consumption.
Running EXPLAIN on the query also causes OOM, making debugging difficult.
Notable Observations:
The column id_monitoring is not a foreign key, but it also lacks an index.
Removing the id_monitoring condition does not resolve the issue; the query still leads to OOM.
Upgrading to TimescaleDB 2.6.1 and 2.15.3 did NOT resolve the issue.
Investigations & Attempts to Resolve:
I have already tried solutions from these issues without success:
At one point, I dropped 9,000 chunks using drop_chunks() to make it possible to run EXPLAIN. The plan showed that only 2 chunks were being considered for the DELETE operation, as expected.
Dataset Characteristics:
The table stores monitoring data for load tests, which typically last 15 minutes per test—hence the hypertable’s chunk interval.
Data is pushed and queried only for test periods, meaning the dataset is discontinuous.
Largest Chunks:
The biggest chunks in nmon_cpu_all are around 1.2 MB in size:
SELECT * FROM chunks_detailed_size('nmon_cpu_all') order by total_bytes DESC limit 20;
chunk_schema/chunk_name/table_bytes/index_bytes/toast_bytes/total_bytes/node_name
_timescaledb_internal | _hyper_51_3980_chunk | 1097728 | 147456 | 0 | 1245184 |
_timescaledb_internal | _hyper_51_3969_chunk | 1073152 | 163840 | 0 | 1236992 |
_timescaledb_internal | _hyper_51_3986_chunk | 794624 | 122880 | 0 | 917504 |
_timescaledb_internal | _hyper_51_26857_chunk | 638976 | 106496 | 0 | 745472 |
_timescaledb_internal | _hyper_51_26881_chunk | 630784 | 114688 | 0 | 745472 |
_timescaledb_internal | _hyper_51_3993_chunk | 647168 | 90112 | 0 | 737280 |
_timescaledb_internal | _hyper_51_26851_chunk | 524288 | 106496 | 0 | 630784 |
_timescaledb_internal | _hyper_51_41492_chunk | 532480 | 90112 | 0 | 622592 |
_timescaledb_internal | _hyper_51_30909_chunk | 483328 | 90112 | 0 | 573440 |
_timescaledb_internal | _hyper_51_6719_chunk | 483328 | 90112 | 0 | 573440 |
_timescaledb_internal | _hyper_51_11819_chunk | 483328 | 90112 | 0 | 573440 |
_timescaledb_internal | _hyper_51_9636_chunk | 483328 | 90112 | 0 | 573440 |
_timescaledb_internal | _hyper_51_10863_chunk | 483328 | 90112 | 0 | 573440 |
_timescaledb_internal | _hyper_51_30921_chunk | 483328 | 90112 | 0 | 573440 |
_timescaledb_internal | _hyper_51_10515_chunk | 483328 | 90112 | 0 | 573440 |
_timescaledb_internal | _hyper_51_26698_chunk | 483328 | 90112 | 0 | 573440 |
_timescaledb_internal | _hyper_51_6641_chunk | 483328 | 90112 | 0 | 573440 |
_timescaledb_internal | _hyper_51_10527_chunk | 483328 | 90112 | 0 | 573440 |
_timescaledb_internal | _hyper_51_10539_chunk | 483328 | 90112 | 0 | 573440 |
_timescaledb_internal | _hyper_51_28178_chunk | 483328 | 90112 | 0 | 573440 |
Potential Next Steps & Open Questions:
One commenter in #4248 suggested upgrading to PostgreSQL 14. I haven't tried this yet, but I’d prefer to avoid a blind upgrade unless necessary.
Would adding an index on id_monitoring help, even though removing it from the query didn’t resolve OOM?
Could the number of chunks (9,337) be a factor in DELETE performance?
postgresql.conf.zip
TimescaleDB version affected
2.2.0, 2.6.1, 2.15.3
PostgreSQL version used
PostgreSQL 13.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, 64-bit
What operating system did you use?
RedHat 8.5.0
What installation method did you use?
Docker
What platform did you run on?
On prem/Self-hosted
Relevant log output and stack trace
How can we reproduce the bug?
The text was updated successfully, but these errors were encountered: