citusdata / citusdata/citus

(subquery_view.sql) With coordinator in metadata, some queries are not pushed down.

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

Description

Repro Steps:

citus_dev make test --size=2

```
CREATE TABLE reference_table (text_col text, int_col int);
SELECT create_reference_table('reference_table');

CREATE OR REPLACE VIEW view_on_views AS SELECT pg_stat_activity.application_name, pg_locks.pid FROM pg_stat_activity, pg_locks;

EXPLAIN (COSTS OFF) WITH cte AS (
SELECT application_name AS text_col
FROM view_on_views
) SELECT * FROM reference_table JOIN cte USING (text_col);

QUERY PLAN
----------------------------------------------------------------------------
Custom Scan (Citus Adaptive)
Task Count: 1
Tasks Shown: All
-> Task
Node: host=localhost port=9700 dbname=emel
-> Merge Join
Merge Cond: (reference_table.text_col = cte.text_col)
CTE cte
-> Nested Loop
-> Function Scan on pg_stat_get_activity s
-> Function Scan on pg_lock_status l
-> Sort
Sort Key: reference_table.text_col
-> Seq Scan on reference_table_102040 reference_table
-> Materialize
-> Sort
Sort Key: cte.text_col
-> CTE Scan on cte
(18 rows)
```

When the coordinator is removed from metadata, the queries are pushed down:

```
select master_remove_node('localhost', 9700);
master_remove_node
--------------------

(1 row)

EXPLAIN (COSTS OFF) WITH cte AS (
SELECT application_name AS text_col
FROM view_on_views
) SELECT * FROM reference_table JOIN cte USING (text_col);
QUERY PLAN
---------------------------------------------------------------------------------------
Custom Scan (Citus Adaptive)
-> Distributed Subplan 3_1
-> Nested Loop
-> Function Scan on pg_stat_get_activity s
-> Function Scan on pg_lock_status l
Task Count: 1
Tasks Shown: All
-> Task
Node: host=localhost port=9701 dbname=emel
-> Merge Join
Merge Cond: (intermediate_result.text_col = reference_table.text_col)
-> Sort
Sort Key: intermediate_result.text_col
-> Function Scan on read_intermediate_result intermediate_result
-> Sort
Sort Key: reference_table.text_col
-> Seq Scan on reference_table_102040 reference_table
(17 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.