citusdata / citusdata/citus

Incorrect classification of deferred pruning

Open
#3,580 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C
Stars
12.8k
Forks
794
Avg merge
2d 14h
Merged PRs (30d)
31

Description

This is a minor bug, that doesn't seem to lead any issues. Could only be confusing for some users/devs.

```SQL
CREATE TABLE test_table (key int, value int);
SELECT create_distributed_table('test_table', 'key');

PREPARE parameter_on_value(int) AS SELECT count(*) FROM test_table WHERE value = $1 AND key = 1;
SET client_min_messages TO DEBUG;
EXECUTE parameter_on_value(1);

DEBUG: Deferred pruning for a fast-path router query
DEBUG: Creating router plan
DEBUG: Plan is router executable
┌───────┐
│ count │
├───────┤
│ 0 │
└───────┘
(1 row)

Time: 3.133 ms
```

But, that's a very specific case, depending on the order of the filters in the query. For example, this time the query is not deferred pruning since key filter comes before value

```SQL
PREPARE parameter_on_value(int) AS SELECT count(*) FROM test_table WHERE key = 1 AND value = $1;
EXECUTE parameter_on_value(1);
DEBUG: Distributed planning for a fast-path router query
DEBUG: Creating router plan
DEBUG: Plan is router executable
DETAIL: distribution column value: 1
┌───────┐
│ count │
├───────┤
│ 0 │
└───────┘
(1 row)

Time: 1.242 ms
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.