Skip to content

Commit

Permalink
Use non-orderby compressed metadata in compressed DML
Browse files Browse the repository at this point in the history
Currently the additional metadata derived from index columns are
only used for the qualifier pushdown in querying but not the
decompression during compressed DML. This patch makes use of this
metadata for compressed DML as well.
  • Loading branch information
svenklemm committed Apr 23, 2024
1 parent 0f1983e commit 45b5862
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions tsl/src/compression/compression.c
Original file line number Diff line number Diff line change
Expand Up @@ -2607,25 +2607,41 @@ fill_predicate_context(Chunk *ch, CompressionSettings *settings, List *predicate
false)); /* is_null */
}
}
continue;
}
else if (ts_array_is_member(settings->fd.orderby, column_name))

int min_attno = compressed_column_metadata_attno(settings,
ch->table_id,
var->varattno,
settings->fd.relid,
"min");
int max_attno = compressed_column_metadata_attno(settings,
ch->table_id,
var->varattno,
settings->fd.relid,
"max");

if (min_attno != InvalidAttrNumber && max_attno != InvalidAttrNumber)
{
int16 index = ts_array_position(settings->fd.orderby, column_name);
switch (op_strategy)
{
case BTEqualStrategyNumber:
{
/* orderby col = value implies min <= value and max >= value */
*heap_filters = lappend(*heap_filters,
make_batchfilter(column_segment_min_name(index),
make_batchfilter(get_attname(settings->fd.relid,
min_attno,
false),
BTLessEqualStrategyNumber,
collation,
opcode,
arg_value,
false, /* is_null_check */
false)); /* is_null */
*heap_filters = lappend(*heap_filters,
make_batchfilter(column_segment_max_name(index),
make_batchfilter(get_attname(settings->fd.relid,
max_attno,
false),
BTGreaterEqualStrategyNumber,
collation,
opcode,
Expand All @@ -2639,7 +2655,9 @@ fill_predicate_context(Chunk *ch, CompressionSettings *settings, List *predicate
{
/* orderby col <[=] value implies min <[=] value */
*heap_filters = lappend(*heap_filters,
make_batchfilter(column_segment_min_name(index),
make_batchfilter(get_attname(settings->fd.relid,
min_attno,
false),
op_strategy,
collation,
opcode,
Expand All @@ -2653,7 +2671,9 @@ fill_predicate_context(Chunk *ch, CompressionSettings *settings, List *predicate
{
/* orderby col >[=] value implies max >[=] value */
*heap_filters = lappend(*heap_filters,
make_batchfilter(column_segment_max_name(index),
make_batchfilter(get_attname(settings->fd.relid,
max_attno,
false),
op_strategy,
collation,
opcode,
Expand Down

0 comments on commit 45b5862

Please sign in to comment.