【发布时间】:2021-01-16 10:17:26
【问题描述】:
这真是令人费解。我需要从 timescaleDB 1.7 的超表中删除日期:
DELETE FROM raw WHERE tm::date = '2020-11-06' -- the local date style is YYYY-MM-DD
在此之前,我检查了我需要解压哪些块,给它一天的保证金,并收到两个块:
SELECT show_chunks('raw', newer_than => '2020-11-05 00:00'::timestamp)
---
Result:
"_timescaledb_internal._hyper_1_19_chunk"
"_timescaledb_internal._hyper_1_21_chunk"
所以我解压这两个。但是,当我运行上面的 DELETE 命令时,我仍然收到关于完全不同块的错误:
ERROR: cannot update/delete rows from chunk "_hyper_1_1_chunk" as it
is compressed SQL state: XX000
顺便说一句,就我在 pgAdmin 中查看它所看到的而言,这个块是空的。知道发生了什么吗?对我来说似乎是一个错误,但也许我做错了什么?
谢谢!
编辑: 以下是@k_rus 要求的 EXPLAIN DELETE 结果的摘录:
EXPLAIN DELETE FROM raw WHERE tm::date = '2020-11-06'
Result:
"Delete on raw (cost=0.00..719.63 rows=147 width=6)"
" Delete on raw"
" Delete on _hyper_1_1_chunk"
" Delete on _hyper_1_2_chunk"
...
" Delete on _hyper_1_22_chunk"
" -> Seq Scan on raw (cost=0.00..0.00 rows=1 width=6)"
" Filter: ((tm)::date = '2020-11-06'::date)"
" -> Custom Scan (CompressChunkDml) on _hyper_1_1_chunk (cost=0.00..27.40 rows=6 width=6)"
" -> Seq Scan on _hyper_1_1_chunk (cost=0.00..27.40 rows=6 width=6)"
" Filter: ((tm)::date = '2020-11-06'::date)"
" -> Custom Scan (CompressChunkDml) on _hyper_1_2_chunk (cost=0.00..27.40 rows=6 width=6)"
" -> Seq Scan on _hyper_1_2_chunk (cost=0.00..27.40 rows=6 width=6)"
" Filter: ((tm)::date = '2020-11-06'::date)"
...
" -> Custom Scan (CompressChunkDml) on _hyper_1_22_chunk (cost=0.00..27.40 rows=6 width=6)"
" -> Seq Scan on _hyper_1_22_chunk (cost=0.00..27.40 rows=6 width=6)"
" Filter: ((tm)::date = '2020-11-06'::date)"
【问题讨论】:
-
你能在你的 DELETE 语句上运行 EXPLAIN 并显示结果吗?
-
嗨@k_rus,这里是:docs.google.com/document/d/…
-
您能否将解释发布到您的问题中,因为回答它很重要?您可以省略重复的部分,只显示计划中的几个部分。