citusdata / citusdata/citus

SELECT EXISTS is extremely inefficient

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

Description

This is meant to be an O(1) operation in Postgres, but it is an O(N) operation in Citus:
```sql
explain select exists (select 1 from test);
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ QUERY PLAN │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=0 width=0) │
│ -> Distributed Subplan 3_1 │
│ -> Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=100000 width=4) │
│ Task Count: 40 │
│ Tasks Shown: One of 40 │
│ -> Task │
│ Node: host=localhost port=1301 dbname=postgres │
│ -> Seq Scan on test_102008 test (cost=0.00..30.40 rows=2040 width=4) │
│ Task Count: 1 │
│ Tasks Shown: All │
│ -> Task │
│ Node: host=localhost port=1300 dbname=postgres │
│ -> Result (cost=0.01..0.02 rows=1 width=1) │
│ InitPlan 1 (returns $0) │
│ -> Function Scan on read_intermediate_result intermediate_result (cost=0.00..10.00 rows=1000 width=0) │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
(15 rows)
```

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.