Skip to content

Commit

Permalink
Enable indexscan on uncompressed part of partially compressed chunks
Browse files Browse the repository at this point in the history
This was previously disabled as no data resided on the
uncompressed chunk once it was compressed, but this is not
the case anymore with partially compressed chunks, so we
enable indexscan for the uncompressed chunk again.

Fixes #5432

Co-authored-by: Ante Kresic <ante.kresic@gmail.com>
(cherry picked from commit 5633960)
  • Loading branch information
konskov authored and akuzm committed Apr 19, 2023
1 parent e03aa0b commit e46d44e
Show file tree
Hide file tree
Showing 4 changed files with 624 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -39,6 +39,9 @@ accidentally triggering the load of a previous DB version.**
* #5497 Allow named time_bucket arguments in Cagg definition
* #5570 Improve interpolate error message on datatype mismatch
* #5558 Use regrole for job owner
* #5544 Fix refresh from beginning of Continuous Aggregate with variable time bucket

* #5542 Enable indexscan on uncompressed part of partially compressed chunks

**Thanks**
* @nikolaps for reporting an issue with the COPY fetcher
Expand Down
9 changes: 6 additions & 3 deletions src/planner/planner.c
Expand Up @@ -1302,13 +1302,16 @@ timescaledb_get_relation_info_hook(PlannerInfo *root, Oid relation_objectid, boo

ts_get_private_reloptinfo(rel)->compressed = true;

/* Planning indexes are expensive, and if this is a compressed chunk, we
/* Planning indexes is expensive, and if this is a fully compressed chunk, we
* know we'll never need to use indexes on the uncompressed version, since
* all the data is in the compressed chunk anyway. Therefore, it is much
* faster if we simply trash the indexlist here and never plan any useless
* IndexPaths at all
* IndexPaths at all.
* If the chunk is partially compressed, then we should enable indexScan
* on the uncompressed part.
*/
rel->indexlist = NIL;
if (!ts_chunk_is_partial(chunk))
rel->indexlist = NIL;

/* Relation size estimates are messed up on compressed chunks due to there
* being no actual pages for the table in the storage manager.
Expand Down

0 comments on commit e46d44e

Please sign in to comment.