Skip to content

Instantly share code, notes, and snippets.

@onderkalaci
Created January 26, 2017 15:58
Show Gist options
  • Save onderkalaci/47aea936356f69e5ad20280dff3584f5 to your computer and use it in GitHub Desktop.
Save onderkalaci/47aea936356f69e5ad20280dff3584f5 to your computer and use it in GitHub Desktop.
Subquery pushdown investigation
CREATE TABLE table_1 (key int, value int);
CREATE TABLE table_2 (key int, value int);
CREATE TABLE table_3 (key int, value int);
SET citus.shard_count TO 4;
SET citus.shard_replication_factor TO 1;
SELECT create_distributed_table ('table_1', 'key');
SELECT create_distributed_table ('table_2', 'key');
SELECT create_distributed_table ('table_3', 'key');
-- this should have errored out since it is not logically correct to push down
-- however our current logic allows the following to run and return wrong results
INSERT INTO table_1 (key)
SELECT table_2.key FROM table_2 INNER JOIN table_3 ON (table_2.key = table_3.value);
-- same for LEFT JOIN
INSERT INTO table_1 (key)
SELECT table_2.key FROM table_2 LEFT JOIN table_3 ON (table_2.key = table_3.value);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment