citusdata / citus

Distributed PostgreSQL as an extension
https://www.citusdata.com
GNU Affero General Public License v3.0
10.63k stars 670 forks source link

An incorrect query result, where the distributed query plan seems wrong #7698

Open duerwuyi opened 1 month ago

duerwuyi commented 1 month ago
DROP TABLE IF EXISTS t1;
create table t1 ( 
vkey int4 ,
c10 int4 
);
DROP TABLE IF EXISTS t3;
create table t3 ( 
vkey int4 
);

insert into t3 (vkey) values (1);
insert into t1 (vkey,c10) values (4, -70);

I made t1 as a distributed table: SELECT create_distributed_table('t1', 'vkey');

query:

select  t3.vkey
from  (t1  right outer join t3 
    on (t1.c10 = t3.vkey ))
where exists (select  *   from   t3);

The result should be t3.vkey = 1 ,but actually returns nothing. The citus version is 12.5.

duerwuyi commented 1 month ago

the distributed query plan of this query: Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=100000 width=4) -> Distributed Subplan 1_1 -> Seq Scan on t3 (cost=0.00..35.50 rows=2550 width=4) -> Distributed Subplan 1_2 -> Seq Scan on t3 (cost=0.00..35.50 rows=2550 width=4) Task Count: 0 Tasks Shown: All

task count should not be 0.