Skip to content

Commit

Permalink
Index scan support during UPDATE/DELETE.
Browse files Browse the repository at this point in the history
During UPDATE/DELETE on compressed hypertables, we do a sequential
scan which can be improved by supporting index scans.

In this patch for a given UPDATE/DELETE query, if there are any
WHERE conditions specified using SEGMENT BY columns, we use index
scan to fetch all matching rows. Fetched rows will be decompressed
and moved to uncompressed chunk and a regular UPDATE/DELETE is
performed on the uncompressed chunk.
  • Loading branch information
sb230132 committed Apr 20, 2023
1 parent a49fdbc commit 698d223
Show file tree
Hide file tree
Showing 7 changed files with 326 additions and 134 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# TimescaleDB Changelog

**Please note: When updating your database, you should connect using
Expand All @@ -18,6 +19,7 @@ accidentally triggering the load of a previous DB version.**
* #5547 Skip Ordered Append when only 1 child node is present
* #5510 Propagate vacuum/analyze to compressed chunks
* #5584 Reduce decompression during constraint checking
* #5586 Index scan support during UPDATE/DELETE

**Bugfixes**
* #5396 Fix SEGMENTBY columns predicates to be pushed down
Expand Down
2 changes: 1 addition & 1 deletion src/cross_module_fn.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ typedef struct CrossModuleFunctions
PGFunction decompress_chunk;
void (*decompress_batches_for_insert)(ChunkInsertState *state, Chunk *chunk,
TupleTableSlot *slot);
void (*decompress_batches_for_update_delete)(List *chunks, List *predicates);
void (*decompress_batches_for_update_delete)(List *chunks, List *predicates, EState *estate);
/* The compression functions below are not installed in SQL as part of create extension;
* They are installed and tested during testing scripts. They are exposed in cross-module
* functions because they may be very useful for debugging customer problems if the sql
Expand Down
4 changes: 3 additions & 1 deletion src/nodes/hypertable_modify.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,9 @@ ExecModifyTable(CustomScanState *cs_node, PlanState *pstate)
collect_chunks_from_scan(pstate, sn);
if (sn->chunks && ts_cm_functions->decompress_batches_for_update_delete)
{
ts_cm_functions->decompress_batches_for_update_delete(sn->chunks, sn->predicates);
ts_cm_functions->decompress_batches_for_update_delete(sn->chunks,
sn->predicates,
estate);
ht_state->comp_chunks_processed = true;
/*
* save snapshot set during ExecutorStart(), since this is the same
Expand Down
Loading

0 comments on commit 698d223

Please sign in to comment.