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 timescale#5432

Co-authored-by: Ante Kresic <ante.kresic@gmail.com>
(cherry picked from commit 5633960)
  • Loading branch information
konskov committed Apr 19, 2023
1 parent efcfeca commit fbc4160
Show file tree
Hide file tree
Showing 4 changed files with 613 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -37,6 +37,7 @@ accidentally triggering the load of a previous DB version.**
* #5462 Fix segfault after column drop on compressed table
* #5543 Copy scheduled_jobs list before sorting it
* #5497 Allow named time_bucket arguments in Cagg definition
* #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 fbc4160

Please sign in to comment.