mirror of https://github.com/citusdata/citus.git
Strip trailing whitespace and add final newline (#3186)
This brings files in line with our editorconfig filepull/3207/head
parent
1d8dde232f
commit
c563e0825c
|
@ -22,6 +22,12 @@ jobs:
|
||||||
- run:
|
- run:
|
||||||
name: 'Check Style'
|
name: 'Check Style'
|
||||||
command: citus_indent --check
|
command: citus_indent --check
|
||||||
|
- run:
|
||||||
|
name: 'Fix whitespace'
|
||||||
|
command: ci/editorconfig.sh
|
||||||
|
- run:
|
||||||
|
name: 'Check if whitespace fixing changed anything, install editorconfig if it did'
|
||||||
|
command: git diff --exit-code
|
||||||
- run:
|
- run:
|
||||||
name: 'Remove useless declarations'
|
name: 'Remove useless declarations'
|
||||||
command: ci/remove_useless_declarations.sh
|
command: ci/remove_useless_declarations.sh
|
||||||
|
|
|
@ -12,12 +12,18 @@ insert_final_newline = true
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
# Don't change test output files
|
# Don't change test output files, pngs or test data files
|
||||||
[*.out]
|
[*.{out,png,data}]
|
||||||
insert_final_newline = unset
|
insert_final_newline = unset
|
||||||
trim_trailing_whitespace = unset
|
trim_trailing_whitespace = unset
|
||||||
|
|
||||||
[*.sql]
|
# Don't change test/regress/output directory, this needs to be a separate rule
|
||||||
|
# for some reason
|
||||||
|
[/src/test/regress/output/**]
|
||||||
|
insert_final_newline = unset
|
||||||
|
trim_trailing_whitespace = unset
|
||||||
|
|
||||||
|
[*.sql,*.sh]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
tab_width = 4
|
tab_width = 4
|
||||||
|
|
2
LICENSE
2
LICENSE
|
@ -658,4 +658,4 @@ specific requirements.
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
<http://www.gnu.org/licenses/>.
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
for f in $(git ls-tree -r HEAD --name-only); do
|
||||||
|
if [ "$f" = "${f%.out}" ] &&
|
||||||
|
[ "$f" = "${f%.data}" ] &&
|
||||||
|
[ "$f" = "${f%.png}" ] &&
|
||||||
|
[ "$(dirname "$f")" != "src/test/regress/output" ]
|
||||||
|
then
|
||||||
|
# Trim trailing whitespace
|
||||||
|
sed -e 's/[[:space:]]*$//' -i "./$f"
|
||||||
|
# Add final newline if not there
|
||||||
|
if [ -n "$(tail -c1 "$f")" ]; then
|
||||||
|
echo >> "$f"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
|
@ -6,7 +6,7 @@ If the input query is trivial (e.g., no joins, no subqueries/ctes, single table
|
||||||
|
|
||||||
Distributed planning (`CreateDistributedPlan`) tries several different methods to plan the query:
|
Distributed planning (`CreateDistributedPlan`) tries several different methods to plan the query:
|
||||||
|
|
||||||
|
|
||||||
1. Fast-path router planner, proceed if the query prunes down to a single shard of a single table
|
1. Fast-path router planner, proceed if the query prunes down to a single shard of a single table
|
||||||
2. Router planner, proceed if the query prunes down to a single set of co-located shards
|
2. Router planner, proceed if the query prunes down to a single set of co-located shards
|
||||||
3. Modification planning, proceed if the query is a DML command and all joins are co-located
|
3. Modification planning, proceed if the query is a DML command and all joins are co-located
|
||||||
|
@ -15,7 +15,7 @@ Distributed planning (`CreateDistributedPlan`) tries several different methods t
|
||||||
|
|
||||||
## Fast-path router planner
|
## Fast-path router planner
|
||||||
|
|
||||||
By examining the query tree, if we can decide that the query hits only a single shard of a single table, we can skip calling `standard_planner()`. Later on the execution, we simply fetch the filter on the distribution key and do the pruning.
|
By examining the query tree, if we can decide that the query hits only a single shard of a single table, we can skip calling `standard_planner()`. Later on the execution, we simply fetch the filter on the distribution key and do the pruning.
|
||||||
|
|
||||||
As the name reveals, this can be considered as a sub-item of Router planner described below. The only difference is that fast-path planner doesn't rely on `standard_planner()` for collecting restriction information.
|
As the name reveals, this can be considered as a sub-item of Router planner described below. The only difference is that fast-path planner doesn't rely on `standard_planner()` for collecting restriction information.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
-- citus--7.0-1--7.0-2.sql
|
-- citus--7.0-1--7.0-2.sql
|
||||||
|
|
||||||
-- redefine shard_name as STRICT
|
-- redefine shard_name as STRICT
|
||||||
CREATE OR REPLACE FUNCTION pg_catalog.shard_name(object_name regclass, shard_id bigint)
|
CREATE OR REPLACE FUNCTION pg_catalog.shard_name(object_name regclass, shard_id bigint)
|
||||||
RETURNS text
|
RETURNS text
|
||||||
LANGUAGE C STABLE STRICT
|
LANGUAGE C STABLE STRICT
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus-7.0-10--7.0-11
|
-- citus-7.0-10--7.0-11
|
||||||
|
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ DECLARE
|
||||||
colocated_tables regclass[];
|
colocated_tables regclass[];
|
||||||
BEGIN
|
BEGIN
|
||||||
SELECT get_colocated_table_array(relation) INTO colocated_tables;
|
SELECT get_colocated_table_array(relation) INTO colocated_tables;
|
||||||
|
|
||||||
PERFORM
|
PERFORM
|
||||||
master_update_shard_statistics(shardid)
|
master_update_shard_statistics(shardid)
|
||||||
FROM
|
FROM
|
||||||
pg_dist_shard
|
pg_dist_shard
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -19,7 +19,7 @@ END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
COMMENT ON FUNCTION master_update_table_statistics(regclass)
|
COMMENT ON FUNCTION master_update_table_statistics(regclass)
|
||||||
IS 'updates shard statistics of the given table and its colocated tables';
|
IS 'updates shard statistics of the given table and its colocated tables';
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION get_colocated_shard_array(bigint)
|
CREATE OR REPLACE FUNCTION get_colocated_shard_array(bigint)
|
||||||
RETURNS BIGINT[]
|
RETURNS BIGINT[]
|
||||||
LANGUAGE C STRICT
|
LANGUAGE C STRICT
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.0-11--7.0-12.sql
|
-- citus--7.0-11--7.0-12.sql
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION pg_catalog.citus_create_restore_point(text)
|
CREATE OR REPLACE FUNCTION pg_catalog.citus_create_restore_point(text)
|
||||||
RETURNS pg_lsn
|
RETURNS pg_lsn
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.0-12--7.0-13.sql
|
-- citus--7.0-12--7.0-13.sql
|
||||||
|
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ BEGIN
|
||||||
SELECT array_agg(object_identity) INTO sequence_names
|
SELECT array_agg(object_identity) INTO sequence_names
|
||||||
FROM pg_event_trigger_dropped_objects()
|
FROM pg_event_trigger_dropped_objects()
|
||||||
WHERE object_type = 'sequence';
|
WHERE object_type = 'sequence';
|
||||||
|
|
||||||
FOR v_obj IN SELECT * FROM pg_event_trigger_dropped_objects() JOIN
|
FOR v_obj IN SELECT * FROM pg_event_trigger_dropped_objects() JOIN
|
||||||
pg_dist_partition ON (logicalrelid = objid)
|
pg_dist_partition ON (logicalrelid = objid)
|
||||||
WHERE object_type IN ('table', 'foreign table')
|
WHERE object_type IN ('table', 'foreign table')
|
||||||
|
@ -28,20 +28,20 @@ BEGIN
|
||||||
|
|
||||||
-- ensure all shards are dropped
|
-- ensure all shards are dropped
|
||||||
PERFORM master_drop_all_shards(v_obj.objid, v_obj.schema_name, v_obj.object_name);
|
PERFORM master_drop_all_shards(v_obj.objid, v_obj.schema_name, v_obj.object_name);
|
||||||
|
|
||||||
PERFORM master_drop_distributed_table_metadata(v_obj.objid, v_obj.schema_name, v_obj.object_name);
|
PERFORM master_drop_distributed_table_metadata(v_obj.objid, v_obj.schema_name, v_obj.object_name);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
||||||
IF cardinality(sequence_names) = 0 THEN
|
IF cardinality(sequence_names) = 0 THEN
|
||||||
RETURN;
|
RETURN;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
PERFORM master_drop_sequences(sequence_names);
|
PERFORM master_drop_sequences(sequence_names);
|
||||||
END;
|
END;
|
||||||
$cdbdt$;
|
$cdbdt$;
|
||||||
|
|
||||||
COMMENT ON FUNCTION citus_drop_trigger()
|
COMMENT ON FUNCTION citus_drop_trigger()
|
||||||
IS 'perform checks and actions at the end of DROP actions';
|
IS 'perform checks and actions at the end of DROP actions';
|
||||||
|
|
||||||
RESET search_path;
|
RESET search_path;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.0-13--7.0-14.sql
|
-- citus--7.0-13--7.0-14.sql
|
||||||
|
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.0-14--7.0-15
|
-- citus--7.0-14--7.0-15
|
||||||
|
|
||||||
DROP FUNCTION pg_catalog.dump_local_wait_edges(int4);
|
DROP FUNCTION pg_catalog.dump_local_wait_edges(int4);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.0-15--7.1-1
|
-- citus--7.0-15--7.1-1
|
||||||
|
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.0-2--7.0-3.sql
|
-- citus--7.0-2--7.0-3.sql
|
||||||
|
|
||||||
ALTER SEQUENCE pg_catalog.pg_dist_shard_placement_placementid_seq
|
ALTER SEQUENCE pg_catalog.pg_dist_shard_placement_placementid_seq
|
||||||
RENAME TO pg_dist_placement_placementid_seq;
|
RENAME TO pg_dist_placement_placementid_seq;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.0-3--7.0-4.sql
|
-- citus--7.0-3--7.0-4.sql
|
||||||
|
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.0-4--7.0-5.sql
|
-- citus--7.0-4--7.0-5.sql
|
||||||
|
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.0-5--7.0-6
|
-- citus--7.0-5--7.0-6
|
||||||
|
|
||||||
CREATE FUNCTION pg_catalog.dump_local_wait_edges(
|
CREATE FUNCTION pg_catalog.dump_local_wait_edges(
|
||||||
IN source_node_id int4,
|
IN source_node_id int4,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.0-6--7.0-7
|
-- citus--7.0-6--7.0-7
|
||||||
|
|
||||||
CREATE FUNCTION citus.replace_isolation_tester_func()
|
CREATE FUNCTION citus.replace_isolation_tester_func()
|
||||||
RETURNS void AS $$
|
RETURNS void AS $$
|
||||||
|
@ -66,7 +66,7 @@ RETURNS int4[] AS $$
|
||||||
-- pg says we're not blocked locally; check whether we're blocked globally.
|
-- pg says we're not blocked locally; check whether we're blocked globally.
|
||||||
SELECT transaction_number INTO mLocalTransactionNum
|
SELECT transaction_number INTO mLocalTransactionNum
|
||||||
FROM get_all_active_transactions() WHERE process_id = pBlockedPid;
|
FROM get_all_active_transactions() WHERE process_id = pBlockedPid;
|
||||||
|
|
||||||
SELECT array_agg(process_id) INTO mRemoteBlockingPids FROM (
|
SELECT array_agg(process_id) INTO mRemoteBlockingPids FROM (
|
||||||
WITH activeTransactions AS (
|
WITH activeTransactions AS (
|
||||||
SELECT process_id, transaction_number FROM get_all_active_transactions()
|
SELECT process_id, transaction_number FROM get_all_active_transactions()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.0-7--7.0-8.sql
|
-- citus--7.0-7--7.0-8.sql
|
||||||
|
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus-7.0-8--7.0-9
|
-- citus-7.0-8--7.0-9
|
||||||
|
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus-7.0-9--7.0-10
|
-- citus-7.0-9--7.0-10
|
||||||
|
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.1-1--7.1-2
|
-- citus--7.1-1--7.1-2
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION pg_catalog.citus_version()
|
CREATE OR REPLACE FUNCTION pg_catalog.citus_version()
|
||||||
RETURNS text
|
RETURNS text
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.1-2--7.1-3
|
-- citus--7.1-2--7.1-3
|
||||||
|
|
||||||
CREATE TABLE citus.pg_dist_node_metadata(
|
CREATE TABLE citus.pg_dist_node_metadata(
|
||||||
metadata jsonb NOT NULL
|
metadata jsonb NOT NULL
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.1-3--7.1-4
|
-- citus--7.1-3--7.1-4
|
||||||
|
|
||||||
CREATE TYPE citus.shard_transfer_mode AS ENUM (
|
CREATE TYPE citus.shard_transfer_mode AS ENUM (
|
||||||
'auto',
|
'auto',
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.1-4--7.2-1
|
-- citus--7.1-4--7.2-1
|
||||||
|
|
||||||
-- bump version to 7.2-1
|
-- bump version to 7.2-1
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.2-1--7.2-2
|
-- citus--7.2-1--7.2-2
|
||||||
|
|
||||||
CREATE TYPE citus.copy_format AS ENUM ('csv', 'binary', 'text');
|
CREATE TYPE citus.copy_format AS ENUM ('csv', 'binary', 'text');
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.2-2--7.2-3
|
-- citus--7.2-2--7.2-3
|
||||||
|
|
||||||
DROP FUNCTION pg_catalog.read_intermediate_result(text,citus.copy_format);
|
DROP FUNCTION pg_catalog.read_intermediate_result(text,citus.copy_format);
|
||||||
DROP TYPE citus.copy_format;
|
DROP TYPE citus.copy_format;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.2-3--7.3-1
|
-- citus--7.2-3--7.3-1
|
||||||
|
|
||||||
-- bump version to 7.3-1
|
-- bump version to 7.3-1
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.3-1--7.3-2
|
-- citus--7.3-1--7.3-2
|
||||||
|
|
||||||
CREATE FUNCTION pg_catalog.citus_text_send_as_jsonb(text)
|
CREATE FUNCTION pg_catalog.citus_text_send_as_jsonb(text)
|
||||||
RETURNS bytea
|
RETURNS bytea
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.3-2--7.3-3
|
-- citus--7.3-2--7.3-3
|
||||||
|
|
||||||
-- Citus json aggregate helpers
|
-- Citus json aggregate helpers
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ CREATE FUNCTION pg_catalog.citus_jsonb_concatenate(state jsonb, val jsonb)
|
||||||
RETURNS jsonb
|
RETURNS jsonb
|
||||||
LANGUAGE SQL
|
LANGUAGE SQL
|
||||||
AS $function$
|
AS $function$
|
||||||
SELECT CASE
|
SELECT CASE
|
||||||
WHEN val IS NULL THEN state
|
WHEN val IS NULL THEN state
|
||||||
WHEN jsonb_typeof(state) = 'null' THEN val
|
WHEN jsonb_typeof(state) = 'null' THEN val
|
||||||
ELSE state || val
|
ELSE state || val
|
||||||
|
@ -24,7 +24,7 @@ CREATE FUNCTION pg_catalog.citus_json_concatenate(state json, val json)
|
||||||
RETURNS json
|
RETURNS json
|
||||||
LANGUAGE SQL
|
LANGUAGE SQL
|
||||||
AS $function$
|
AS $function$
|
||||||
SELECT CASE
|
SELECT CASE
|
||||||
WHEN val IS NULL THEN state
|
WHEN val IS NULL THEN state
|
||||||
WHEN json_typeof(state) = 'null' THEN val
|
WHEN json_typeof(state) = 'null' THEN val
|
||||||
WHEN json_typeof(state) = 'object' THEN
|
WHEN json_typeof(state) = 'object' THEN
|
||||||
|
@ -33,7 +33,7 @@ AS $function$
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT * FROM json_each(val)
|
SELECT * FROM json_each(val)
|
||||||
) t)
|
) t)
|
||||||
ELSE
|
ELSE
|
||||||
(SELECT json_agg(a) FROM (
|
(SELECT json_agg(a) FROM (
|
||||||
SELECT json_array_elements(state) AS a
|
SELECT json_array_elements(state) AS a
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
@ -60,7 +60,7 @@ CREATE AGGREGATE pg_catalog.jsonb_cat_agg(jsonb) (
|
||||||
);
|
);
|
||||||
COMMENT ON AGGREGATE pg_catalog.jsonb_cat_agg(jsonb)
|
COMMENT ON AGGREGATE pg_catalog.jsonb_cat_agg(jsonb)
|
||||||
IS 'concatenate input jsonbs into a single jsonb';
|
IS 'concatenate input jsonbs into a single jsonb';
|
||||||
|
|
||||||
CREATE AGGREGATE pg_catalog.json_cat_agg(json) (
|
CREATE AGGREGATE pg_catalog.json_cat_agg(json) (
|
||||||
SFUNC = citus_json_concatenate,
|
SFUNC = citus_json_concatenate,
|
||||||
FINALFUNC = citus_json_concatenate_final,
|
FINALFUNC = citus_json_concatenate_final,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.3-3--7.4-1
|
-- citus--7.3-3--7.4-1
|
||||||
|
|
||||||
DROP FUNCTION IF EXISTS master_expire_table_cache(regclass);
|
DROP FUNCTION IF EXISTS master_expire_table_cache(regclass);
|
||||||
DROP FUNCTION IF EXISTS pg_catalog.worker_fetch_regular_table(text, bigint, text[], integer[]);
|
DROP FUNCTION IF EXISTS pg_catalog.worker_fetch_regular_table(text, bigint, text[], integer[]);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.4-1--7.4-2
|
-- citus--7.4-1--7.4-2
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION pg_catalog.citus_drop_trigger()
|
CREATE OR REPLACE FUNCTION pg_catalog.citus_drop_trigger()
|
||||||
RETURNS event_trigger
|
RETURNS event_trigger
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.4-2--7.4-3
|
-- citus--7.4-2--7.4-3
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
-- note that we're not dropping the older version of the function
|
-- note that we're not dropping the older version of the function
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.4-3--7.5-1
|
-- citus--7.4-3--7.5-1
|
||||||
|
|
||||||
-- bump version to 7.5-1
|
-- bump version to 7.5-1
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.5-1--7.5-2
|
-- citus--7.5-1--7.5-2
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
-- note that we're not dropping the older version of the function
|
-- note that we're not dropping the older version of the function
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.5-2--7.5-3
|
-- citus--7.5-2--7.5-3
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
CREATE FUNCTION master_dist_authinfo_cache_invalidate()
|
CREATE FUNCTION master_dist_authinfo_cache_invalidate()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.5-3--7.5-4
|
-- citus--7.5-3--7.5-4
|
||||||
|
|
||||||
CREATE FUNCTION pg_catalog.citus_query_stats(OUT queryid bigint,
|
CREATE FUNCTION pg_catalog.citus_query_stats(OUT queryid bigint,
|
||||||
OUT userid oid,
|
OUT userid oid,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.5-4--7.5-5
|
-- citus--7.5-4--7.5-5
|
||||||
CREATE FUNCTION pg_catalog.citus_executor_name(executor_type int)
|
CREATE FUNCTION pg_catalog.citus_executor_name(executor_type int)
|
||||||
RETURNS TEXT
|
RETURNS TEXT
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.5-5--7.5-6
|
-- citus--7.5-5--7.5-6
|
||||||
|
|
||||||
-- Don't want this to be available to non-superusers.
|
-- Don't want this to be available to non-superusers.
|
||||||
REVOKE ALL ON FUNCTION pg_catalog.citus_stat_statements_reset() FROM PUBLIC;
|
REVOKE ALL ON FUNCTION pg_catalog.citus_stat_statements_reset() FROM PUBLIC;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.5-6--7.5-7
|
-- citus--7.5-6--7.5-7
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
CREATE FUNCTION pg_catalog.poolinfo_valid(text)
|
CREATE FUNCTION pg_catalog.poolinfo_valid(text)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.5-7--8.0-1
|
-- citus--7.5-7--8.0-1
|
||||||
|
|
||||||
-- bump version to 8.0-1
|
-- bump version to 8.0-1
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--7.5-7--8.0-1
|
-- citus--7.5-7--8.0-1
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION pg_catalog.relation_is_a_known_shard(regclass)
|
CREATE OR REPLACE FUNCTION pg_catalog.relation_is_a_known_shard(regclass)
|
||||||
|
@ -20,7 +20,7 @@ COMMENT ON FUNCTION citus_table_is_visible(oid)
|
||||||
-- this is the exact same query with what \d
|
-- this is the exact same query with what \d
|
||||||
-- command produces, except pg_table_is_visible
|
-- command produces, except pg_table_is_visible
|
||||||
-- is replaced with pg_catalog.relation_is_a_known_shard(c.oid)
|
-- is replaced with pg_catalog.relation_is_a_known_shard(c.oid)
|
||||||
CREATE VIEW citus.citus_shards_on_worker AS
|
CREATE VIEW citus.citus_shards_on_worker AS
|
||||||
SELECT n.nspname as "Schema",
|
SELECT n.nspname as "Schema",
|
||||||
c.relname as "Name",
|
c.relname as "Name",
|
||||||
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'table' END as "Type",
|
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'table' END as "Type",
|
||||||
|
@ -39,7 +39,7 @@ GRANT SELECT ON pg_catalog.citus_shards_on_worker TO public;
|
||||||
-- this is the exact same query with what \di
|
-- this is the exact same query with what \di
|
||||||
-- command produces, except pg_table_is_visible
|
-- command produces, except pg_table_is_visible
|
||||||
-- is replaced with pg_catalog.relation_is_a_known_shard(c.oid)
|
-- is replaced with pg_catalog.relation_is_a_known_shard(c.oid)
|
||||||
CREATE VIEW citus.citus_shard_indexes_on_worker AS
|
CREATE VIEW citus.citus_shard_indexes_on_worker AS
|
||||||
SELECT n.nspname as "Schema",
|
SELECT n.nspname as "Schema",
|
||||||
c.relname as "Name",
|
c.relname as "Name",
|
||||||
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'table' END as "Type",
|
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'table' END as "Type",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--8.0-10--8.0-11
|
-- citus--8.0-10--8.0-11
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
-- Deprecated functions
|
-- Deprecated functions
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--8.0-11--8.0-12
|
-- citus--8.0-11--8.0-12
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_statements(OUT queryid bigint,
|
CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_statements(OUT queryid bigint,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--8.0-12--8.0-13
|
-- citus--8.0-12--8.0-13
|
||||||
CREATE FUNCTION citus_check_defaults_for_sslmode()
|
CREATE FUNCTION citus_check_defaults_for_sslmode()
|
||||||
RETURNS void
|
RETURNS void
|
||||||
LANGUAGE C STRICT
|
LANGUAGE C STRICT
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--8.0-13--8.1-1.sql
|
-- citus--8.0-13--8.1-1.sql
|
||||||
|
|
||||||
-- bump version to 8.1-1
|
-- bump version to 8.1-1
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--8.0-2--8.0-3
|
-- citus--8.0-2--8.0-3
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
CREATE FUNCTION master_remove_partition_metadata(logicalrelid regclass,
|
CREATE FUNCTION master_remove_partition_metadata(logicalrelid regclass,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--8.0-3--8.0-4
|
-- citus--8.0-3--8.0-4
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION lock_relation_if_exists(table_name text, lock_mode text)
|
CREATE OR REPLACE FUNCTION lock_relation_if_exists(table_name text, lock_mode text)
|
||||||
|
|
|
@ -1,37 +1,37 @@
|
||||||
-- citus--8.0-4--8.0-5.sql
|
-- citus--8.0-4--8.0-5.sql
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
|
|
||||||
DROP FUNCTION IF EXISTS get_all_active_transactions();
|
DROP FUNCTION IF EXISTS get_all_active_transactions();
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION get_all_active_transactions(OUT datid oid, OUT process_id int, OUT initiator_node_identifier int4, OUT worker_query BOOL,
|
CREATE OR REPLACE FUNCTION get_all_active_transactions(OUT datid oid, OUT process_id int, OUT initiator_node_identifier int4, OUT worker_query BOOL,
|
||||||
OUT transaction_number int8, OUT transaction_stamp timestamptz)
|
OUT transaction_number int8, OUT transaction_stamp timestamptz)
|
||||||
RETURNS SETOF RECORD
|
RETURNS SETOF RECORD
|
||||||
LANGUAGE C STRICT AS 'MODULE_PATHNAME',
|
LANGUAGE C STRICT AS 'MODULE_PATHNAME',
|
||||||
$$get_all_active_transactions$$;
|
$$get_all_active_transactions$$;
|
||||||
|
|
||||||
COMMENT ON FUNCTION get_all_active_transactions(OUT datid oid, OUT datname text, OUT process_id int, OUT initiator_node_identifier int4, OUT worker_query BOOL,
|
COMMENT ON FUNCTION get_all_active_transactions(OUT datid oid, OUT datname text, OUT process_id int, OUT initiator_node_identifier int4, OUT worker_query BOOL,
|
||||||
OUT transaction_number int8, OUT transaction_stamp timestamptz)
|
OUT transaction_number int8, OUT transaction_stamp timestamptz)
|
||||||
IS 'returns distributed transaction ids of active distributed transactions';
|
IS 'returns distributed transaction ids of active distributed transactions';
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION citus_dist_stat_activity(OUT query_hostname text, OUT query_hostport int, OUT master_query_host_name text, OUT master_query_host_port int,
|
CREATE OR REPLACE FUNCTION citus_dist_stat_activity(OUT query_hostname text, OUT query_hostport int, OUT master_query_host_name text, OUT master_query_host_port int,
|
||||||
OUT transaction_number int8, OUT transaction_stamp timestamptz, OUT datid oid, OUT datname name,
|
OUT transaction_number int8, OUT transaction_stamp timestamptz, OUT datid oid, OUT datname name,
|
||||||
OUT pid int, OUT usesysid oid, OUT usename name, OUT application_name text, OUT client_addr INET,
|
OUT pid int, OUT usesysid oid, OUT usename name, OUT application_name text, OUT client_addr INET,
|
||||||
OUT client_hostname TEXT, OUT client_port int, OUT backend_start timestamptz, OUT xact_start timestamptz,
|
OUT client_hostname TEXT, OUT client_port int, OUT backend_start timestamptz, OUT xact_start timestamptz,
|
||||||
OUT query_start timestamptz, OUT state_change timestamptz, OUT wait_event_type text, OUT wait_event text,
|
OUT query_start timestamptz, OUT state_change timestamptz, OUT wait_event_type text, OUT wait_event text,
|
||||||
OUT state text, OUT backend_xid xid, OUT backend_xmin xid, OUT query text, OUT backend_type text)
|
OUT state text, OUT backend_xid xid, OUT backend_xmin xid, OUT query text, OUT backend_type text)
|
||||||
RETURNS SETOF RECORD
|
RETURNS SETOF RECORD
|
||||||
LANGUAGE C STRICT AS 'MODULE_PATHNAME',
|
LANGUAGE C STRICT AS 'MODULE_PATHNAME',
|
||||||
$$citus_dist_stat_activity$$;
|
$$citus_dist_stat_activity$$;
|
||||||
|
|
||||||
COMMENT ON FUNCTION citus_dist_stat_activity(OUT query_hostname text, OUT query_hostport int, OUT master_query_host_name text, OUT master_query_host_port int,
|
COMMENT ON FUNCTION citus_dist_stat_activity(OUT query_hostname text, OUT query_hostport int, OUT master_query_host_name text, OUT master_query_host_port int,
|
||||||
OUT transaction_number int8, OUT transaction_stamp timestamptz, OUT datid oid, OUT datname name,
|
OUT transaction_number int8, OUT transaction_stamp timestamptz, OUT datid oid, OUT datname name,
|
||||||
OUT pid int, OUT usesysid oid, OUT usename name, OUT application_name text, OUT client_addr INET,
|
OUT pid int, OUT usesysid oid, OUT usename name, OUT application_name text, OUT client_addr INET,
|
||||||
OUT client_hostname TEXT, OUT client_port int, OUT backend_start timestamptz, OUT xact_start timestamptz,
|
OUT client_hostname TEXT, OUT client_port int, OUT backend_start timestamptz, OUT xact_start timestamptz,
|
||||||
OUT query_start timestamptz, OUT state_change timestamptz, OUT wait_event_type text, OUT wait_event text,
|
OUT query_start timestamptz, OUT state_change timestamptz, OUT wait_event_type text, OUT wait_event text,
|
||||||
OUT state text, OUT backend_xid xid, OUT backend_xmin xid, OUT query text, OUT backend_type text)
|
OUT state text, OUT backend_xid xid, OUT backend_xmin xid, OUT query text, OUT backend_type text)
|
||||||
IS 'returns distributed transaction activity on distributed tables';
|
IS 'returns distributed transaction activity on distributed tables';
|
||||||
|
|
||||||
CREATE VIEW citus.citus_dist_stat_activity AS
|
CREATE VIEW citus.citus_dist_stat_activity AS
|
||||||
|
@ -41,22 +41,22 @@ GRANT SELECT ON pg_catalog.citus_dist_stat_activity TO PUBLIC;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION citus_worker_stat_activity(OUT query_hostname text, OUT query_hostport int, OUT master_query_host_name text, OUT master_query_host_port int,
|
CREATE OR REPLACE FUNCTION citus_worker_stat_activity(OUT query_hostname text, OUT query_hostport int, OUT master_query_host_name text, OUT master_query_host_port int,
|
||||||
OUT transaction_number int8, OUT transaction_stamp timestamptz, OUT datid oid, OUT datname name,
|
OUT transaction_number int8, OUT transaction_stamp timestamptz, OUT datid oid, OUT datname name,
|
||||||
OUT pid int, OUT usesysid oid, OUT usename name, OUT application_name text, OUT client_addr INET,
|
OUT pid int, OUT usesysid oid, OUT usename name, OUT application_name text, OUT client_addr INET,
|
||||||
OUT client_hostname TEXT, OUT client_port int, OUT backend_start timestamptz, OUT xact_start timestamptz,
|
OUT client_hostname TEXT, OUT client_port int, OUT backend_start timestamptz, OUT xact_start timestamptz,
|
||||||
OUT query_start timestamptz, OUT state_change timestamptz, OUT wait_event_type text, OUT wait_event text,
|
OUT query_start timestamptz, OUT state_change timestamptz, OUT wait_event_type text, OUT wait_event text,
|
||||||
OUT state text, OUT backend_xid xid, OUT backend_xmin xid, OUT query text, OUT backend_type text)
|
OUT state text, OUT backend_xid xid, OUT backend_xmin xid, OUT query text, OUT backend_type text)
|
||||||
RETURNS SETOF RECORD
|
RETURNS SETOF RECORD
|
||||||
LANGUAGE C STRICT AS 'MODULE_PATHNAME',
|
LANGUAGE C STRICT AS 'MODULE_PATHNAME',
|
||||||
$$citus_worker_stat_activity$$;
|
$$citus_worker_stat_activity$$;
|
||||||
|
|
||||||
COMMENT ON FUNCTION citus_worker_stat_activity(OUT query_hostname text, OUT query_hostport int, OUT master_query_host_name text, OUT master_query_host_port int,
|
COMMENT ON FUNCTION citus_worker_stat_activity(OUT query_hostname text, OUT query_hostport int, OUT master_query_host_name text, OUT master_query_host_port int,
|
||||||
OUT transaction_number int8, OUT transaction_stamp timestamptz, OUT datid oid, OUT datname name,
|
OUT transaction_number int8, OUT transaction_stamp timestamptz, OUT datid oid, OUT datname name,
|
||||||
OUT pid int, OUT usesysid oid, OUT usename name, OUT application_name text, OUT client_addr INET,
|
OUT pid int, OUT usesysid oid, OUT usename name, OUT application_name text, OUT client_addr INET,
|
||||||
OUT client_hostname TEXT, OUT client_port int, OUT backend_start timestamptz, OUT xact_start timestamptz,
|
OUT client_hostname TEXT, OUT client_port int, OUT backend_start timestamptz, OUT xact_start timestamptz,
|
||||||
OUT query_start timestamptz, OUT state_change timestamptz, OUT wait_event_type text, OUT wait_event text,
|
OUT query_start timestamptz, OUT state_change timestamptz, OUT wait_event_type text, OUT wait_event text,
|
||||||
OUT state text, OUT backend_xid xid, OUT backend_xmin xid, OUT query text, OUT backend_type text)
|
OUT state text, OUT backend_xid xid, OUT backend_xmin xid, OUT query text, OUT backend_type text)
|
||||||
IS 'returns distributed transaction activity on shards of distributed tables';
|
IS 'returns distributed transaction activity on shards of distributed tables';
|
||||||
|
|
||||||
CREATE VIEW citus.citus_worker_stat_activity AS
|
CREATE VIEW citus.citus_worker_stat_activity AS
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--8.0-5--8.0-6
|
-- citus--8.0-5--8.0-6
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
CREATE FUNCTION get_global_active_transactions(OUT datid oid, OUT process_id int, OUT initiator_node_identifier int4, OUT worker_query BOOL, OUT transaction_number int8, OUT transaction_stamp timestamptz)
|
CREATE FUNCTION get_global_active_transactions(OUT datid oid, OUT process_id int, OUT initiator_node_identifier int4, OUT worker_query BOOL, OUT transaction_number int8, OUT transaction_stamp timestamptz)
|
||||||
|
@ -42,10 +42,10 @@ RETURNS int4[] AS $$
|
||||||
WHERE waiting_transaction_num = mLocalTransactionNum) THEN
|
WHERE waiting_transaction_num = mLocalTransactionNum) THEN
|
||||||
SELECT array_agg(pBlockedPid) INTO mRemoteBlockingPids;
|
SELECT array_agg(pBlockedPid) INTO mRemoteBlockingPids;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
RETURN mRemoteBlockingPids;
|
RETURN mRemoteBlockingPids;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
#include "udfs/citus_isolation_test_session_is_blocked/8.0-6.sql"
|
#include "udfs/citus_isolation_test_session_is_blocked/8.0-6.sql"
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
-- citus--8.0-6--8.0-7
|
-- citus--8.0-6--8.0-7
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
CREATE VIEW citus.citus_lock_waits AS
|
CREATE VIEW citus.citus_lock_waits AS
|
||||||
|
|
||||||
WITH
|
WITH
|
||||||
citus_dist_stat_activity AS
|
citus_dist_stat_activity AS
|
||||||
(
|
(
|
||||||
SELECT * FROM citus_dist_stat_activity
|
SELECT * FROM citus_dist_stat_activity
|
||||||
|
@ -19,7 +19,7 @@ citus_dist_stat_activity_with_node_id AS
|
||||||
FROM
|
FROM
|
||||||
citus_dist_stat_activity LEFT JOIN pg_dist_node
|
citus_dist_stat_activity LEFT JOIN pg_dist_node
|
||||||
ON
|
ON
|
||||||
citus_dist_stat_activity.master_query_host_name = pg_dist_node.nodename AND
|
citus_dist_stat_activity.master_query_host_name = pg_dist_node.nodename AND
|
||||||
citus_dist_stat_activity.master_query_host_port = pg_dist_node.nodeport
|
citus_dist_stat_activity.master_query_host_port = pg_dist_node.nodeport
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
-- citus--8.0-7--8.0-8
|
-- citus--8.0-7--8.0-8
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
DROP FUNCTION IF EXISTS pg_catalog.worker_drop_distributed_table(logicalrelid Oid);
|
DROP FUNCTION IF EXISTS pg_catalog.worker_drop_distributed_table(logicalrelid Oid);
|
||||||
|
|
||||||
|
|
||||||
CREATE FUNCTION worker_drop_distributed_table(table_name text)
|
CREATE FUNCTION worker_drop_distributed_table(table_name text)
|
||||||
RETURNS VOID
|
RETURNS VOID
|
||||||
LANGUAGE C STRICT
|
LANGUAGE C STRICT
|
||||||
AS 'MODULE_PATHNAME', $$worker_drop_distributed_table$$;
|
AS 'MODULE_PATHNAME', $$worker_drop_distributed_table$$;
|
||||||
|
|
||||||
COMMENT ON FUNCTION worker_drop_distributed_table(table_name text)
|
COMMENT ON FUNCTION worker_drop_distributed_table(table_name text)
|
||||||
IS 'drop the distributed table and its reference from metadata tables';
|
IS 'drop the distributed table and its reference from metadata tables';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--8.0-9--8.0-10
|
-- citus--8.0-9--8.0-10
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
CREATE FUNCTION worker_execute_sql_task(jobid bigint, taskid integer, query text, binary bool)
|
CREATE FUNCTION worker_execute_sql_task(jobid bigint, taskid integer, query text, binary bool)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--8.1-1--8.2-1.sql
|
-- citus--8.1-1--8.2-1.sql
|
||||||
|
|
||||||
-- bump version to 8.2-1
|
-- bump version to 8.2-1
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
-- citus--8.2-1--8.2-2.sql
|
-- citus--8.2-1--8.2-2.sql
|
||||||
|
|
||||||
DROP FUNCTION IF EXISTS pg_catalog.create_insert_proxy_for_table(regclass,regclass);
|
DROP FUNCTION IF EXISTS pg_catalog.create_insert_proxy_for_table(regclass,regclass);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--8.2-2--8.2-3
|
-- citus--8.2-2--8.2-3
|
||||||
|
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--8.2-3--8.2-4
|
-- citus--8.2-3--8.2-4
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION pg_catalog.citus_executor_name(executor_type int)
|
CREATE OR REPLACE FUNCTION pg_catalog.citus_executor_name(executor_type int)
|
||||||
RETURNS text
|
RETURNS text
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--8.2-4--8.3-1
|
-- citus--8.2-4--8.3-1
|
||||||
|
|
||||||
-- bump version to 8.3-1
|
-- bump version to 8.3-1
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- citus--8.3-1--9.0-1
|
-- citus--8.3-1--9.0-1
|
||||||
|
|
||||||
SET search_path = 'pg_catalog';
|
SET search_path = 'pg_catalog';
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ CREATE TRIGGER dist_object_cache_invalidate
|
||||||
-- by the operator.
|
-- by the operator.
|
||||||
ALTER TABLE pg_dist_poolinfo DROP CONSTRAINT pg_dist_poolinfo_nodeid_fkey;
|
ALTER TABLE pg_dist_poolinfo DROP CONSTRAINT pg_dist_poolinfo_nodeid_fkey;
|
||||||
|
|
||||||
-- if the rebalancer extension is still around, drop it before creating Citus functions
|
-- if the rebalancer extension is still around, drop it before creating Citus functions
|
||||||
DROP EXTENSION IF EXISTS shard_rebalancer;
|
DROP EXTENSION IF EXISTS shard_rebalancer;
|
||||||
|
|
||||||
#include "udfs/get_rebalance_table_shards_plan/9.0-1.sql"
|
#include "udfs/get_rebalance_table_shards_plan/9.0-1.sql"
|
||||||
|
|
|
@ -9,4 +9,3 @@ COMMENT ON FUNCTION pg_catalog.alter_role_if_exists(
|
||||||
role_name text,
|
role_name text,
|
||||||
utility_query text)
|
utility_query text)
|
||||||
IS 'runs the utility query, if the role exists';
|
IS 'runs the utility query, if the role exists';
|
||||||
|
|
|
@ -9,4 +9,3 @@ COMMENT ON FUNCTION pg_catalog.alter_role_if_exists(
|
||||||
role_name text,
|
role_name text,
|
||||||
utility_query text)
|
utility_query text)
|
||||||
IS 'runs the utility query, if the role exists';
|
IS 'runs the utility query, if the role exists';
|
||||||
|
|
|
@ -15,7 +15,7 @@ RETURNS boolean AS $$
|
||||||
-- number when the worker process waiting for other session.
|
-- number when the worker process waiting for other session.
|
||||||
IF EXISTS (SELECT transaction_number FROM get_global_active_transactions()
|
IF EXISTS (SELECT transaction_number FROM get_global_active_transactions()
|
||||||
WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId) THEN
|
WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId) THEN
|
||||||
SELECT transaction_number INTO mBlockedTransactionNum FROM get_global_active_transactions()
|
SELECT transaction_number INTO mBlockedTransactionNum FROM get_global_active_transactions()
|
||||||
WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId;
|
WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId;
|
||||||
ELSE
|
ELSE
|
||||||
-- Check whether transactions initiated from the coordinator get locked
|
-- Check whether transactions initiated from the coordinator get locked
|
||||||
|
|
|
@ -15,7 +15,7 @@ RETURNS boolean AS $$
|
||||||
-- number when the worker process waiting for other session.
|
-- number when the worker process waiting for other session.
|
||||||
IF EXISTS (SELECT transaction_number FROM get_global_active_transactions()
|
IF EXISTS (SELECT transaction_number FROM get_global_active_transactions()
|
||||||
WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId) THEN
|
WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId) THEN
|
||||||
SELECT transaction_number INTO mBlockedTransactionNum FROM get_global_active_transactions()
|
SELECT transaction_number INTO mBlockedTransactionNum FROM get_global_active_transactions()
|
||||||
WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId;
|
WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId;
|
||||||
ELSE
|
ELSE
|
||||||
-- Check whether transactions initiated from the coordinator get locked
|
-- Check whether transactions initiated from the coordinator get locked
|
||||||
|
|
|
@ -15,7 +15,7 @@ RETURNS boolean AS $$
|
||||||
-- number when the worker process waiting for other session.
|
-- number when the worker process waiting for other session.
|
||||||
IF EXISTS (SELECT transaction_number FROM get_global_active_transactions()
|
IF EXISTS (SELECT transaction_number FROM get_global_active_transactions()
|
||||||
WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId) THEN
|
WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId) THEN
|
||||||
SELECT transaction_number INTO mBlockedTransactionNum FROM get_global_active_transactions()
|
SELECT transaction_number INTO mBlockedTransactionNum FROM get_global_active_transactions()
|
||||||
WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId;
|
WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId;
|
||||||
ELSE
|
ELSE
|
||||||
-- Check whether transactions initiated from the coordinator get locked
|
-- Check whether transactions initiated from the coordinator get locked
|
||||||
|
|
|
@ -165,14 +165,14 @@ check-citus-upgrade-local:
|
||||||
$(citus_upgrade_check) \
|
$(citus_upgrade_check) \
|
||||||
--bindir=$(bindir) \
|
--bindir=$(bindir) \
|
||||||
--pgxsdir=$(pgxsdir) \
|
--pgxsdir=$(pgxsdir) \
|
||||||
--citus-old-version=$(citus-old-version)
|
--citus-old-version=$(citus-old-version)
|
||||||
|
|
||||||
check-citus-upgrade-mixed-local:
|
check-citus-upgrade-mixed-local:
|
||||||
$(citus_upgrade_check) \
|
$(citus_upgrade_check) \
|
||||||
--bindir=$(bindir) \
|
--bindir=$(bindir) \
|
||||||
--pgxsdir=$(pgxsdir) \
|
--pgxsdir=$(pgxsdir) \
|
||||||
--citus-old-version=$(citus-old-version) \
|
--citus-old-version=$(citus-old-version) \
|
||||||
--mixed
|
--mixed
|
||||||
|
|
||||||
clean distclean maintainer-clean:
|
clean distclean maintainer-clean:
|
||||||
rm -f $(output_files) $(input_files)
|
rm -f $(output_files) $(input_files)
|
||||||
|
|
|
@ -30,7 +30,6 @@ WITH cte_1 AS (
|
||||||
FROM tt1
|
FROM tt1
|
||||||
WHERE value_1 >= 2
|
WHERE value_1 >= 2
|
||||||
)
|
)
|
||||||
|
|
||||||
DELETE FROM tt2
|
DELETE FROM tt2
|
||||||
USING cte_2
|
USING cte_2
|
||||||
WHERE tt2.id = cte_2.cte2_id
|
WHERE tt2.id = cte_2.cte2_id
|
||||||
|
@ -57,7 +56,6 @@ WITH cte_1 AS (
|
||||||
FROM tt1
|
FROM tt1
|
||||||
WHERE value_1 >= 2
|
WHERE value_1 >= 2
|
||||||
)
|
)
|
||||||
|
|
||||||
DELETE FROM tt2
|
DELETE FROM tt2
|
||||||
USING cte_2
|
USING cte_2
|
||||||
WHERE tt2.id = cte_2.cte2_id
|
WHERE tt2.id = cte_2.cte2_id
|
||||||
|
@ -82,9 +80,8 @@ WITH cte_1(id) AS (
|
||||||
FROM tt1
|
FROM tt1
|
||||||
WHERE value_1 >= 2
|
WHERE value_1 >= 2
|
||||||
)
|
)
|
||||||
|
|
||||||
DELETE FROM tt2
|
DELETE FROM tt2
|
||||||
USING cte_2
|
USING cte_2
|
||||||
WHERE tt2.id = cte_2.cte2_id
|
WHERE tt2.id = cte_2.cte2_id
|
||||||
RETURNING cte2_id
|
RETURNING cte2_id
|
||||||
)
|
)
|
||||||
|
@ -107,7 +104,6 @@ WITH cte_1 AS (
|
||||||
FROM tt1
|
FROM tt1
|
||||||
WHERE value_1 >= 2
|
WHERE value_1 >= 2
|
||||||
)
|
)
|
||||||
|
|
||||||
UPDATE tt2
|
UPDATE tt2
|
||||||
SET value_1 = 10
|
SET value_1 = 10
|
||||||
FROM cte_2
|
FROM cte_2
|
||||||
|
@ -130,7 +126,6 @@ WITH cte_1 AS (
|
||||||
WITH cte_2 AS (
|
WITH cte_2 AS (
|
||||||
SELECT * FROM tt3
|
SELECT * FROM tt3
|
||||||
)
|
)
|
||||||
|
|
||||||
UPDATE tt2
|
UPDATE tt2
|
||||||
SET value_1 = (SELECT max((json_val->>'qty')::int) FROM cte_2)
|
SET value_1 = (SELECT max((json_val->>'qty')::int) FROM cte_2)
|
||||||
RETURNING id, value_1
|
RETURNING id, value_1
|
||||||
|
|
|
@ -27,25 +27,25 @@ INSERT INTO distributed_table SELECT i::text, i % 10, row_to_json(row(i, i*i)) F
|
||||||
INSERT INTO second_distributed_table SELECT i::text, i % 10, row_to_json(row(i, i*i)) FROM generate_series (0, 100) i;
|
INSERT INTO second_distributed_table SELECT i::text, i % 10, row_to_json(row(i, i*i)) FROM generate_series (0, 100) i;
|
||||||
INSERT INTO reference_table SELECT i::text, 'user_' || i FROM generate_series (0, 100) i;
|
INSERT INTO reference_table SELECT i::text, 'user_' || i FROM generate_series (0, 100) i;
|
||||||
INSERT INTO local_table SELECT i::text, 'user_' || i FROM generate_series (0, 100) i;
|
INSERT INTO local_table SELECT i::text, 'user_' || i FROM generate_series (0, 100) i;
|
||||||
CREATE VIEW tenant_ids AS
|
CREATE VIEW tenant_ids AS
|
||||||
SELECT
|
SELECT
|
||||||
tenant_id, name
|
tenant_id, name
|
||||||
FROM
|
FROM
|
||||||
distributed_table, reference_table
|
distributed_table, reference_table
|
||||||
WHERE
|
WHERE
|
||||||
distributed_table.dept::text = reference_table.id
|
distributed_table.dept::text = reference_table.id
|
||||||
ORDER BY 2 DESC, 1 DESC;
|
ORDER BY 2 DESC, 1 DESC;
|
||||||
SET client_min_messages TO DEBUG1;
|
SET client_min_messages TO DEBUG1;
|
||||||
-- the subquery foo is recursively planned
|
-- the subquery foo is recursively planned
|
||||||
UPDATE
|
UPDATE
|
||||||
reference_table
|
reference_table
|
||||||
SET
|
SET
|
||||||
name = 'new_' || name
|
name = 'new_' || name
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
avg(second_distributed_table.tenant_id::int) as avg_tenant_id
|
avg(second_distributed_table.tenant_id::int) as avg_tenant_id
|
||||||
FROM
|
FROM
|
||||||
second_distributed_table
|
second_distributed_table
|
||||||
) as foo
|
) as foo
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -61,27 +61,27 @@ DEBUG: Plan 4 query after replacing subqueries and CTEs: UPDATE recursive_dml_q
|
||||||
|
|
||||||
-- the subquery foo is recursively planned
|
-- the subquery foo is recursively planned
|
||||||
-- but note that the subquery foo itself is pushdownable
|
-- but note that the subquery foo itself is pushdownable
|
||||||
UPDATE
|
UPDATE
|
||||||
second_distributed_table
|
second_distributed_table
|
||||||
SET
|
SET
|
||||||
dept = foo.max_dept * 2
|
dept = foo.max_dept * 2
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT DISTINCT ON (tenant_id) tenant_id, max(dept) as max_dept FROM
|
SELECT DISTINCT ON (tenant_id) tenant_id, max(dept) as max_dept FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
second_distributed_table.dept, second_distributed_table.tenant_id
|
second_distributed_table.dept, second_distributed_table.tenant_id
|
||||||
FROM
|
FROM
|
||||||
second_distributed_table, distributed_table
|
second_distributed_table, distributed_table
|
||||||
WHERE
|
WHERE
|
||||||
distributed_table.tenant_id = second_distributed_table.tenant_id
|
distributed_table.tenant_id = second_distributed_table.tenant_id
|
||||||
) foo_inner
|
) foo_inner
|
||||||
GROUP BY
|
GROUP BY
|
||||||
tenant_id
|
tenant_id
|
||||||
ORDER BY 1 DESC
|
ORDER BY 1 DESC
|
||||||
) as foo
|
) as foo
|
||||||
WHERE
|
WHERE
|
||||||
foo.tenant_id != second_distributed_table.tenant_id
|
foo.tenant_id != second_distributed_table.tenant_id
|
||||||
AND second_distributed_table.dept IN (2)
|
AND second_distributed_table.dept IN (2)
|
||||||
RETURNING
|
RETURNING
|
||||||
second_distributed_table.tenant_id, second_distributed_table.dept;
|
second_distributed_table.tenant_id, second_distributed_table.dept;
|
||||||
|
@ -103,29 +103,29 @@ DEBUG: Plan 6 query after replacing subqueries and CTEs: UPDATE recursive_dml_q
|
||||||
|
|
||||||
-- the subquery foo is recursively planned
|
-- the subquery foo is recursively planned
|
||||||
-- and foo itself is a non colocated subquery and recursively planned
|
-- and foo itself is a non colocated subquery and recursively planned
|
||||||
UPDATE
|
UPDATE
|
||||||
second_distributed_table
|
second_distributed_table
|
||||||
SET
|
SET
|
||||||
dept = foo.tenant_id::int / 4
|
dept = foo.tenant_id::int / 4
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT DISTINCT foo_inner_1.tenant_id FROM
|
SELECT DISTINCT foo_inner_1.tenant_id FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
second_distributed_table.dept, second_distributed_table.tenant_id
|
second_distributed_table.dept, second_distributed_table.tenant_id
|
||||||
FROM
|
FROM
|
||||||
second_distributed_table, distributed_table
|
second_distributed_table, distributed_table
|
||||||
WHERE
|
WHERE
|
||||||
distributed_table.tenant_id = second_distributed_table.tenant_id
|
distributed_table.tenant_id = second_distributed_table.tenant_id
|
||||||
AND
|
AND
|
||||||
second_distributed_table.dept IN (3,4)
|
second_distributed_table.dept IN (3,4)
|
||||||
) foo_inner_1,
|
) foo_inner_1,
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
second_distributed_table.tenant_id
|
second_distributed_table.tenant_id
|
||||||
FROM
|
FROM
|
||||||
second_distributed_table, distributed_table
|
second_distributed_table, distributed_table
|
||||||
WHERE
|
WHERE
|
||||||
distributed_table.tenant_id = second_distributed_table.tenant_id
|
distributed_table.tenant_id = second_distributed_table.tenant_id
|
||||||
AND
|
AND
|
||||||
second_distributed_table.dept IN (4,5)
|
second_distributed_table.dept IN (4,5)
|
||||||
|
@ -133,21 +133,21 @@ FROM
|
||||||
WHERE foo_inner_1.tenant_id != foo_inner_2.tenant_id
|
WHERE foo_inner_1.tenant_id != foo_inner_2.tenant_id
|
||||||
) as foo
|
) as foo
|
||||||
WHERE
|
WHERE
|
||||||
foo.tenant_id != second_distributed_table.tenant_id
|
foo.tenant_id != second_distributed_table.tenant_id
|
||||||
AND second_distributed_table.dept IN (3);
|
AND second_distributed_table.dept IN (3);
|
||||||
DEBUG: generating subplan 8_1 for subquery SELECT second_distributed_table.tenant_id FROM recursive_dml_queries.second_distributed_table, recursive_dml_queries.distributed_table WHERE ((distributed_table.tenant_id OPERATOR(pg_catalog.=) second_distributed_table.tenant_id) AND (second_distributed_table.dept OPERATOR(pg_catalog.=) ANY (ARRAY[4, 5])))
|
DEBUG: generating subplan 8_1 for subquery SELECT second_distributed_table.tenant_id FROM recursive_dml_queries.second_distributed_table, recursive_dml_queries.distributed_table WHERE ((distributed_table.tenant_id OPERATOR(pg_catalog.=) second_distributed_table.tenant_id) AND (second_distributed_table.dept OPERATOR(pg_catalog.=) ANY (ARRAY[4, 5])))
|
||||||
DEBUG: generating subplan 8_2 for subquery SELECT DISTINCT foo_inner_1.tenant_id FROM (SELECT second_distributed_table.dept, second_distributed_table.tenant_id FROM recursive_dml_queries.second_distributed_table, recursive_dml_queries.distributed_table WHERE ((distributed_table.tenant_id OPERATOR(pg_catalog.=) second_distributed_table.tenant_id) AND (second_distributed_table.dept OPERATOR(pg_catalog.=) ANY (ARRAY[3, 4])))) foo_inner_1, (SELECT intermediate_result.tenant_id FROM read_intermediate_result('8_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) foo_inner_2 WHERE (foo_inner_1.tenant_id OPERATOR(pg_catalog.<>) foo_inner_2.tenant_id)
|
DEBUG: generating subplan 8_2 for subquery SELECT DISTINCT foo_inner_1.tenant_id FROM (SELECT second_distributed_table.dept, second_distributed_table.tenant_id FROM recursive_dml_queries.second_distributed_table, recursive_dml_queries.distributed_table WHERE ((distributed_table.tenant_id OPERATOR(pg_catalog.=) second_distributed_table.tenant_id) AND (second_distributed_table.dept OPERATOR(pg_catalog.=) ANY (ARRAY[3, 4])))) foo_inner_1, (SELECT intermediate_result.tenant_id FROM read_intermediate_result('8_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) foo_inner_2 WHERE (foo_inner_1.tenant_id OPERATOR(pg_catalog.<>) foo_inner_2.tenant_id)
|
||||||
DEBUG: Plan 8 query after replacing subqueries and CTEs: UPDATE recursive_dml_queries.second_distributed_table SET dept = ((foo.tenant_id)::integer OPERATOR(pg_catalog./) 4) FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('8_2'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) foo WHERE ((foo.tenant_id OPERATOR(pg_catalog.<>) second_distributed_table.tenant_id) AND (second_distributed_table.dept OPERATOR(pg_catalog.=) 3))
|
DEBUG: Plan 8 query after replacing subqueries and CTEs: UPDATE recursive_dml_queries.second_distributed_table SET dept = ((foo.tenant_id)::integer OPERATOR(pg_catalog./) 4) FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('8_2'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) foo WHERE ((foo.tenant_id OPERATOR(pg_catalog.<>) second_distributed_table.tenant_id) AND (second_distributed_table.dept OPERATOR(pg_catalog.=) 3))
|
||||||
-- we currently do not allow local tables in modification queries
|
-- we currently do not allow local tables in modification queries
|
||||||
UPDATE
|
UPDATE
|
||||||
distributed_table
|
distributed_table
|
||||||
SET
|
SET
|
||||||
dept = avg_tenant_id::int
|
dept = avg_tenant_id::int
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
avg(local_table.id::int) as avg_tenant_id
|
avg(local_table.id::int) as avg_tenant_id
|
||||||
FROM
|
FROM
|
||||||
local_table
|
local_table
|
||||||
) as foo
|
) as foo
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -162,15 +162,15 @@ DEBUG: Plan 11 query after replacing subqueries and CTEs: UPDATE recursive_dml_
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- we currently do not allow views in modification queries
|
-- we currently do not allow views in modification queries
|
||||||
UPDATE
|
UPDATE
|
||||||
distributed_table
|
distributed_table
|
||||||
SET
|
SET
|
||||||
dept = avg_tenant_id::int
|
dept = avg_tenant_id::int
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
avg(tenant_id::int) as avg_tenant_id
|
avg(tenant_id::int) as avg_tenant_id
|
||||||
FROM
|
FROM
|
||||||
tenant_ids
|
tenant_ids
|
||||||
) as foo
|
) as foo
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -184,32 +184,32 @@ DEBUG: Plan 12 query after replacing subqueries and CTEs: UPDATE recursive_dml_
|
||||||
50 | 50 | {"f1": 50, "f2": 2500}
|
50 | 50 | {"f1": 50, "f2": 2500}
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- there is a lateral join (e.g., corrolated subquery) thus the subqueries cannot be
|
-- there is a lateral join (e.g., corrolated subquery) thus the subqueries cannot be
|
||||||
-- recursively planned
|
-- recursively planned
|
||||||
UPDATE
|
UPDATE
|
||||||
second_distributed_table
|
second_distributed_table
|
||||||
SET
|
SET
|
||||||
dept = foo.tenant_id::int / 4
|
dept = foo.tenant_id::int / 4
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT DISTINCT foo_inner_1.tenant_id FROM
|
SELECT DISTINCT foo_inner_1.tenant_id FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
second_distributed_table.dept, second_distributed_table.tenant_id
|
second_distributed_table.dept, second_distributed_table.tenant_id
|
||||||
FROM
|
FROM
|
||||||
second_distributed_table, distributed_table
|
second_distributed_table, distributed_table
|
||||||
WHERE
|
WHERE
|
||||||
distributed_table.tenant_id = second_distributed_table.tenant_id
|
distributed_table.tenant_id = second_distributed_table.tenant_id
|
||||||
AND
|
AND
|
||||||
second_distributed_table.dept IN (3,4)
|
second_distributed_table.dept IN (3,4)
|
||||||
)
|
)
|
||||||
foo_inner_1 JOIN LATERAL
|
foo_inner_1 JOIN LATERAL
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
second_distributed_table.tenant_id
|
second_distributed_table.tenant_id
|
||||||
FROM
|
FROM
|
||||||
second_distributed_table, distributed_table
|
second_distributed_table, distributed_table
|
||||||
WHERE
|
WHERE
|
||||||
distributed_table.tenant_id = second_distributed_table.tenant_id
|
distributed_table.tenant_id = second_distributed_table.tenant_id
|
||||||
AND foo_inner_1.dept = second_distributed_table.dept
|
AND foo_inner_1.dept = second_distributed_table.dept
|
||||||
AND
|
AND
|
||||||
|
@ -222,55 +222,54 @@ ERROR: complex joins are only supported when all distributed tables are joined
|
||||||
-- again a corrolated subquery
|
-- again a corrolated subquery
|
||||||
-- this time distribution key eq. exists
|
-- this time distribution key eq. exists
|
||||||
-- however recursive planning is prevented due to correlated subqueries
|
-- however recursive planning is prevented due to correlated subqueries
|
||||||
UPDATE
|
UPDATE
|
||||||
second_distributed_table
|
second_distributed_table
|
||||||
SET
|
SET
|
||||||
dept = foo.tenant_id::int / 4
|
dept = foo.tenant_id::int / 4
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT baz.tenant_id FROM
|
SELECT baz.tenant_id FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
second_distributed_table.dept, second_distributed_table.tenant_id
|
second_distributed_table.dept, second_distributed_table.tenant_id
|
||||||
FROM
|
FROM
|
||||||
second_distributed_table, distributed_table as d1
|
second_distributed_table, distributed_table as d1
|
||||||
WHERE
|
WHERE
|
||||||
d1.tenant_id = second_distributed_table.tenant_id
|
d1.tenant_id = second_distributed_table.tenant_id
|
||||||
AND
|
AND
|
||||||
second_distributed_table.dept IN (3,4)
|
second_distributed_table.dept IN (3,4)
|
||||||
AND
|
AND
|
||||||
second_distributed_table.tenant_id IN
|
second_distributed_table.tenant_id IN
|
||||||
(
|
(
|
||||||
SELECT s2.tenant_id
|
SELECT s2.tenant_id
|
||||||
FROM second_distributed_table as s2
|
FROM second_distributed_table as s2
|
||||||
GROUP BY d1.tenant_id, s2.tenant_id
|
GROUP BY d1.tenant_id, s2.tenant_id
|
||||||
)
|
)
|
||||||
) as baz
|
) as baz
|
||||||
) as foo WHERE second_distributed_table.tenant_id = foo.tenant_id
|
) as foo WHERE second_distributed_table.tenant_id = foo.tenant_id
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
ERROR: complex joins are only supported when all distributed tables are joined on their distribution columns with equal operator
|
ERROR: complex joins are only supported when all distributed tables are joined on their distribution columns with equal operator
|
||||||
-- we don't support subqueries/CTEs inside VALUES
|
-- we don't support subqueries/CTEs inside VALUES
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
second_distributed_table (tenant_id, dept)
|
second_distributed_table (tenant_id, dept)
|
||||||
VALUES ('3', (WITH vals AS (SELECT 3) select * from vals));
|
VALUES ('3', (WITH vals AS (SELECT 3) select * from vals));
|
||||||
DEBUG: generating subplan 18_1 for CTE vals: SELECT 3
|
DEBUG: generating subplan 18_1 for CTE vals: SELECT 3
|
||||||
DEBUG: Plan 18 query after replacing subqueries and CTEs: INSERT INTO recursive_dml_queries.second_distributed_table (tenant_id, dept) VALUES ('3'::text, (SELECT vals."?column?" FROM (SELECT intermediate_result."?column?" FROM read_intermediate_result('18_1'::text, 'binary'::citus_copy_format) intermediate_result("?column?" integer)) vals))
|
DEBUG: Plan 18 query after replacing subqueries and CTEs: INSERT INTO recursive_dml_queries.second_distributed_table (tenant_id, dept) VALUES ('3'::text, (SELECT vals."?column?" FROM (SELECT intermediate_result."?column?" FROM read_intermediate_result('18_1'::text, 'binary'::citus_copy_format) intermediate_result("?column?" integer)) vals))
|
||||||
ERROR: subqueries are not supported within INSERT queries
|
ERROR: subqueries are not supported within INSERT queries
|
||||||
HINT: Try rewriting your queries with 'INSERT INTO ... SELECT' syntax.
|
HINT: Try rewriting your queries with 'INSERT INTO ... SELECT' syntax.
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
second_distributed_table (tenant_id, dept)
|
second_distributed_table (tenant_id, dept)
|
||||||
VALUES ('3', (SELECT 3));
|
VALUES ('3', (SELECT 3));
|
||||||
ERROR: subqueries are not supported within INSERT queries
|
ERROR: subqueries are not supported within INSERT queries
|
||||||
HINT: Try rewriting your queries with 'INSERT INTO ... SELECT' syntax.
|
HINT: Try rewriting your queries with 'INSERT INTO ... SELECT' syntax.
|
||||||
-- DML with an unreferenced SELECT CTE
|
-- DML with an unreferenced SELECT CTE
|
||||||
WITH cte_1 AS (
|
WITH cte_1 AS (
|
||||||
WITH cte_2 AS (
|
WITH cte_2 AS (
|
||||||
SELECT tenant_id as cte2_id
|
SELECT tenant_id as cte2_id
|
||||||
FROM second_distributed_table
|
FROM second_distributed_table
|
||||||
WHERE dept >= 2
|
WHERE dept >= 2
|
||||||
)
|
)
|
||||||
|
UPDATE distributed_table
|
||||||
UPDATE distributed_table
|
|
||||||
SET dept = 10
|
SET dept = 10
|
||||||
RETURNING *
|
RETURNING *
|
||||||
)
|
)
|
||||||
|
@ -282,12 +281,11 @@ DEBUG: generating subplan 20_1 for CTE cte_1: WITH cte_2 AS (SELECT second_dist
|
||||||
DEBUG: Plan 20 query after replacing subqueries and CTEs: UPDATE recursive_dml_queries.distributed_table SET dept = 5 FROM (SELECT intermediate_result.tenant_id, intermediate_result.dept, intermediate_result.info FROM read_intermediate_result('20_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text, dept integer, info jsonb)) cte_1 WHERE (distributed_table.tenant_id OPERATOR(pg_catalog.<) cte_1.tenant_id)
|
DEBUG: Plan 20 query after replacing subqueries and CTEs: UPDATE recursive_dml_queries.distributed_table SET dept = 5 FROM (SELECT intermediate_result.tenant_id, intermediate_result.dept, intermediate_result.info FROM read_intermediate_result('20_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text, dept integer, info jsonb)) cte_1 WHERE (distributed_table.tenant_id OPERATOR(pg_catalog.<) cte_1.tenant_id)
|
||||||
WITH cte_1 AS (
|
WITH cte_1 AS (
|
||||||
WITH cte_2 AS (
|
WITH cte_2 AS (
|
||||||
SELECT tenant_id as cte2_id
|
SELECT tenant_id as cte2_id
|
||||||
FROM second_distributed_table
|
FROM second_distributed_table
|
||||||
WHERE dept >= 2
|
WHERE dept >= 2
|
||||||
)
|
)
|
||||||
|
UPDATE distributed_table
|
||||||
UPDATE distributed_table
|
|
||||||
SET dept = 10
|
SET dept = 10
|
||||||
RETURNING *
|
RETURNING *
|
||||||
)
|
)
|
||||||
|
@ -299,13 +297,13 @@ DEBUG: generating subplan 22_1 for CTE cte_1: WITH cte_2 AS (SELECT second_dist
|
||||||
DEBUG: Plan 22 query after replacing subqueries and CTEs: UPDATE recursive_dml_queries.distributed_table SET dept = 5 FROM (SELECT intermediate_result.tenant_id, intermediate_result.dept, intermediate_result.info FROM read_intermediate_result('22_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text, dept integer, info jsonb)) cte_1 WHERE (distributed_table.tenant_id OPERATOR(pg_catalog.<) cte_1.tenant_id)
|
DEBUG: Plan 22 query after replacing subqueries and CTEs: UPDATE recursive_dml_queries.distributed_table SET dept = 5 FROM (SELECT intermediate_result.tenant_id, intermediate_result.dept, intermediate_result.info FROM read_intermediate_result('22_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text, dept integer, info jsonb)) cte_1 WHERE (distributed_table.tenant_id OPERATOR(pg_catalog.<) cte_1.tenant_id)
|
||||||
-- we don't support updating local table with a join with
|
-- we don't support updating local table with a join with
|
||||||
-- distributed tables
|
-- distributed tables
|
||||||
UPDATE
|
UPDATE
|
||||||
local_table
|
local_table
|
||||||
SET
|
SET
|
||||||
id = 'citus_test'
|
id = 'citus_test'
|
||||||
FROM
|
FROM
|
||||||
distributed_table
|
distributed_table
|
||||||
WHERE
|
WHERE
|
||||||
distributed_table.tenant_id = local_table.id;
|
distributed_table.tenant_id = local_table.id;
|
||||||
ERROR: relation local_table is not distributed
|
ERROR: relation local_table is not distributed
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
-- master_disable_node and master_add_inactive_node can not be
|
-- master_disable_node and master_add_inactive_node can not be
|
||||||
-- tested as they don't create network activity
|
-- tested as they don't create network activity
|
||||||
--
|
--
|
||||||
|
|
||||||
SELECT citus.mitmproxy('conn.allow()');
|
SELECT citus.mitmproxy('conn.allow()');
|
||||||
mitmproxy
|
mitmproxy
|
||||||
-----------
|
-----------
|
||||||
|
|
|
@ -87,7 +87,6 @@ ERROR: connection error: localhost:9060
|
||||||
DETAIL: server closed the connection unexpectedly
|
DETAIL: server closed the connection unexpectedly
|
||||||
This probably means the server terminated abnormally
|
This probably means the server terminated abnormally
|
||||||
before or while processing the request.
|
before or while processing the request.
|
||||||
|
|
||||||
-- kill at the third copy (pull)
|
-- kill at the third copy (pull)
|
||||||
SELECT citus.mitmproxy('conn.onQuery(query="SELECT DISTINCT users_table.user").kill()');
|
SELECT citus.mitmproxy('conn.onQuery(query="SELECT DISTINCT users_table.user").kill()');
|
||||||
mitmproxy
|
mitmproxy
|
||||||
|
|
|
@ -29,7 +29,7 @@ SELECT create_distributed_table('second_distributed_table','key');
|
||||||
INSERT INTO reference_table VALUES (1);
|
INSERT INTO reference_table VALUES (1);
|
||||||
INSERT INTO distributed_table VALUES (1, '1', 20);
|
INSERT INTO distributed_table VALUES (1, '1', 20);
|
||||||
INSERT INTO second_distributed_table VALUES (1, '1');
|
INSERT INTO second_distributed_table VALUES (1, '1');
|
||||||
-- a simple test for
|
-- a simple test for
|
||||||
CREATE TABLE collections_list (
|
CREATE TABLE collections_list (
|
||||||
key bigserial,
|
key bigserial,
|
||||||
ser bigserial,
|
ser bigserial,
|
||||||
|
@ -44,7 +44,7 @@ SELECT create_distributed_table('collections_list', 'key');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
CREATE TABLE collections_list_0
|
CREATE TABLE collections_list_0
|
||||||
PARTITION OF collections_list (key, ser, ts, collection_id, value)
|
PARTITION OF collections_list (key, ser, ts, collection_id, value)
|
||||||
FOR VALUES IN ( 0 );
|
FOR VALUES IN ( 0 );
|
||||||
-- connection worker and get ready for the tests
|
-- connection worker and get ready for the tests
|
||||||
|
@ -54,19 +54,19 @@ SET search_path TO local_shard_execution;
|
||||||
-- on the distributed tables (e.g., WHERE key = 1), we'll hit a shard
|
-- on the distributed tables (e.g., WHERE key = 1), we'll hit a shard
|
||||||
-- placement which is local to this not
|
-- placement which is local to this not
|
||||||
CREATE OR REPLACE FUNCTION shard_of_distribution_column_is_local(dist_key int) RETURNS bool AS $$
|
CREATE OR REPLACE FUNCTION shard_of_distribution_column_is_local(dist_key int) RETURNS bool AS $$
|
||||||
|
|
||||||
DECLARE shard_is_local BOOLEAN := FALSE;
|
DECLARE shard_is_local BOOLEAN := FALSE;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
WITH local_shard_ids AS (SELECT get_shard_id_for_distribution_column('local_shard_execution.distributed_table', dist_key)),
|
WITH local_shard_ids AS (SELECT get_shard_id_for_distribution_column('local_shard_execution.distributed_table', dist_key)),
|
||||||
all_local_shard_ids_on_node AS (SELECT shardid FROM pg_dist_placement WHERE groupid IN (SELECT groupid FROM pg_dist_local_group))
|
all_local_shard_ids_on_node AS (SELECT shardid FROM pg_dist_placement WHERE groupid IN (SELECT groupid FROM pg_dist_local_group))
|
||||||
SELECT
|
SELECT
|
||||||
true INTO shard_is_local
|
true INTO shard_is_local
|
||||||
FROM
|
FROM
|
||||||
local_shard_ids
|
local_shard_ids
|
||||||
WHERE
|
WHERE
|
||||||
get_shard_id_for_distribution_column IN (SELECT * FROM all_local_shard_ids_on_node);
|
get_shard_id_for_distribution_column IN (SELECT * FROM all_local_shard_ids_on_node);
|
||||||
|
|
||||||
IF shard_is_local IS NULL THEN
|
IF shard_is_local IS NULL THEN
|
||||||
shard_is_local = FALSE;
|
shard_is_local = FALSE;
|
||||||
|
@ -76,7 +76,7 @@ CREATE OR REPLACE FUNCTION shard_of_distribution_column_is_local(dist_key int) R
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
-- pick some example values that reside on the shards locally and remote
|
-- pick some example values that reside on the shards locally and remote
|
||||||
-- distribution key values of 1,6, 500 and 701 are LOCAL to shards,
|
-- distribution key values of 1,6, 500 and 701 are LOCAL to shards,
|
||||||
-- we'll use these values in the tests
|
-- we'll use these values in the tests
|
||||||
SELECT shard_of_distribution_column_is_local(1);
|
SELECT shard_of_distribution_column_is_local(1);
|
||||||
shard_of_distribution_column_is_local
|
shard_of_distribution_column_is_local
|
||||||
|
@ -102,7 +102,7 @@ SELECT shard_of_distribution_column_is_local(701);
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- distribution key values of 11 and 12 are REMOTE to shards
|
-- distribution key values of 11 and 12 are REMOTE to shards
|
||||||
SELECT shard_of_distribution_column_is_local(11);
|
SELECT shard_of_distribution_column_is_local(11);
|
||||||
shard_of_distribution_column_is_local
|
shard_of_distribution_column_is_local
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
@ -118,7 +118,7 @@ SELECT shard_of_distribution_column_is_local(12);
|
||||||
--- enable logging to see which tasks are executed locally
|
--- enable logging to see which tasks are executed locally
|
||||||
SET client_min_messages TO LOG;
|
SET client_min_messages TO LOG;
|
||||||
SET citus.log_local_commands TO ON;
|
SET citus.log_local_commands TO ON;
|
||||||
-- first, make sure that local execution works fine
|
-- first, make sure that local execution works fine
|
||||||
-- with simple queries that are not in transcation blocks
|
-- with simple queries that are not in transcation blocks
|
||||||
SELECT count(*) FROM distributed_table WHERE key = 1;
|
SELECT count(*) FROM distributed_table WHERE key = 1;
|
||||||
LOG: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE (key OPERATOR(pg_catalog.=) 1)
|
LOG: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE (key OPERATOR(pg_catalog.=) 1)
|
||||||
|
@ -167,15 +167,15 @@ DELETE FROM second_distributed_table;
|
||||||
-- load some more data for the following tests
|
-- load some more data for the following tests
|
||||||
INSERT INTO second_distributed_table VALUES (1, '1');
|
INSERT INTO second_distributed_table VALUES (1, '1');
|
||||||
LOG: executing the command locally: INSERT INTO local_shard_execution.second_distributed_table_1470005 (key, value) VALUES (1, '1'::text)
|
LOG: executing the command locally: INSERT INTO local_shard_execution.second_distributed_table_1470005 (key, value) VALUES (1, '1'::text)
|
||||||
-- INSERT .. SELECT hitting a single single (co-located) shard(s) should
|
-- INSERT .. SELECT hitting a single single (co-located) shard(s) should
|
||||||
-- be executed locally
|
-- be executed locally
|
||||||
INSERT INTO distributed_table
|
INSERT INTO distributed_table
|
||||||
SELECT
|
SELECT
|
||||||
distributed_table.*
|
distributed_table.*
|
||||||
FROM
|
FROM
|
||||||
distributed_table, second_distributed_table
|
distributed_table, second_distributed_table
|
||||||
WHERE
|
WHERE
|
||||||
distributed_table.key = 1 and distributed_table.key=second_distributed_table.key
|
distributed_table.key = 1 and distributed_table.key=second_distributed_table.key
|
||||||
ON CONFLICT(key) DO UPDATE SET value = '22'
|
ON CONFLICT(key) DO UPDATE SET value = '22'
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
LOG: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) SELECT distributed_table.key, distributed_table.value, distributed_table.age FROM local_shard_execution.distributed_table_1470001 distributed_table, local_shard_execution.second_distributed_table_1470005 second_distributed_table WHERE (((distributed_table.key OPERATOR(pg_catalog.=) 1) AND (distributed_table.key OPERATOR(pg_catalog.=) second_distributed_table.key)) AND ((worker_hash(distributed_table.key) OPERATOR(pg_catalog.>=) '-2147483648'::integer) AND (worker_hash(distributed_table.key) OPERATOR(pg_catalog.<=) '-1073741825'::integer))) ON CONFLICT(key) DO UPDATE SET value = '22'::text RETURNING citus_table_alias.key, citus_table_alias.value, citus_table_alias.age
|
LOG: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) SELECT distributed_table.key, distributed_table.value, distributed_table.age FROM local_shard_execution.distributed_table_1470001 distributed_table, local_shard_execution.second_distributed_table_1470005 second_distributed_table WHERE (((distributed_table.key OPERATOR(pg_catalog.=) 1) AND (distributed_table.key OPERATOR(pg_catalog.=) second_distributed_table.key)) AND ((worker_hash(distributed_table.key) OPERATOR(pg_catalog.>=) '-2147483648'::integer) AND (worker_hash(distributed_table.key) OPERATOR(pg_catalog.<=) '-1073741825'::integer))) ON CONFLICT(key) DO UPDATE SET value = '22'::text RETURNING citus_table_alias.key, citus_table_alias.value, citus_table_alias.age
|
||||||
|
@ -185,13 +185,13 @@ LOG: executing the command locally: INSERT INTO local_shard_execution.distribut
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- INSERT .. SELECT hitting multi-shards should go thourgh distributed execution
|
-- INSERT .. SELECT hitting multi-shards should go thourgh distributed execution
|
||||||
INSERT INTO distributed_table
|
INSERT INTO distributed_table
|
||||||
SELECT
|
SELECT
|
||||||
distributed_table.*
|
distributed_table.*
|
||||||
FROM
|
FROM
|
||||||
distributed_table, second_distributed_table
|
distributed_table, second_distributed_table
|
||||||
WHERE
|
WHERE
|
||||||
distributed_table.key != 1 and distributed_table.key=second_distributed_table.key
|
distributed_table.key != 1 and distributed_table.key=second_distributed_table.key
|
||||||
ON CONFLICT(key) DO UPDATE SET value = '22'
|
ON CONFLICT(key) DO UPDATE SET value = '22'
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
key | value | age
|
key | value | age
|
||||||
|
@ -251,11 +251,11 @@ LOG: executing the command locally: SELECT key, value, age FROM local_shard_exe
|
||||||
COPY reference_table FROM STDIN;
|
COPY reference_table FROM STDIN;
|
||||||
COPY distributed_table FROM STDIN WITH CSV;
|
COPY distributed_table FROM STDIN WITH CSV;
|
||||||
COPY second_distributed_table FROM STDIN WITH CSV;
|
COPY second_distributed_table FROM STDIN WITH CSV;
|
||||||
-- the behaviour in transaction blocks is the following:
|
-- the behaviour in transaction blocks is the following:
|
||||||
-- (a) Unless the first query is a local query, always use distributed execution.
|
-- (a) Unless the first query is a local query, always use distributed execution.
|
||||||
-- (b) If the executor has used local execution, it has to use local execution
|
-- (b) If the executor has used local execution, it has to use local execution
|
||||||
-- for the remaining of the transaction block. If that's not possible, the
|
-- for the remaining of the transaction block. If that's not possible, the
|
||||||
-- executor has to error out (e.g., TRUNCATE is a utility command and we
|
-- executor has to error out (e.g., TRUNCATE is a utility command and we
|
||||||
-- currently do not support local execution of utility commands)
|
-- currently do not support local execution of utility commands)
|
||||||
-- rollback should be able to rollback local execution
|
-- rollback should be able to rollback local execution
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -322,14 +322,14 @@ SELECT count(*) FROM second_distributed_table;
|
||||||
-- that has done before
|
-- that has done before
|
||||||
BEGIN;
|
BEGIN;
|
||||||
-- INSERT is executed locally
|
-- INSERT is executed locally
|
||||||
INSERT INTO distributed_table VALUES (1, '11',21) ON CONFLICT(key) DO UPDATE SET value = '23' RETURNING *;
|
INSERT INTO distributed_table VALUES (1, '11',21) ON CONFLICT(key) DO UPDATE SET value = '23' RETURNING *;
|
||||||
LOG: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (1, '11'::text, 21) ON CONFLICT(key) DO UPDATE SET value = '23'::text RETURNING citus_table_alias.key, citus_table_alias.value, citus_table_alias.age
|
LOG: executing the command locally: INSERT INTO local_shard_execution.distributed_table_1470001 AS citus_table_alias (key, value, age) VALUES (1, '11'::text, 21) ON CONFLICT(key) DO UPDATE SET value = '23'::text RETURNING citus_table_alias.key, citus_table_alias.value, citus_table_alias.age
|
||||||
key | value | age
|
key | value | age
|
||||||
-----+-------+-----
|
-----+-------+-----
|
||||||
1 | 23 | 20
|
1 | 23 | 20
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- since the INSERT is executed locally, the SELECT should also be
|
-- since the INSERT is executed locally, the SELECT should also be
|
||||||
-- executed locally and see the changes
|
-- executed locally and see the changes
|
||||||
SELECT * FROM distributed_table WHERE key = 1 ORDER BY 1,2,3;
|
SELECT * FROM distributed_table WHERE key = 1 ORDER BY 1,2,3;
|
||||||
LOG: executing the command locally: SELECT key, value, age FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE (key OPERATOR(pg_catalog.=) 1) ORDER BY key, value, age
|
LOG: executing the command locally: SELECT key, value, age FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE (key OPERATOR(pg_catalog.=) 1) ORDER BY key, value, age
|
||||||
|
@ -370,7 +370,7 @@ LOG: executing the command locally: SELECT key, value, age FROM local_shard_exe
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- if we start with a distributed execution, we should keep
|
-- if we start with a distributed execution, we should keep
|
||||||
-- using that and never switch back to local execution
|
-- using that and never switch back to local execution
|
||||||
BEGIN;
|
BEGIN;
|
||||||
DELETE FROM distributed_table WHERE value = '11';
|
DELETE FROM distributed_table WHERE value = '11';
|
||||||
-- although this command could have been executed
|
-- although this command could have been executed
|
||||||
|
@ -517,8 +517,7 @@ LOG: executing the command locally: SELECT count(*) AS count FROM local_shard_e
|
||||||
0
|
0
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
INSERT INTO distributed_table (key) SELECT i FROM generate_series(1,10)i;
|
||||||
INSERT INTO distributed_table (key) SELECT i FROM generate_series(1,10)i;
|
|
||||||
ERROR: cannot execute command because a local execution has already been done in the transaction
|
ERROR: cannot execute command because a local execution has already been done in the transaction
|
||||||
DETAIL: Some parallel commands cannot be executed if a previous command has already been executed locally
|
DETAIL: Some parallel commands cannot be executed if a previous command has already been executed locally
|
||||||
HINT: Try re-running the transaction with "SET LOCAL citus.enable_local_execution TO OFF;"
|
HINT: Try re-running the transaction with "SET LOCAL citus.enable_local_execution TO OFF;"
|
||||||
|
@ -532,8 +531,7 @@ LOG: executing the command locally: SELECT count(*) AS count FROM local_shard_e
|
||||||
0
|
0
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
INSERT INTO distributed_table (key) SELECT key+1 FROM distributed_table;
|
||||||
INSERT INTO distributed_table (key) SELECT key+1 FROM distributed_table;
|
|
||||||
ERROR: cannot execute command because a local execution has already been done in the transaction
|
ERROR: cannot execute command because a local execution has already been done in the transaction
|
||||||
DETAIL: Some parallel commands cannot be executed if a previous command has already been executed locally
|
DETAIL: Some parallel commands cannot be executed if a previous command has already been executed locally
|
||||||
HINT: Try re-running the transaction with "SET LOCAL citus.enable_local_execution TO OFF;"
|
HINT: Try re-running the transaction with "SET LOCAL citus.enable_local_execution TO OFF;"
|
||||||
|
@ -584,7 +582,7 @@ CREATE OR REPLACE PROCEDURE only_local_execution() AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO distributed_table VALUES (1, '11',21) ON CONFLICT(key) DO UPDATE SET value = '29';
|
INSERT INTO distributed_table VALUES (1, '11',21) ON CONFLICT(key) DO UPDATE SET value = '29';
|
||||||
SELECT count(*) INTO cnt FROM distributed_table WHERE key = 1;
|
SELECT count(*) INTO cnt FROM distributed_table WHERE key = 1;
|
||||||
DELETE FROM distributed_table WHERE key = 1;
|
DELETE FROM distributed_table WHERE key = 1;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
CALL only_local_execution();
|
CALL only_local_execution();
|
||||||
|
@ -666,11 +664,11 @@ SELECT * FROM local_insert, distributed_local_mixed ORDER BY 1,2,3,4,5;
|
||||||
|
|
||||||
-- router CTE pushdown
|
-- router CTE pushdown
|
||||||
WITH all_data AS (SELECT * FROM distributed_table WHERE key = 1)
|
WITH all_data AS (SELECT * FROM distributed_table WHERE key = 1)
|
||||||
SELECT
|
SELECT
|
||||||
count(*)
|
count(*)
|
||||||
FROM
|
FROM
|
||||||
distributed_table, all_data
|
distributed_table, all_data
|
||||||
WHERE
|
WHERE
|
||||||
distributed_table.key = all_data.key AND distributed_table.key = 1;
|
distributed_table.key = all_data.key AND distributed_table.key = 1;
|
||||||
LOG: executing the command locally: WITH all_data AS (SELECT distributed_table_1.key, distributed_table_1.value, distributed_table_1.age FROM local_shard_execution.distributed_table_1470001 distributed_table_1 WHERE (distributed_table_1.key OPERATOR(pg_catalog.=) 1)) SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470001 distributed_table, all_data WHERE ((distributed_table.key OPERATOR(pg_catalog.=) all_data.key) AND (distributed_table.key OPERATOR(pg_catalog.=) 1))
|
LOG: executing the command locally: WITH all_data AS (SELECT distributed_table_1.key, distributed_table_1.value, distributed_table_1.age FROM local_shard_execution.distributed_table_1470001 distributed_table_1 WHERE (distributed_table_1.key OPERATOR(pg_catalog.=) 1)) SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470001 distributed_table, all_data WHERE ((distributed_table.key OPERATOR(pg_catalog.=) all_data.key) AND (distributed_table.key OPERATOR(pg_catalog.=) 1))
|
||||||
count
|
count
|
||||||
|
@ -684,13 +682,13 @@ INSERT INTO distributed_table VALUES (2, '29', 29);
|
||||||
INSERT INTO second_distributed_table VALUES (2, '29');
|
INSERT INTO second_distributed_table VALUES (2, '29');
|
||||||
-- single shard that is not a local query followed by a local query
|
-- single shard that is not a local query followed by a local query
|
||||||
WITH all_data AS (SELECT * FROM second_distributed_table WHERE key = 2)
|
WITH all_data AS (SELECT * FROM second_distributed_table WHERE key = 2)
|
||||||
SELECT
|
SELECT
|
||||||
distributed_table.key
|
distributed_table.key
|
||||||
FROM
|
FROM
|
||||||
distributed_table, all_data
|
distributed_table, all_data
|
||||||
WHERE
|
WHERE
|
||||||
distributed_table.value = all_data.value AND distributed_table.key = 1
|
distributed_table.value = all_data.value AND distributed_table.key = 1
|
||||||
ORDER BY
|
ORDER BY
|
||||||
1 DESC;
|
1 DESC;
|
||||||
key
|
key
|
||||||
-----
|
-----
|
||||||
|
@ -699,15 +697,15 @@ ORDER BY
|
||||||
|
|
||||||
-- multi-shard CTE is followed by a query which could be executed locally, but
|
-- multi-shard CTE is followed by a query which could be executed locally, but
|
||||||
-- since the query started with a parallel query, it doesn't use local execution
|
-- since the query started with a parallel query, it doesn't use local execution
|
||||||
-- note that if we allow Postgres to inline the CTE (e.g., not have the EXISTS
|
-- note that if we allow Postgres to inline the CTE (e.g., not have the EXISTS
|
||||||
-- subquery), then it'd pushdown the filters and the query becomes single-shard,
|
-- subquery), then it'd pushdown the filters and the query becomes single-shard,
|
||||||
-- locally executable query
|
-- locally executable query
|
||||||
WITH all_data AS (SELECT * FROM distributed_table)
|
WITH all_data AS (SELECT * FROM distributed_table)
|
||||||
SELECT
|
SELECT
|
||||||
count(*)
|
count(*)
|
||||||
FROM
|
FROM
|
||||||
distributed_table, all_data
|
distributed_table, all_data
|
||||||
WHERE
|
WHERE
|
||||||
distributed_table.key = all_data.key AND distributed_table.key = 1
|
distributed_table.key = all_data.key AND distributed_table.key = 1
|
||||||
AND EXISTS (SELECT * FROM all_data);
|
AND EXISTS (SELECT * FROM all_data);
|
||||||
count
|
count
|
||||||
|
@ -719,11 +717,11 @@ WHERE
|
||||||
-- a subquery that needs to be recursively planned and a parallel
|
-- a subquery that needs to be recursively planned and a parallel
|
||||||
-- query, so do not use local execution
|
-- query, so do not use local execution
|
||||||
WITH all_data AS (SELECT age FROM distributed_table)
|
WITH all_data AS (SELECT age FROM distributed_table)
|
||||||
SELECT
|
SELECT
|
||||||
count(*)
|
count(*)
|
||||||
FROM
|
FROM
|
||||||
distributed_table, all_data
|
distributed_table, all_data
|
||||||
WHERE
|
WHERE
|
||||||
distributed_table.key = all_data.age AND distributed_table.key = 1;
|
distributed_table.key = all_data.age AND distributed_table.key = 1;
|
||||||
count
|
count
|
||||||
-------
|
-------
|
||||||
|
@ -754,7 +752,7 @@ LOG: executing the command locally: INSERT INTO local_shard_execution.distribut
|
||||||
5 | 55 | 22
|
5 | 55 | 22
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
-- distributed execution of multi-rows INSERTs, where some part of the execution
|
-- distributed execution of multi-rows INSERTs, where some part of the execution
|
||||||
-- could have been done via local execution but the executor choose the other way around
|
-- could have been done via local execution but the executor choose the other way around
|
||||||
-- because the command is a multi-shard query
|
-- because the command is a multi-shard query
|
||||||
INSERT INTO distributed_table VALUES (1, '11',21), (2,'22',22), (3,'33',33), (4,'44',44),(5,'55',55) ON CONFLICT(key) DO UPDATE SET value = (EXCLUDED.value::int + 1)::text RETURNING *;
|
INSERT INTO distributed_table VALUES (1, '11',21), (2,'22',22), (3,'33',33), (4,'44',44),(5,'55',55) ON CONFLICT(key) DO UPDATE SET value = (EXCLUDED.value::int + 1)::text RETURNING *;
|
||||||
|
@ -866,8 +864,8 @@ LOG: executing the command locally: SELECT count(*) AS count FROM local_shard_e
|
||||||
4
|
4
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
-- failures of local execution should rollback both the
|
-- failures of local execution should rollback both the
|
||||||
-- local execution and remote executions
|
-- local execution and remote executions
|
||||||
-- fail on a local execution
|
-- fail on a local execution
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
@ -948,7 +946,6 @@ LOG: executing the command locally: DELETE FROM local_shard_execution.distribut
|
||||||
LOG: executing the command locally: DELETE FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE (value OPERATOR(pg_catalog.<>) '123123213123213'::text)
|
LOG: executing the command locally: DELETE FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE (value OPERATOR(pg_catalog.<>) '123123213123213'::text)
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
DELETE FROM reference_table WHERE key = 500 RETURNING *;
|
DELETE FROM reference_table WHERE key = 500 RETURNING *;
|
||||||
LOG: executing the command locally: DELETE FROM local_shard_execution.reference_table_1470000 reference_table WHERE (key OPERATOR(pg_catalog.=) 500) RETURNING key
|
LOG: executing the command locally: DELETE FROM local_shard_execution.reference_table_1470000 reference_table WHERE (key OPERATOR(pg_catalog.=) 500) RETURNING key
|
||||||
key
|
key
|
||||||
|
@ -985,7 +982,7 @@ BEGIN;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- probably not a realistic case since views are not very
|
-- probably not a realistic case since views are not very
|
||||||
-- well supported with MX
|
-- well supported with MX
|
||||||
CREATE VIEW v_local_query_execution AS
|
CREATE VIEW v_local_query_execution AS
|
||||||
SELECT * FROM distributed_table WHERE key = 500;
|
SELECT * FROM distributed_table WHERE key = 500;
|
||||||
SELECT * FROM v_local_query_execution;
|
SELECT * FROM v_local_query_execution;
|
||||||
LOG: executing the command locally: SELECT key, value, age FROM (SELECT distributed_table.key, distributed_table.value, distributed_table.age FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE (distributed_table.key OPERATOR(pg_catalog.=) 500)) v_local_query_execution
|
LOG: executing the command locally: SELECT key, value, age FROM (SELECT distributed_table.key, distributed_table.value, distributed_table.age FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE (distributed_table.key OPERATOR(pg_catalog.=) 500)) v_local_query_execution
|
||||||
|
@ -996,7 +993,7 @@ LOG: executing the command locally: SELECT key, value, age FROM (SELECT distrib
|
||||||
|
|
||||||
-- similar test, but this time the view itself is a non-local
|
-- similar test, but this time the view itself is a non-local
|
||||||
-- query, but the query on the view is local
|
-- query, but the query on the view is local
|
||||||
CREATE VIEW v_local_query_execution_2 AS
|
CREATE VIEW v_local_query_execution_2 AS
|
||||||
SELECT * FROM distributed_table;
|
SELECT * FROM distributed_table;
|
||||||
SELECT * FROM v_local_query_execution_2 WHERE key = 500;
|
SELECT * FROM v_local_query_execution_2 WHERE key = 500;
|
||||||
LOG: executing the command locally: SELECT key, value, age FROM (SELECT distributed_table.key, distributed_table.value, distributed_table.age FROM local_shard_execution.distributed_table_1470003 distributed_table) v_local_query_execution_2 WHERE (key OPERATOR(pg_catalog.=) 500)
|
LOG: executing the command locally: SELECT key, value, age FROM (SELECT distributed_table.key, distributed_table.value, distributed_table.age FROM local_shard_execution.distributed_table_1470003 distributed_table) v_local_query_execution_2 WHERE (key OPERATOR(pg_catalog.=) 500)
|
||||||
|
@ -1016,19 +1013,15 @@ BEGIN;
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
DELETE FROM distributed_table WHERE key = 500;
|
DELETE FROM distributed_table WHERE key = 500;
|
||||||
|
|
||||||
ROLLBACK TO SAVEPOINT my_savepoint;
|
ROLLBACK TO SAVEPOINT my_savepoint;
|
||||||
|
|
||||||
DELETE FROM distributed_table WHERE key = 500;
|
DELETE FROM distributed_table WHERE key = 500;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
-- even if we switch from local execution -> remote execution,
|
-- even if we switch from local execution -> remote execution,
|
||||||
-- we are able to use local execution after rollback
|
-- we are able to use local execution after rollback
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
SAVEPOINT my_savepoint;
|
SAVEPOINT my_savepoint;
|
||||||
DELETE FROM distributed_table WHERE key = 500;
|
DELETE FROM distributed_table WHERE key = 500;
|
||||||
LOG: executing the command locally: DELETE FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE (key OPERATOR(pg_catalog.=) 500)
|
LOG: executing the command locally: DELETE FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE (key OPERATOR(pg_catalog.=) 500)
|
||||||
|
|
||||||
SELECT count(*) FROM distributed_table;
|
SELECT count(*) FROM distributed_table;
|
||||||
LOG: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE true
|
LOG: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470001 distributed_table WHERE true
|
||||||
LOG: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE true
|
LOG: executing the command locally: SELECT count(*) AS count FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE true
|
||||||
|
@ -1038,7 +1031,6 @@ LOG: executing the command locally: SELECT count(*) AS count FROM local_shard_e
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
ROLLBACK TO SAVEPOINT my_savepoint;
|
ROLLBACK TO SAVEPOINT my_savepoint;
|
||||||
|
|
||||||
DELETE FROM distributed_table WHERE key = 500;
|
DELETE FROM distributed_table WHERE key = 500;
|
||||||
LOG: executing the command locally: DELETE FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE (key OPERATOR(pg_catalog.=) 500)
|
LOG: executing the command locally: DELETE FROM local_shard_execution.distributed_table_1470003 distributed_table WHERE (key OPERATOR(pg_catalog.=) 500)
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
@ -1079,7 +1071,7 @@ LOG: executing the command locally: SELECT key, ser, ts, collection_id, value F
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
-- the final queries for the following CTEs are going to happen on the intermediate results only
|
-- the final queries for the following CTEs are going to happen on the intermediate results only
|
||||||
-- one of them will be executed remotely, and the other is locally
|
-- one of them will be executed remotely, and the other is locally
|
||||||
-- Citus currently doesn't allow using task_assignment_policy for intermediate results
|
-- Citus currently doesn't allow using task_assignment_policy for intermediate results
|
||||||
WITH distributed_local_mixed AS (INSERT INTO reference_table VALUES (1000) RETURNING *) SELECT * FROM distributed_local_mixed;
|
WITH distributed_local_mixed AS (INSERT INTO reference_table VALUES (1000) RETURNING *) SELECT * FROM distributed_local_mixed;
|
||||||
LOG: executing the command locally: INSERT INTO local_shard_execution.reference_table_1470000 (key) VALUES (1000) RETURNING key
|
LOG: executing the command locally: INSERT INTO local_shard_execution.reference_table_1470000 (key) VALUES (1000) RETURNING key
|
||||||
|
@ -1131,10 +1123,10 @@ LOG: executing the command locally: DELETE FROM local_shard_execution.reference
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
-- local execution with custom type
|
-- local execution with custom type
|
||||||
SET citus.replication_model TO "streaming";
|
SET citus.replication_model TO "streaming";
|
||||||
SET citus.shard_replication_factor TO 1;
|
SET citus.shard_replication_factor TO 1;
|
||||||
CREATE TYPE invite_resp AS ENUM ('yes', 'no', 'maybe');
|
CREATE TYPE invite_resp AS ENUM ('yes', 'no', 'maybe');
|
||||||
CREATE TABLE event_responses (
|
CREATE TABLE event_responses (
|
||||||
event_id int,
|
event_id int,
|
||||||
user_id int,
|
user_id int,
|
||||||
|
|
|
@ -58,7 +58,7 @@ FROM (
|
||||||
AND e.event_type IN (3, 4)
|
AND e.event_type IN (3, 4)
|
||||||
)
|
)
|
||||||
) t1 LEFT JOIN (
|
) t1 LEFT JOIN (
|
||||||
SELECT DISTINCT user_id,
|
SELECT DISTINCT user_id,
|
||||||
'Has done event'::TEXT AS hasdone_event
|
'Has done event'::TEXT AS hasdone_event
|
||||||
FROM events_table AS e
|
FROM events_table AS e
|
||||||
WHERE e.user_id >= 1
|
WHERE e.user_id >= 1
|
||||||
|
@ -127,7 +127,7 @@ SELECT
|
||||||
users_table
|
users_table
|
||||||
WHERE
|
WHERE
|
||||||
user_id >= 1 AND
|
user_id >= 1 AND
|
||||||
user_id <= 3 AND
|
user_id <= 3 AND
|
||||||
users_table.value_1 > 3 AND users_table.value_1 < 5
|
users_table.value_1 > 3 AND users_table.value_1 < 5
|
||||||
GROUP BY
|
GROUP BY
|
||||||
user_id
|
user_id
|
||||||
|
@ -170,7 +170,6 @@ FROM (
|
||||||
max(u.time) as user_lastseen,
|
max(u.time) as user_lastseen,
|
||||||
array_agg(event_type ORDER BY u.time) AS event_array
|
array_agg(event_type ORDER BY u.time) AS event_array
|
||||||
FROM (
|
FROM (
|
||||||
|
|
||||||
SELECT user_id, time
|
SELECT user_id, time
|
||||||
FROM users_table
|
FROM users_table
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -205,9 +204,8 @@ FROM users_table
|
||||||
WHERE user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 1 AND value_1 <= 2)
|
WHERE user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 1 AND value_1 <= 2)
|
||||||
AND user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 3 AND value_1 <= 4)
|
AND user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 3 AND value_1 <= 4)
|
||||||
AND user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 5 AND value_1 <= 6);
|
AND user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 5 AND value_1 <= 6);
|
||||||
|
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
count | count | avg
|
count | count | avg
|
||||||
-------+-------+--------------------
|
-------+-------+--------------------
|
||||||
5 | 5 | 3.8000000000000000
|
5 | 5 | 3.8000000000000000
|
||||||
|
@ -300,7 +298,6 @@ SELECT user_id, value_2 FROM users_table WHERE
|
||||||
value_2 >= 3
|
value_2 >= 3
|
||||||
AND EXISTS (SELECT user_id FROM events_table WHERE event_type > 1 AND event_type <= 3 AND value_3 > 1 AND user_id=users_table.user_id)
|
AND EXISTS (SELECT user_id FROM events_table WHERE event_type > 1 AND event_type <= 3 AND value_3 > 1 AND user_id=users_table.user_id)
|
||||||
AND NOT EXISTS (SELECT user_id FROM events_table WHERE event_type > 3 AND event_type <= 4 AND value_3 > 1 AND user_id=users_table.user_id);
|
AND NOT EXISTS (SELECT user_id FROM events_table WHERE event_type > 3 AND event_type <= 4 AND value_3 > 1 AND user_id=users_table.user_id);
|
||||||
|
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
count | count | avg
|
count | count | avg
|
||||||
|
@ -315,21 +312,20 @@ SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
------------------------------------
|
------------------------------------
|
||||||
TRUNCATE agg_results;
|
TRUNCATE agg_results;
|
||||||
INSERT INTO agg_results(user_id, value_2_agg)
|
INSERT INTO agg_results(user_id, value_2_agg)
|
||||||
SELECT user_id,
|
SELECT user_id,
|
||||||
value_2
|
value_2
|
||||||
FROM users_table
|
FROM users_table
|
||||||
WHERE value_1 > 1
|
WHERE value_1 > 1
|
||||||
AND value_1 < 3
|
AND value_1 < 3
|
||||||
AND value_2 >= 1
|
AND value_2 >= 1
|
||||||
AND EXISTS (SELECT user_id
|
AND EXISTS (SELECT user_id
|
||||||
FROM events_table
|
FROM events_table
|
||||||
WHERE event_type > 1
|
WHERE event_type > 1
|
||||||
AND event_type < 3
|
AND event_type < 3
|
||||||
AND value_3 > 1
|
AND value_3 > 1
|
||||||
AND user_id = users_table.user_id
|
AND user_id = users_table.user_id
|
||||||
GROUP BY user_id
|
GROUP BY user_id
|
||||||
HAVING Count(*) > 2);
|
HAVING Count(*) > 2);
|
||||||
|
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
count | count | avg
|
count | count | avg
|
||||||
|
@ -337,7 +333,6 @@ SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
4 | 2 | 3.5000000000000000
|
4 | 2 | 3.5000000000000000
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
------------------------------------
|
------------------------------------
|
||||||
------------------------------------
|
------------------------------------
|
||||||
-- Find me all users_table who logged in more than once
|
-- Find me all users_table who logged in more than once
|
||||||
|
@ -348,7 +343,7 @@ INSERT INTO agg_results(user_id, value_1_agg)
|
||||||
SELECT user_id, value_1 from
|
SELECT user_id, value_1 from
|
||||||
(
|
(
|
||||||
SELECT user_id, value_1 From users_table
|
SELECT user_id, value_1 From users_table
|
||||||
WHERE value_2 > 1 and user_id = 1 GROUP BY value_1, user_id HAVING count(*) > 1
|
WHERE value_2 > 1 and user_id = 1 GROUP BY value_1, user_id HAVING count(*) > 1
|
||||||
) as a;
|
) as a;
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
|
@ -372,8 +367,7 @@ And user_id in
|
||||||
(select user_id
|
(select user_id
|
||||||
From users_table
|
From users_table
|
||||||
Where value_1 = 2
|
Where value_1 = 2
|
||||||
And value_2 > 1);
|
And value_2 > 1);
|
||||||
|
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
count | count | avg
|
count | count | avg
|
||||||
|
@ -398,23 +392,21 @@ SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
34 | 6 | 3.4411764705882353
|
34 | 6 | 3.4411764705882353
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
------------------------------------
|
------------------------------------
|
||||||
------------------------------------
|
------------------------------------
|
||||||
-- Find me all the users_table who has done some event more than three times
|
-- Find me all the users_table who has done some event more than three times
|
||||||
------------------------------------
|
------------------------------------
|
||||||
------------------------------------
|
------------------------------------
|
||||||
TRUNCATE agg_results;
|
TRUNCATE agg_results;
|
||||||
INSERT INTO agg_results(user_id)
|
INSERT INTO agg_results(user_id)
|
||||||
select user_id from
|
select user_id from
|
||||||
(
|
(
|
||||||
select
|
select
|
||||||
user_id
|
user_id
|
||||||
from
|
from
|
||||||
events_table
|
events_table
|
||||||
where event_type = 4 group by user_id having count(*) > 3
|
where event_type = 4 group by user_id having count(*) > 3
|
||||||
) as a;
|
) as a;
|
||||||
|
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
count | count | avg
|
count | count | avg
|
||||||
|
@ -422,7 +414,6 @@ SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
4 | 4 | 2.5000000000000000
|
4 | 4 | 2.5000000000000000
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
------------------------------------
|
------------------------------------
|
||||||
------------------------------------
|
------------------------------------
|
||||||
-- Find my assets that have the highest probability and fetch their metadata
|
-- Find my assets that have the highest probability and fetch their metadata
|
||||||
|
@ -432,17 +423,17 @@ TRUNCATE agg_results;
|
||||||
INSERT INTO agg_results(user_id, value_1_agg, value_3_agg)
|
INSERT INTO agg_results(user_id, value_1_agg, value_3_agg)
|
||||||
SELECT
|
SELECT
|
||||||
users_table.user_id, users_table.value_1, prob
|
users_table.user_id, users_table.value_1, prob
|
||||||
FROM
|
FROM
|
||||||
users_table
|
users_table
|
||||||
JOIN
|
JOIN
|
||||||
(SELECT
|
(SELECT
|
||||||
ma.user_id, (GREATEST(coalesce(ma.value_4, 0.0) / 250 + GREATEST(1.0))) / 2 AS prob
|
ma.user_id, (GREATEST(coalesce(ma.value_4, 0.0) / 250 + GREATEST(1.0))) / 2 AS prob
|
||||||
FROM
|
FROM
|
||||||
users_table AS ma, events_table as short_list
|
users_table AS ma, events_table as short_list
|
||||||
WHERE
|
WHERE
|
||||||
short_list.user_id = ma.user_id and ma.value_1 < 3 and short_list.event_type < 3
|
short_list.user_id = ma.user_id and ma.value_1 < 3 and short_list.event_type < 3
|
||||||
) temp
|
) temp
|
||||||
ON users_table.user_id = temp.user_id
|
ON users_table.user_id = temp.user_id
|
||||||
WHERE users_table.value_1 < 3;
|
WHERE users_table.value_1 < 3;
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
|
@ -456,17 +447,17 @@ TRUNCATE agg_results;
|
||||||
INSERT INTO agg_results(user_id)
|
INSERT INTO agg_results(user_id)
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT users_ids.user_id
|
DISTINCT users_ids.user_id
|
||||||
FROM
|
FROM
|
||||||
(SELECT DISTINCT user_id FROM users_table) as users_ids
|
(SELECT DISTINCT user_id FROM users_table) as users_ids
|
||||||
JOIN
|
JOIN
|
||||||
(SELECT
|
(SELECT
|
||||||
ma.user_id, ma.value_1, (GREATEST(coalesce(ma.value_4 / 250, 0.0) + GREATEST(1.0))) / 2 AS prob
|
ma.user_id, ma.value_1, (GREATEST(coalesce(ma.value_4 / 250, 0.0) + GREATEST(1.0))) / 2 AS prob
|
||||||
FROM
|
FROM
|
||||||
users_table AS ma, events_table as short_list
|
users_table AS ma, events_table as short_list
|
||||||
WHERE
|
WHERE
|
||||||
short_list.user_id = ma.user_id and ma.value_1 < 3 and short_list.event_type < 2
|
short_list.user_id = ma.user_id and ma.value_1 < 3 and short_list.event_type < 2
|
||||||
) temp
|
) temp
|
||||||
ON users_ids.user_id = temp.user_id
|
ON users_ids.user_id = temp.user_id
|
||||||
WHERE temp.value_1 < 3;
|
WHERE temp.value_1 < 3;
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results;
|
||||||
|
@ -480,17 +471,17 @@ TRUNCATE agg_results;
|
||||||
INSERT INTO agg_results(user_id, value_1_agg, value_2_agg)
|
INSERT INTO agg_results(user_id, value_1_agg, value_2_agg)
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT ON (users_ids.user_id) users_ids.user_id, temp.value_1, prob
|
DISTINCT ON (users_ids.user_id) users_ids.user_id, temp.value_1, prob
|
||||||
FROM
|
FROM
|
||||||
(SELECT DISTINCT user_id FROM users_table) as users_ids
|
(SELECT DISTINCT user_id FROM users_table) as users_ids
|
||||||
JOIN
|
JOIN
|
||||||
(SELECT
|
(SELECT
|
||||||
ma.user_id, ma.value_1, (GREATEST(coalesce(ma.value_4 / 250, 0.0) + GREATEST(1.0))) / 2 AS prob
|
ma.user_id, ma.value_1, (GREATEST(coalesce(ma.value_4 / 250, 0.0) + GREATEST(1.0))) / 2 AS prob
|
||||||
FROM
|
FROM
|
||||||
users_table AS ma, events_table as short_list
|
users_table AS ma, events_table as short_list
|
||||||
WHERE
|
WHERE
|
||||||
short_list.user_id = ma.user_id and ma.value_1 < 3 and short_list.event_type < 2
|
short_list.user_id = ma.user_id and ma.value_1 < 3 and short_list.event_type < 2
|
||||||
) temp
|
) temp
|
||||||
ON users_ids.user_id = temp.user_id
|
ON users_ids.user_id = temp.user_id
|
||||||
WHERE temp.value_1 < 3
|
WHERE temp.value_1 < 3
|
||||||
ORDER BY 1, 2;
|
ORDER BY 1, 2;
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id), avg(value_1_agg) FROM agg_results;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id), avg(value_1_agg) FROM agg_results;
|
||||||
|
@ -504,16 +495,16 @@ TRUNCATE agg_results;
|
||||||
INSERT INTO agg_results(user_id, value_1_agg, value_2_agg)
|
INSERT INTO agg_results(user_id, value_1_agg, value_2_agg)
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT ON (users_ids.user_id) users_ids.user_id, temp.value_1, prob
|
DISTINCT ON (users_ids.user_id) users_ids.user_id, temp.value_1, prob
|
||||||
FROM
|
FROM
|
||||||
(SELECT DISTINCT ON (user_id) user_id, value_2 FROM users_table ORDER BY 1,2) as users_ids
|
(SELECT DISTINCT ON (user_id) user_id, value_2 FROM users_table ORDER BY 1,2) as users_ids
|
||||||
JOIN
|
JOIN
|
||||||
(SELECT
|
(SELECT
|
||||||
ma.user_id, ma.value_1, (GREATEST(coalesce(ma.value_4 / 250, 0.0) + GREATEST(1.0))) / 2 AS prob
|
ma.user_id, ma.value_1, (GREATEST(coalesce(ma.value_4 / 250, 0.0) + GREATEST(1.0))) / 2 AS prob
|
||||||
FROM
|
FROM
|
||||||
users_table AS ma, events_table as short_list
|
users_table AS ma, events_table as short_list
|
||||||
WHERE
|
WHERE
|
||||||
short_list.user_id = ma.user_id and ma.value_1 < 10 and short_list.event_type < 2
|
short_list.user_id = ma.user_id and ma.value_1 < 10 and short_list.event_type < 2
|
||||||
) temp
|
) temp
|
||||||
ON users_ids.user_id = temp.user_id
|
ON users_ids.user_id = temp.user_id
|
||||||
ORDER BY 1, 2;
|
ORDER BY 1, 2;
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id), avg(value_1_agg) FROM agg_results;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id), avg(value_1_agg) FROM agg_results;
|
||||||
|
|
|
@ -41,8 +41,8 @@ FROM (
|
||||||
SELECT u.user_id, e.event_type::text AS event, e.time
|
SELECT u.user_id, e.event_type::text AS event, e.time
|
||||||
FROM users_table AS u,
|
FROM users_table AS u,
|
||||||
events_table AS e
|
events_table AS e
|
||||||
WHERE u.user_id = e.user_id AND
|
WHERE u.user_id = e.user_id AND
|
||||||
(u.user_id = 1 OR u.user_id = 2) AND
|
(u.user_id = 1 OR u.user_id = 2) AND
|
||||||
(e.user_id = 1 OR e.user_id = 2)
|
(e.user_id = 1 OR e.user_id = 2)
|
||||||
AND e.event_type IN (1, 2)
|
AND e.event_type IN (1, 2)
|
||||||
) t
|
) t
|
||||||
|
@ -90,10 +90,9 @@ FROM (
|
||||||
AND e.event_type IN (3, 4)
|
AND e.event_type IN (3, 4)
|
||||||
)
|
)
|
||||||
) t1 LEFT JOIN (
|
) t1 LEFT JOIN (
|
||||||
SELECT DISTINCT user_id,
|
SELECT DISTINCT user_id,
|
||||||
'Has done event'::TEXT AS hasdone_event
|
'Has done event'::TEXT AS hasdone_event
|
||||||
FROM events_table AS e
|
FROM events_table AS e
|
||||||
|
|
||||||
WHERE e.user_id >= 1
|
WHERE e.user_id >= 1
|
||||||
AND e.user_id <= 2
|
AND e.user_id <= 2
|
||||||
AND e.event_type IN (5, 6)
|
AND e.event_type IN (5, 6)
|
||||||
|
@ -133,11 +132,10 @@ FROM (
|
||||||
AND e.event_type IN (3, 4)
|
AND e.event_type IN (3, 4)
|
||||||
)
|
)
|
||||||
) t1 LEFT JOIN (
|
) t1 LEFT JOIN (
|
||||||
SELECT DISTINCT user_id,
|
SELECT DISTINCT user_id,
|
||||||
'Has done event'::TEXT AS hasdone_event
|
'Has done event'::TEXT AS hasdone_event
|
||||||
FROM events_table AS e
|
FROM events_table AS e
|
||||||
|
WHERE
|
||||||
WHERE
|
|
||||||
(e.user_id = 2 OR e.user_id = 3)
|
(e.user_id = 2 OR e.user_id = 3)
|
||||||
AND e.event_type IN (4, 5)
|
AND e.event_type IN (4, 5)
|
||||||
) t2 ON (t1.user_id = t2.user_id)
|
) t2 ON (t1.user_id = t2.user_id)
|
||||||
|
@ -170,7 +168,6 @@ FROM (
|
||||||
max(u.time) as user_lastseen,
|
max(u.time) as user_lastseen,
|
||||||
array_agg(event_type ORDER BY u.time) AS event_array
|
array_agg(event_type ORDER BY u.time) AS event_array
|
||||||
FROM (
|
FROM (
|
||||||
|
|
||||||
SELECT user_id, time
|
SELECT user_id, time
|
||||||
FROM users_table
|
FROM users_table
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -213,7 +210,6 @@ FROM (
|
||||||
max(u.time) as user_lastseen,
|
max(u.time) as user_lastseen,
|
||||||
array_agg(event_type ORDER BY u.time) AS event_array
|
array_agg(event_type ORDER BY u.time) AS event_array
|
||||||
FROM (
|
FROM (
|
||||||
|
|
||||||
SELECT user_id, time
|
SELECT user_id, time
|
||||||
FROM users_table
|
FROM users_table
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -251,9 +247,8 @@ WHERE user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 1 AND value_1
|
||||||
AND user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 3 AND value_1 <= 4)
|
AND user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 3 AND value_1 <= 4)
|
||||||
AND user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 5 AND value_1 <= 6)
|
AND user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 5 AND value_1 <= 6)
|
||||||
AND user_id = 1;
|
AND user_id = 1;
|
||||||
|
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
||||||
count | count | avg
|
count | count | avg
|
||||||
-------+-------+------------------------
|
-------+-------+------------------------
|
||||||
1 | 1 | 1.00000000000000000000
|
1 | 1 | 1.00000000000000000000
|
||||||
|
@ -272,9 +267,8 @@ WHERE user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 1 AND value_1
|
||||||
AND user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 3 AND value_1 <= 4 AND (user_id = 1 OR user_id = 2))
|
AND user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 3 AND value_1 <= 4 AND (user_id = 1 OR user_id = 2))
|
||||||
AND user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 5 AND value_1 <= 6 AND (user_id = 1 OR user_id = 2))
|
AND user_id IN (SELECT user_id FROM users_table WHERE value_1 >= 5 AND value_1 <= 6 AND (user_id = 1 OR user_id = 2))
|
||||||
AND (user_id = 1 OR user_id = 2);
|
AND (user_id = 1 OR user_id = 2);
|
||||||
|
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
||||||
count | count | avg
|
count | count | avg
|
||||||
-------+-------+------------------------
|
-------+-------+------------------------
|
||||||
1 | 1 | 1.00000000000000000000
|
1 | 1 | 1.00000000000000000000
|
||||||
|
@ -330,7 +324,6 @@ SELECT user_id, value_2 FROM users_table WHERE
|
||||||
AND user_id = 1
|
AND user_id = 1
|
||||||
AND EXISTS (SELECT user_id FROM events_table WHERE event_type > 1 AND event_type <= 3 AND value_3 > 1 AND user_id=users_table.user_id)
|
AND EXISTS (SELECT user_id FROM events_table WHERE event_type > 1 AND event_type <= 3 AND value_3 > 1 AND user_id=users_table.user_id)
|
||||||
AND NOT EXISTS (SELECT user_id FROM events_table WHERE event_type > 4 AND event_type <= 5 AND value_3 > 4 AND user_id=users_table.user_id);
|
AND NOT EXISTS (SELECT user_id FROM events_table WHERE event_type > 4 AND event_type <= 5 AND value_3 > 4 AND user_id=users_table.user_id);
|
||||||
|
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
||||||
count | count | avg
|
count | count | avg
|
||||||
|
@ -350,7 +343,6 @@ SELECT user_id, value_2 FROM users_table WHERE
|
||||||
AND (user_id = 1 OR user_id = 2)
|
AND (user_id = 1 OR user_id = 2)
|
||||||
AND EXISTS (SELECT user_id FROM events_table WHERE event_type > 1 AND event_type <= 3 AND value_3 > 1 AND user_id=users_table.user_id AND (user_id = 1 OR user_id = 2))
|
AND EXISTS (SELECT user_id FROM events_table WHERE event_type > 1 AND event_type <= 3 AND value_3 > 1 AND user_id=users_table.user_id AND (user_id = 1 OR user_id = 2))
|
||||||
AND NOT EXISTS (SELECT user_id FROM events_table WHERE event_type > 4 AND event_type <= 5 AND value_3 > 4 AND user_id=users_table.user_id AND (user_id = 1 OR user_id = 2));
|
AND NOT EXISTS (SELECT user_id FROM events_table WHERE event_type > 4 AND event_type <= 5 AND value_3 > 4 AND user_id=users_table.user_id AND (user_id = 1 OR user_id = 2));
|
||||||
|
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
||||||
count | count | avg
|
count | count | avg
|
||||||
|
@ -365,23 +357,22 @@ SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
||||||
------------------------------------
|
------------------------------------
|
||||||
TRUNCATE agg_results_second;
|
TRUNCATE agg_results_second;
|
||||||
INSERT INTO agg_results_second(user_id, value_2_agg)
|
INSERT INTO agg_results_second(user_id, value_2_agg)
|
||||||
SELECT user_id,
|
SELECT user_id,
|
||||||
value_2
|
value_2
|
||||||
FROM users_table
|
FROM users_table
|
||||||
WHERE value_1 > 1
|
WHERE value_1 > 1
|
||||||
AND value_1 < 3
|
AND value_1 < 3
|
||||||
AND value_2 >= 1
|
AND value_2 >= 1
|
||||||
AND user_id = 3
|
AND user_id = 3
|
||||||
AND EXISTS (SELECT user_id
|
AND EXISTS (SELECT user_id
|
||||||
FROM events_table
|
FROM events_table
|
||||||
WHERE event_type > 1
|
WHERE event_type > 1
|
||||||
AND event_type < 3
|
AND event_type < 3
|
||||||
AND value_3 > 1
|
AND value_3 > 1
|
||||||
AND user_id = users_table.user_id
|
AND user_id = users_table.user_id
|
||||||
AND user_id = 3
|
AND user_id = 3
|
||||||
GROUP BY user_id
|
GROUP BY user_id
|
||||||
HAVING Count(*) > 2);
|
HAVING Count(*) > 2);
|
||||||
|
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
||||||
count | count | avg
|
count | count | avg
|
||||||
|
@ -396,22 +387,21 @@ SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
||||||
------------------------------------
|
------------------------------------
|
||||||
TRUNCATE agg_results_second;
|
TRUNCATE agg_results_second;
|
||||||
INSERT INTO agg_results_second(user_id, value_2_agg)
|
INSERT INTO agg_results_second(user_id, value_2_agg)
|
||||||
SELECT user_id,
|
SELECT user_id,
|
||||||
value_2
|
value_2
|
||||||
FROM users_table
|
FROM users_table
|
||||||
WHERE value_1 > 1
|
WHERE value_1 > 1
|
||||||
AND value_1 < 3
|
AND value_1 < 3
|
||||||
AND value_2 >= 1
|
AND value_2 >= 1
|
||||||
AND (user_id = 3 or user_id = 4)
|
AND (user_id = 3 or user_id = 4)
|
||||||
AND EXISTS (SELECT user_id
|
AND EXISTS (SELECT user_id
|
||||||
FROM events_table
|
FROM events_table
|
||||||
WHERE event_type = 2
|
WHERE event_type = 2
|
||||||
AND value_3 > 1
|
AND value_3 > 1
|
||||||
AND user_id = users_table.user_id
|
AND user_id = users_table.user_id
|
||||||
AND (user_id = 3 or user_id = 4)
|
AND (user_id = 3 or user_id = 4)
|
||||||
GROUP BY user_id
|
GROUP BY user_id
|
||||||
HAVING Count(*) > 2);
|
HAVING Count(*) > 2);
|
||||||
|
|
||||||
-- get some statistics from the aggregated results to ensure the results are correct
|
-- get some statistics from the aggregated results to ensure the results are correct
|
||||||
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
||||||
count | count | avg
|
count | count | avg
|
||||||
|
@ -419,4 +409,3 @@ SELECT count(*), count(DISTINCT user_id), avg(user_id) FROM agg_results_second;
|
||||||
4 | 2 | 3.5000000000000000
|
4 | 2 | 3.5000000000000000
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ SET citus.next_shard_id TO 1240000;
|
||||||
-- test with invalid port, prevent OS dependent warning from being displayed
|
-- test with invalid port, prevent OS dependent warning from being displayed
|
||||||
SET client_min_messages to ERROR;
|
SET client_min_messages to ERROR;
|
||||||
-- PG 9.5 does not show context for plpgsql raise
|
-- PG 9.5 does not show context for plpgsql raise
|
||||||
-- message whereas PG 9.6 shows. disabling it
|
-- message whereas PG 9.6 shows. disabling it
|
||||||
-- for this test only to have consistent behavior
|
-- for this test only to have consistent behavior
|
||||||
-- b/w PG 9.6+ and PG 9.5.
|
-- b/w PG 9.6+ and PG 9.5.
|
||||||
\set SHOW_CONTEXT never
|
\set SHOW_CONTEXT never
|
||||||
SELECT * FROM master_run_on_worker(ARRAY['localhost']::text[], ARRAY['666']::int[],
|
SELECT * FROM master_run_on_worker(ARRAY['localhost']::text[], ARRAY['666']::int[],
|
||||||
ARRAY['select count(*) from pg_dist_shard']::text[],
|
ARRAY['select count(*) from pg_dist_shard']::text[],
|
||||||
|
@ -61,7 +61,6 @@ SELECT * FROM master_run_on_worker(ARRAY[:node_name]::text[], ARRAY[:node_port]:
|
||||||
localhost | 57637 | f | expected a single row in query result
|
localhost | 57637 | f | expected a single row in query result
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- send multiple queries
|
-- send multiple queries
|
||||||
SELECT * FROM master_run_on_worker(ARRAY[:node_name, :node_name]::text[],
|
SELECT * FROM master_run_on_worker(ARRAY[:node_name, :node_name]::text[],
|
||||||
ARRAY[:node_port, :node_port]::int[],
|
ARRAY[:node_port, :node_port]::int[],
|
||||||
|
@ -185,7 +184,6 @@ SELECT * FROM master_run_on_worker(ARRAY[:node_name]::text[], ARRAY[:node_port]:
|
||||||
localhost | 57637 | t | DROP TABLE
|
localhost | 57637 | t | DROP TABLE
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- verify table is dropped
|
-- verify table is dropped
|
||||||
SELECT * FROM master_run_on_worker(ARRAY[:node_name]::text[], ARRAY[:node_port]::int[],
|
SELECT * FROM master_run_on_worker(ARRAY[:node_name]::text[], ARRAY[:node_port]::int[],
|
||||||
ARRAY['select count(*) from second_table']::text[],
|
ARRAY['select count(*) from second_table']::text[],
|
||||||
|
@ -226,7 +224,6 @@ SELECT * FROM master_run_on_worker(ARRAY[:node_name]::text[], ARRAY[:node_port]:
|
||||||
localhost | 57637 | f | expected a single row in query result
|
localhost | 57637 | f | expected a single row in query result
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- send multiple queries
|
-- send multiple queries
|
||||||
SELECT * FROM master_run_on_worker(ARRAY[:node_name, :node_name]::text[],
|
SELECT * FROM master_run_on_worker(ARRAY[:node_name, :node_name]::text[],
|
||||||
ARRAY[:node_port, :node_port]::int[],
|
ARRAY[:node_port, :node_port]::int[],
|
||||||
|
|
|
@ -223,9 +223,7 @@ SELECT shardmaxvalue::integer - shardminvalue::integer AS shard_size
|
||||||
DELETE FROM pg_dist_shard_placement
|
DELETE FROM pg_dist_shard_placement
|
||||||
WHERE shardid IN (SELECT shardid FROM pg_dist_shard
|
WHERE shardid IN (SELECT shardid FROM pg_dist_shard
|
||||||
WHERE logicalrelid = 'foreign_table_to_distribute'::regclass);
|
WHERE logicalrelid = 'foreign_table_to_distribute'::regclass);
|
||||||
|
|
||||||
DELETE FROM pg_dist_shard
|
DELETE FROM pg_dist_shard
|
||||||
WHERE logicalrelid = 'foreign_table_to_distribute'::regclass;
|
WHERE logicalrelid = 'foreign_table_to_distribute'::regclass;
|
||||||
|
|
||||||
DELETE FROM pg_dist_partition
|
DELETE FROM pg_dist_partition
|
||||||
WHERE logicalrelid = 'foreign_table_to_distribute'::regclass;
|
WHERE logicalrelid = 'foreign_table_to_distribute'::regclass;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
--
|
--
|
||||||
-- MULTI_DISTRIBUTED_TRANSACTION_ID
|
-- MULTI_DISTRIBUTED_TRANSACTION_ID
|
||||||
--
|
--
|
||||||
-- Unit tests for distributed transaction id functionality
|
-- Unit tests for distributed transaction id functionality
|
||||||
--
|
--
|
||||||
-- get the current transaction id, which should be uninitialized
|
-- get the current transaction id, which should be uninitialized
|
||||||
|
@ -17,7 +17,6 @@ SELECT initiator_node_identifier, transaction_number, transaction_stamp FROM get
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
-- we should still see the uninitialized values
|
-- we should still see the uninitialized values
|
||||||
SELECT initiator_node_identifier, transaction_number, transaction_stamp, (process_id = pg_backend_pid()) FROM get_current_transaction_id();
|
SELECT initiator_node_identifier, transaction_number, transaction_stamp, (process_id = pg_backend_pid()) FROM get_current_transaction_id();
|
||||||
initiator_node_identifier | transaction_number | transaction_stamp | ?column?
|
initiator_node_identifier | transaction_number | transaction_stamp | ?column?
|
||||||
|
@ -52,7 +51,6 @@ SELECT initiator_node_identifier, transaction_number, transaction_stamp, (proces
|
||||||
|
|
||||||
-- also see that ROLLBACK (i.e., failures in the transaction) clears the shared memory
|
-- also see that ROLLBACK (i.e., failures in the transaction) clears the shared memory
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
-- we should still see the uninitialized values
|
-- we should still see the uninitialized values
|
||||||
SELECT initiator_node_identifier, transaction_number, transaction_stamp, (process_id = pg_backend_pid()) FROM get_current_transaction_id();
|
SELECT initiator_node_identifier, transaction_number, transaction_stamp, (process_id = pg_backend_pid()) FROM get_current_transaction_id();
|
||||||
initiator_node_identifier | transaction_number | transaction_stamp | ?column?
|
initiator_node_identifier | transaction_number | transaction_stamp | ?column?
|
||||||
|
@ -79,7 +77,6 @@ COMMIT;
|
||||||
|
|
||||||
-- we should also see that a new connection means an uninitialized transaction id
|
-- we should also see that a new connection means an uninitialized transaction id
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
SELECT assign_distributed_transaction_id(52, 52, '2015-01-01 00:00:00+0');
|
SELECT assign_distributed_transaction_id(52, 52, '2015-01-01 00:00:00+0');
|
||||||
assign_distributed_transaction_id
|
assign_distributed_transaction_id
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
@ -126,7 +123,7 @@ ROLLBACK PREPARED 'dist_xact_id_test';
|
||||||
-- set back to the original zone
|
-- set back to the original zone
|
||||||
SET TIME ZONE DEFAULT;
|
SET TIME ZONE DEFAULT;
|
||||||
-- parallel safe wrapper for getting the current transaction number
|
-- parallel safe wrapper for getting the current transaction number
|
||||||
CREATE OR REPLACE FUNCTION parallel_worker_transaction_id_test()
|
CREATE OR REPLACE FUNCTION parallel_worker_transaction_id_test()
|
||||||
RETURNS bigint STRICT VOLATILE PARALLEL SAFE AS $$
|
RETURNS bigint STRICT VOLATILE PARALLEL SAFE AS $$
|
||||||
SELECT transaction_number FROM get_current_transaction_id();
|
SELECT transaction_number FROM get_current_transaction_id();
|
||||||
$$ LANGUAGE sql;
|
$$ LANGUAGE sql;
|
||||||
|
|
|
@ -161,7 +161,7 @@ SELECT get_referencing_relation_id_list::regclass FROM get_referencing_relation_
|
||||||
----------------------------------
|
----------------------------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- some tests within transction blocks to make sure that
|
-- some tests within transction blocks to make sure that
|
||||||
-- cache invalidation works fine
|
-- cache invalidation works fine
|
||||||
CREATE TABLE test_1 (id int UNIQUE);
|
CREATE TABLE test_1 (id int UNIQUE);
|
||||||
CREATE TABLE test_2 (id int UNIQUE);
|
CREATE TABLE test_2 (id int UNIQUE);
|
||||||
|
@ -198,17 +198,17 @@ SELECT create_distributed_Table('test_5', 'id');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
CREATE VIEW referential_integrity_summary AS
|
CREATE VIEW referential_integrity_summary AS
|
||||||
WITH RECURSIVE referential_integrity_summary(n, table_name, referencing_relations, referenced_relations) AS
|
WITH RECURSIVE referential_integrity_summary(n, table_name, referencing_relations, referenced_relations) AS
|
||||||
(
|
(
|
||||||
SELECT 0,'0','{}'::regclass[],'{}'::regclass[]
|
SELECT 0,'0','{}'::regclass[],'{}'::regclass[]
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
n + 1,
|
n + 1,
|
||||||
'test_' || n + 1|| '' as table_name,
|
'test_' || n + 1|| '' as table_name,
|
||||||
(SELECT array_agg(get_referencing_relation_id_list::regclass ORDER BY 1) FROM get_referencing_relation_id_list(('test_' || (n +1) ) ::regclass)) as referencing_relations,
|
(SELECT array_agg(get_referencing_relation_id_list::regclass ORDER BY 1) FROM get_referencing_relation_id_list(('test_' || (n +1) ) ::regclass)) as referencing_relations,
|
||||||
(SELECT array_agg(get_referenced_relation_id_list::regclass ORDER BY 1) FROM get_referenced_relation_id_list(('test_' || (n +1) ) ::regclass)) as referenced_by_relations
|
(SELECT array_agg(get_referenced_relation_id_list::regclass ORDER BY 1) FROM get_referenced_relation_id_list(('test_' || (n +1) ) ::regclass)) as referenced_by_relations
|
||||||
FROM referential_integrity_summary, pg_class
|
FROM referential_integrity_summary, pg_class
|
||||||
WHERE
|
WHERE
|
||||||
pg_class.relname = ('test_' || (n +1))
|
pg_class.relname = ('test_' || (n +1))
|
||||||
AND n < 5
|
AND n < 5
|
||||||
|
@ -216,7 +216,7 @@ CREATE VIEW referential_integrity_summary AS
|
||||||
SELECT * FROM referential_integrity_summary WHERE n != 0 ORDER BY 1;
|
SELECT * FROM referential_integrity_summary WHERE n != 0 ORDER BY 1;
|
||||||
-- make sure that invalidation through ALTER TABLE works fine
|
-- make sure that invalidation through ALTER TABLE works fine
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE test_2 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_1(id);
|
ALTER TABLE test_2 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_1(id);
|
||||||
SELECT * FROM referential_integrity_summary;
|
SELECT * FROM referential_integrity_summary;
|
||||||
n | table_name | referencing_relations | referenced_relations
|
n | table_name | referencing_relations | referenced_relations
|
||||||
---+------------+-----------------------+----------------------
|
---+------------+-----------------------+----------------------
|
||||||
|
@ -263,7 +263,7 @@ BEGIN;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- similar test, but slightly different order of creating foreign keys
|
-- similar test, but slightly different order of creating foreign keys
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE test_2 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_1(id);
|
ALTER TABLE test_2 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_1(id);
|
||||||
SELECT * FROM referential_integrity_summary;
|
SELECT * FROM referential_integrity_summary;
|
||||||
n | table_name | referencing_relations | referenced_relations
|
n | table_name | referencing_relations | referenced_relations
|
||||||
---+------------+-----------------------+----------------------
|
---+------------+-----------------------+----------------------
|
||||||
|
@ -310,7 +310,7 @@ BEGIN;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- make sure that DROP CONSTRAINT works invalidates the cache correctly
|
-- make sure that DROP CONSTRAINT works invalidates the cache correctly
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE test_2 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_1(id);
|
ALTER TABLE test_2 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_1(id);
|
||||||
ALTER TABLE test_3 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_2(id);
|
ALTER TABLE test_3 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_2(id);
|
||||||
ALTER TABLE test_4 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_3(id);
|
ALTER TABLE test_4 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_3(id);
|
||||||
ALTER TABLE test_5 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_4(id);
|
ALTER TABLE test_5 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_4(id);
|
||||||
|
@ -412,7 +412,7 @@ COMMIT;
|
||||||
-- DROP TABLE works expected
|
-- DROP TABLE works expected
|
||||||
-- re-create the constraints
|
-- re-create the constraints
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE test_2 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_1(id);
|
ALTER TABLE test_2 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_1(id);
|
||||||
ALTER TABLE test_3 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_2(id);
|
ALTER TABLE test_3 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_2(id);
|
||||||
ALTER TABLE test_4 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_3(id);
|
ALTER TABLE test_4 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_3(id);
|
||||||
ALTER TABLE test_5 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_4(id);
|
ALTER TABLE test_5 ADD CONSTRAINT fkey_1 FOREIGN KEY(id) REFERENCES test_4(id);
|
||||||
|
@ -601,7 +601,6 @@ drop cascades to table test_8
|
||||||
---------------------------------
|
---------------------------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
SET search_path TO public;
|
SET search_path TO public;
|
||||||
DROP SCHEMA fkey_graph CASCADE;
|
DROP SCHEMA fkey_graph CASCADE;
|
||||||
|
|
|
@ -73,10 +73,10 @@ SET client_min_messages TO INFO;
|
||||||
SELECT
|
SELECT
|
||||||
raw_events_first.user_id
|
raw_events_first.user_id
|
||||||
FROM
|
FROM
|
||||||
raw_events_first, raw_events_second
|
raw_events_first, raw_events_second
|
||||||
WHERE
|
WHERE
|
||||||
raw_events_first.user_id = raw_events_second.user_id
|
raw_events_first.user_id = raw_events_second.user_id
|
||||||
ORDER BY
|
ORDER BY
|
||||||
user_id DESC;
|
user_id DESC;
|
||||||
user_id
|
user_id
|
||||||
---------
|
---------
|
||||||
|
@ -161,10 +161,10 @@ INSERT INTO raw_events_first (user_id, time, value_1, value_2, value_3, value_4)
|
||||||
(8, now(), 80, 800, 8000, 80000);
|
(8, now(), 80, 800, 8000, 80000);
|
||||||
-- reorder columns
|
-- reorder columns
|
||||||
SET client_min_messages TO DEBUG2;
|
SET client_min_messages TO DEBUG2;
|
||||||
INSERT INTO raw_events_second (value_2, value_1, value_3, value_4, user_id, time)
|
INSERT INTO raw_events_second (value_2, value_1, value_3, value_4, user_id, time)
|
||||||
SELECT
|
SELECT
|
||||||
value_2, value_1, value_3, value_4, user_id, time
|
value_2, value_1, value_3, value_4, user_id, time
|
||||||
FROM
|
FROM
|
||||||
raw_events_first
|
raw_events_first
|
||||||
WHERE
|
WHERE
|
||||||
user_id = 8;
|
user_id = 8;
|
||||||
|
@ -174,10 +174,10 @@ DEBUG: Skipping target shard interval 13300006 since SELECT query for it pruned
|
||||||
DEBUG: Skipping target shard interval 13300007 since SELECT query for it pruned away
|
DEBUG: Skipping target shard interval 13300007 since SELECT query for it pruned away
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
-- a zero shard select
|
-- a zero shard select
|
||||||
INSERT INTO raw_events_second (value_2, value_1, value_3, value_4, user_id, time)
|
INSERT INTO raw_events_second (value_2, value_1, value_3, value_4, user_id, time)
|
||||||
SELECT
|
SELECT
|
||||||
value_2, value_1, value_3, value_4, user_id, time
|
value_2, value_1, value_3, value_4, user_id, time
|
||||||
FROM
|
FROM
|
||||||
raw_events_first
|
raw_events_first
|
||||||
WHERE
|
WHERE
|
||||||
false;
|
false;
|
||||||
|
@ -187,10 +187,10 @@ DEBUG: Skipping target shard interval 13300006 since SELECT query for it pruned
|
||||||
DEBUG: Skipping target shard interval 13300007 since SELECT query for it pruned away
|
DEBUG: Skipping target shard interval 13300007 since SELECT query for it pruned away
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
-- another zero shard select
|
-- another zero shard select
|
||||||
INSERT INTO raw_events_second (value_2, value_1, value_3, value_4, user_id, time)
|
INSERT INTO raw_events_second (value_2, value_1, value_3, value_4, user_id, time)
|
||||||
SELECT
|
SELECT
|
||||||
value_2, value_1, value_3, value_4, user_id, time
|
value_2, value_1, value_3, value_4, user_id, time
|
||||||
FROM
|
FROM
|
||||||
raw_events_first
|
raw_events_first
|
||||||
WHERE
|
WHERE
|
||||||
0 != 0;
|
0 != 0;
|
||||||
|
@ -205,13 +205,13 @@ INSERT INTO raw_events_first (user_id, time, value_1, value_2, value_3, value_4)
|
||||||
(9, now(), 90, 900, 9000, 90000);
|
(9, now(), 90, 900, 9000, 90000);
|
||||||
-- show that RETURNING also works
|
-- show that RETURNING also works
|
||||||
SET client_min_messages TO DEBUG2;
|
SET client_min_messages TO DEBUG2;
|
||||||
INSERT INTO raw_events_second (user_id, value_1, value_3)
|
INSERT INTO raw_events_second (user_id, value_1, value_3)
|
||||||
SELECT
|
SELECT
|
||||||
user_id, value_1, value_3
|
user_id, value_1, value_3
|
||||||
FROM
|
FROM
|
||||||
raw_events_first
|
raw_events_first
|
||||||
WHERE
|
WHERE
|
||||||
value_3 = 9000
|
value_3 = 9000
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300004 AS citus_table_alias (user_id, value_1, value_3) SELECT user_id, value_1, value_3 FROM public.raw_events_first_13300000 raw_events_first WHERE ((value_3 OPERATOR(pg_catalog.=) (9000)::double precision) AND ((worker_hash(user_id) OPERATOR(pg_catalog.>=) '-2147483648'::integer) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) '-1073741825'::integer))) RETURNING citus_table_alias.user_id, citus_table_alias."time", citus_table_alias.value_1, citus_table_alias.value_2, citus_table_alias.value_3, citus_table_alias.value_4
|
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300004 AS citus_table_alias (user_id, value_1, value_3) SELECT user_id, value_1, value_3 FROM public.raw_events_first_13300000 raw_events_first WHERE ((value_3 OPERATOR(pg_catalog.=) (9000)::double precision) AND ((worker_hash(user_id) OPERATOR(pg_catalog.>=) '-2147483648'::integer) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) '-1073741825'::integer))) RETURNING citus_table_alias.user_id, citus_table_alias."time", citus_table_alias.value_1, citus_table_alias.value_2, citus_table_alias.value_3, citus_table_alias.value_4
|
||||||
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300005 AS citus_table_alias (user_id, value_1, value_3) SELECT user_id, value_1, value_3 FROM public.raw_events_first_13300001 raw_events_first WHERE ((value_3 OPERATOR(pg_catalog.=) (9000)::double precision) AND ((worker_hash(user_id) OPERATOR(pg_catalog.>=) '-1073741824'::integer) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) '-1'::integer))) RETURNING citus_table_alias.user_id, citus_table_alias."time", citus_table_alias.value_1, citus_table_alias.value_2, citus_table_alias.value_3, citus_table_alias.value_4
|
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300005 AS citus_table_alias (user_id, value_1, value_3) SELECT user_id, value_1, value_3 FROM public.raw_events_first_13300001 raw_events_first WHERE ((value_3 OPERATOR(pg_catalog.=) (9000)::double precision) AND ((worker_hash(user_id) OPERATOR(pg_catalog.>=) '-1073741824'::integer) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) '-1'::integer))) RETURNING citus_table_alias.user_id, citus_table_alias."time", citus_table_alias.value_1, citus_table_alias.value_2, citus_table_alias.value_3, citus_table_alias.value_4
|
||||||
|
@ -225,13 +225,13 @@ DEBUG: Plan is router executable
|
||||||
|
|
||||||
-- hits two shards
|
-- hits two shards
|
||||||
\set VERBOSITY TERSE
|
\set VERBOSITY TERSE
|
||||||
INSERT INTO raw_events_second (user_id, value_1, value_3)
|
INSERT INTO raw_events_second (user_id, value_1, value_3)
|
||||||
SELECT
|
SELECT
|
||||||
user_id, value_1, value_3
|
user_id, value_1, value_3
|
||||||
FROM
|
FROM
|
||||||
raw_events_first
|
raw_events_first
|
||||||
WHERE
|
WHERE
|
||||||
user_id = 9 OR user_id = 16
|
user_id = 9 OR user_id = 16
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
DEBUG: Skipping target shard interval 13300004 since SELECT query for it pruned away
|
DEBUG: Skipping target shard interval 13300004 since SELECT query for it pruned away
|
||||||
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300005 AS citus_table_alias (user_id, value_1, value_3) SELECT user_id, value_1, value_3 FROM public.raw_events_first_13300001 raw_events_first WHERE (((user_id OPERATOR(pg_catalog.=) 9) OR (user_id OPERATOR(pg_catalog.=) 16)) AND ((worker_hash(user_id) OPERATOR(pg_catalog.>=) '-1073741824'::integer) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) '-1'::integer))) RETURNING citus_table_alias.user_id, citus_table_alias."time", citus_table_alias.value_1, citus_table_alias.value_2, citus_table_alias.value_3, citus_table_alias.value_4
|
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300005 AS citus_table_alias (user_id, value_1, value_3) SELECT user_id, value_1, value_3 FROM public.raw_events_first_13300001 raw_events_first WHERE (((user_id OPERATOR(pg_catalog.=) 9) OR (user_id OPERATOR(pg_catalog.=) 16)) AND ((worker_hash(user_id) OPERATOR(pg_catalog.>=) '-1073741824'::integer) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) '-1'::integer))) RETURNING citus_table_alias.user_id, citus_table_alias."time", citus_table_alias.value_1, citus_table_alias.value_2, citus_table_alias.value_3, citus_table_alias.value_4
|
||||||
|
@ -240,9 +240,9 @@ DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300007 AS
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
ERROR: duplicate key value violates unique constraint "raw_events_second_user_id_value_1_key_13300007"
|
ERROR: duplicate key value violates unique constraint "raw_events_second_user_id_value_1_key_13300007"
|
||||||
-- now do some aggregations
|
-- now do some aggregations
|
||||||
INSERT INTO agg_events
|
INSERT INTO agg_events
|
||||||
SELECT
|
SELECT
|
||||||
user_id, sum(value_1), avg(value_2), sum(value_3), count(value_4)
|
user_id, sum(value_1), avg(value_2), sum(value_3), count(value_4)
|
||||||
FROM
|
FROM
|
||||||
raw_events_first
|
raw_events_first
|
||||||
GROUP BY
|
GROUP BY
|
||||||
|
@ -253,7 +253,7 @@ DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_t
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id, value_1_agg, value_2_agg, value_3_agg, value_4_agg) SELECT user_id, sum(value_1) AS sum, avg(value_2) AS avg, sum(value_3) AS sum, count(value_4) AS count FROM public.raw_events_first_13300003 raw_events_first WHERE ((worker_hash(user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) 2147483647)) GROUP BY user_id
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id, value_1_agg, value_2_agg, value_3_agg, value_4_agg) SELECT user_id, sum(value_1) AS sum, avg(value_2) AS avg, sum(value_3) AS sum, count(value_4) AS count FROM public.raw_events_first_13300003 raw_events_first WHERE ((worker_hash(user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) 2147483647)) GROUP BY user_id
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
-- group by column not exists on the SELECT target list
|
-- group by column not exists on the SELECT target list
|
||||||
INSERT INTO agg_events (value_3_agg, value_4_agg, value_1_agg, user_id)
|
INSERT INTO agg_events (value_3_agg, value_4_agg, value_1_agg, user_id)
|
||||||
SELECT
|
SELECT
|
||||||
sum(value_3), count(value_4), sum(value_1), user_id
|
sum(value_3), count(value_4), sum(value_1), user_id
|
||||||
FROM
|
FROM
|
||||||
|
@ -268,16 +268,16 @@ DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_t
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
ERROR: duplicate key value violates unique constraint "agg_events_user_id_value_1_agg_key_13300008"
|
ERROR: duplicate key value violates unique constraint "agg_events_user_id_value_1_agg_key_13300008"
|
||||||
-- some subquery tests
|
-- some subquery tests
|
||||||
INSERT INTO agg_events
|
INSERT INTO agg_events
|
||||||
(value_1_agg,
|
(value_1_agg,
|
||||||
user_id)
|
user_id)
|
||||||
SELECT SUM(value_1),
|
SELECT SUM(value_1),
|
||||||
id
|
id
|
||||||
FROM (SELECT raw_events_second.user_id AS id,
|
FROM (SELECT raw_events_second.user_id AS id,
|
||||||
raw_events_second.value_1
|
raw_events_second.value_1
|
||||||
FROM raw_events_first,
|
FROM raw_events_first,
|
||||||
raw_events_second
|
raw_events_second
|
||||||
WHERE raw_events_first.user_id = raw_events_second.user_id) AS foo
|
WHERE raw_events_first.user_id = raw_events_second.user_id) AS foo
|
||||||
GROUP BY id
|
GROUP BY id
|
||||||
ORDER BY id;
|
ORDER BY id;
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS citus_table_alias (user_id, value_1_agg) SELECT id, sum(value_1) AS sum FROM (SELECT raw_events_second.user_id AS id, raw_events_second.value_1 FROM public.raw_events_first_13300000 raw_events_first, public.raw_events_second_13300004 raw_events_second WHERE (raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id)) foo WHERE ((worker_hash(id) OPERATOR(pg_catalog.>=) '-2147483648'::integer) AND (worker_hash(id) OPERATOR(pg_catalog.<=) '-1073741825'::integer)) GROUP BY id ORDER BY id
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS citus_table_alias (user_id, value_1_agg) SELECT id, sum(value_1) AS sum FROM (SELECT raw_events_second.user_id AS id, raw_events_second.value_1 FROM public.raw_events_first_13300000 raw_events_first, public.raw_events_second_13300004 raw_events_second WHERE (raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id)) foo WHERE ((worker_hash(id) OPERATOR(pg_catalog.>=) '-2147483648'::integer) AND (worker_hash(id) OPERATOR(pg_catalog.<=) '-1073741825'::integer)) GROUP BY id ORDER BY id
|
||||||
|
@ -286,20 +286,20 @@ DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_t
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id, value_1_agg) SELECT id, sum(value_1) AS sum FROM (SELECT raw_events_second.user_id AS id, raw_events_second.value_1 FROM public.raw_events_first_13300003 raw_events_first, public.raw_events_second_13300007 raw_events_second WHERE (raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id)) foo WHERE ((worker_hash(id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(id) OPERATOR(pg_catalog.<=) 2147483647)) GROUP BY id ORDER BY id
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id, value_1_agg) SELECT id, sum(value_1) AS sum FROM (SELECT raw_events_second.user_id AS id, raw_events_second.value_1 FROM public.raw_events_first_13300003 raw_events_first, public.raw_events_second_13300007 raw_events_second WHERE (raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id)) foo WHERE ((worker_hash(id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(id) OPERATOR(pg_catalog.<=) 2147483647)) GROUP BY id ORDER BY id
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
ERROR: duplicate key value violates unique constraint "agg_events_user_id_value_1_agg_key_13300008"
|
ERROR: duplicate key value violates unique constraint "agg_events_user_id_value_1_agg_key_13300008"
|
||||||
-- subquery one more level depth
|
-- subquery one more level depth
|
||||||
INSERT INTO agg_events
|
INSERT INTO agg_events
|
||||||
(value_4_agg,
|
(value_4_agg,
|
||||||
value_1_agg,
|
value_1_agg,
|
||||||
user_id)
|
user_id)
|
||||||
SELECT v4,
|
SELECT v4,
|
||||||
v1,
|
v1,
|
||||||
id
|
id
|
||||||
FROM (SELECT SUM(raw_events_second.value_4) AS v4,
|
FROM (SELECT SUM(raw_events_second.value_4) AS v4,
|
||||||
SUM(raw_events_first.value_1) AS v1,
|
SUM(raw_events_first.value_1) AS v1,
|
||||||
raw_events_second.user_id AS id
|
raw_events_second.user_id AS id
|
||||||
FROM raw_events_first,
|
FROM raw_events_first,
|
||||||
raw_events_second
|
raw_events_second
|
||||||
WHERE raw_events_first.user_id = raw_events_second.user_id
|
WHERE raw_events_first.user_id = raw_events_second.user_id
|
||||||
GROUP BY raw_events_second.user_id) AS foo
|
GROUP BY raw_events_second.user_id) AS foo
|
||||||
ORDER BY id;
|
ORDER BY id;
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS citus_table_alias (user_id, value_1_agg, value_4_agg) SELECT id, v1, v4 FROM (SELECT sum(raw_events_second.value_4) AS v4, sum(raw_events_first.value_1) AS v1, raw_events_second.user_id AS id FROM public.raw_events_first_13300000 raw_events_first, public.raw_events_second_13300004 raw_events_second WHERE (raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id) GROUP BY raw_events_second.user_id) foo WHERE ((worker_hash(id) OPERATOR(pg_catalog.>=) '-2147483648'::integer) AND (worker_hash(id) OPERATOR(pg_catalog.<=) '-1073741825'::integer)) ORDER BY id
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS citus_table_alias (user_id, value_1_agg, value_4_agg) SELECT id, v1, v4 FROM (SELECT sum(raw_events_second.value_4) AS v4, sum(raw_events_first.value_1) AS v1, raw_events_second.user_id AS id FROM public.raw_events_first_13300000 raw_events_first, public.raw_events_second_13300004 raw_events_second WHERE (raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id) GROUP BY raw_events_second.user_id) foo WHERE ((worker_hash(id) OPERATOR(pg_catalog.>=) '-2147483648'::integer) AND (worker_hash(id) OPERATOR(pg_catalog.<=) '-1073741825'::integer)) ORDER BY id
|
||||||
|
@ -451,19 +451,19 @@ DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_t
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id) SELECT f2.id FROM ((SELECT foo.id FROM (SELECT reference_table.user_id AS id FROM public.raw_events_first_13300003 raw_events_first, public.reference_table_13300012 reference_table WHERE (raw_events_first.user_id OPERATOR(pg_catalog.=) reference_table.user_id)) foo) f JOIN (SELECT foo2.v4, foo2.v1, foo2.id FROM (SELECT sum(raw_events_second.value_4) AS v4, sum(raw_events_first.value_1) AS v1, raw_events_second.user_id AS id FROM public.raw_events_first_13300003 raw_events_first, public.raw_events_second_13300007 raw_events_second WHERE (raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id) GROUP BY raw_events_second.user_id HAVING (sum(raw_events_second.value_4) OPERATOR(pg_catalog.>) (1000)::numeric)) foo2) f2 ON ((f.id OPERATOR(pg_catalog.=) f2.id))) WHERE ((f.id OPERATOR(pg_catalog.=) ANY (SELECT raw_events_second.user_id FROM public.raw_events_second_13300007 raw_events_second)) AND ((worker_hash(f2.id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(f2.id) OPERATOR(pg_catalog.<=) 2147483647)))
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id) SELECT f2.id FROM ((SELECT foo.id FROM (SELECT reference_table.user_id AS id FROM public.raw_events_first_13300003 raw_events_first, public.reference_table_13300012 reference_table WHERE (raw_events_first.user_id OPERATOR(pg_catalog.=) reference_table.user_id)) foo) f JOIN (SELECT foo2.v4, foo2.v1, foo2.id FROM (SELECT sum(raw_events_second.value_4) AS v4, sum(raw_events_first.value_1) AS v1, raw_events_second.user_id AS id FROM public.raw_events_first_13300003 raw_events_first, public.raw_events_second_13300007 raw_events_second WHERE (raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id) GROUP BY raw_events_second.user_id HAVING (sum(raw_events_second.value_4) OPERATOR(pg_catalog.>) (1000)::numeric)) foo2) f2 ON ((f.id OPERATOR(pg_catalog.=) f2.id))) WHERE ((f.id OPERATOR(pg_catalog.=) ANY (SELECT raw_events_second.user_id FROM public.raw_events_second_13300007 raw_events_second)) AND ((worker_hash(f2.id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(f2.id) OPERATOR(pg_catalog.<=) 2147483647)))
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
-- some UPSERTS
|
-- some UPSERTS
|
||||||
INSERT INTO agg_events AS ae
|
INSERT INTO agg_events AS ae
|
||||||
(
|
(
|
||||||
user_id,
|
user_id,
|
||||||
value_1_agg,
|
value_1_agg,
|
||||||
agg_time
|
agg_time
|
||||||
)
|
)
|
||||||
SELECT user_id,
|
SELECT user_id,
|
||||||
value_1,
|
value_1,
|
||||||
time
|
time
|
||||||
FROM raw_events_first
|
FROM raw_events_first
|
||||||
ON conflict (user_id, value_1_agg)
|
ON conflict (user_id, value_1_agg)
|
||||||
DO UPDATE
|
DO UPDATE
|
||||||
SET agg_time = EXCLUDED.agg_time
|
SET agg_time = EXCLUDED.agg_time
|
||||||
WHERE ae.agg_time < EXCLUDED.agg_time;
|
WHERE ae.agg_time < EXCLUDED.agg_time;
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS ae (user_id, value_1_agg, agg_time) SELECT user_id, value_1, "time" FROM public.raw_events_first_13300000 raw_events_first WHERE ((worker_hash(user_id) OPERATOR(pg_catalog.>=) '-2147483648'::integer) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) '-1073741825'::integer)) ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time OPERATOR(pg_catalog.<) excluded.agg_time)
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS ae (user_id, value_1_agg, agg_time) SELECT user_id, value_1, "time" FROM public.raw_events_first_13300000 raw_events_first WHERE ((worker_hash(user_id) OPERATOR(pg_catalog.>=) '-2147483648'::integer) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) '-1073741825'::integer)) ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time OPERATOR(pg_catalog.<) excluded.agg_time)
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS ae (user_id, value_1_agg, agg_time) SELECT user_id, value_1, "time" FROM public.raw_events_first_13300001 raw_events_first WHERE ((worker_hash(user_id) OPERATOR(pg_catalog.>=) '-1073741824'::integer) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) '-1'::integer)) ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time OPERATOR(pg_catalog.<) excluded.agg_time)
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS ae (user_id, value_1_agg, agg_time) SELECT user_id, value_1, "time" FROM public.raw_events_first_13300001 raw_events_first WHERE ((worker_hash(user_id) OPERATOR(pg_catalog.>=) '-1073741824'::integer) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) '-1'::integer)) ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time OPERATOR(pg_catalog.<) excluded.agg_time)
|
||||||
|
@ -471,19 +471,19 @@ DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS ae (use
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS ae (user_id, value_1_agg, agg_time) SELECT user_id, value_1, "time" FROM public.raw_events_first_13300003 raw_events_first WHERE ((worker_hash(user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) 2147483647)) ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time OPERATOR(pg_catalog.<) excluded.agg_time)
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS ae (user_id, value_1_agg, agg_time) SELECT user_id, value_1, "time" FROM public.raw_events_first_13300003 raw_events_first WHERE ((worker_hash(user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) 2147483647)) ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time OPERATOR(pg_catalog.<) excluded.agg_time)
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
-- upserts with returning
|
-- upserts with returning
|
||||||
INSERT INTO agg_events AS ae
|
INSERT INTO agg_events AS ae
|
||||||
(
|
(
|
||||||
user_id,
|
user_id,
|
||||||
value_1_agg,
|
value_1_agg,
|
||||||
agg_time
|
agg_time
|
||||||
)
|
)
|
||||||
SELECT user_id,
|
SELECT user_id,
|
||||||
value_1,
|
value_1,
|
||||||
time
|
time
|
||||||
FROM raw_events_first
|
FROM raw_events_first
|
||||||
ON conflict (user_id, value_1_agg)
|
ON conflict (user_id, value_1_agg)
|
||||||
DO UPDATE
|
DO UPDATE
|
||||||
SET agg_time = EXCLUDED.agg_time
|
SET agg_time = EXCLUDED.agg_time
|
||||||
WHERE ae.agg_time < EXCLUDED.agg_time
|
WHERE ae.agg_time < EXCLUDED.agg_time
|
||||||
RETURNING user_id, value_1_agg;
|
RETURNING user_id, value_1_agg;
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS ae (user_id, value_1_agg, agg_time) SELECT user_id, value_1, "time" FROM public.raw_events_first_13300000 raw_events_first WHERE ((worker_hash(user_id) OPERATOR(pg_catalog.>=) '-2147483648'::integer) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) '-1073741825'::integer)) ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time OPERATOR(pg_catalog.<) excluded.agg_time) RETURNING ae.user_id, ae.value_1_agg
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS ae (user_id, value_1_agg, agg_time) SELECT user_id, value_1, "time" FROM public.raw_events_first_13300000 raw_events_first WHERE ((worker_hash(user_id) OPERATOR(pg_catalog.>=) '-2147483648'::integer) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) '-1073741825'::integer)) ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time OPERATOR(pg_catalog.<) excluded.agg_time) RETURNING ae.user_id, ae.value_1_agg
|
||||||
|
@ -584,10 +584,10 @@ DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_t
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
SET client_min_messages TO INFO;
|
SET client_min_messages TO INFO;
|
||||||
-- see that the results are different from the SELECT query
|
-- see that the results are different from the SELECT query
|
||||||
SELECT
|
SELECT
|
||||||
user_id, value_1_agg
|
user_id, value_1_agg
|
||||||
FROM
|
FROM
|
||||||
agg_events
|
agg_events
|
||||||
ORDER BY
|
ORDER BY
|
||||||
user_id, value_1_agg;
|
user_id, value_1_agg;
|
||||||
user_id | value_1_agg
|
user_id | value_1_agg
|
||||||
|
@ -770,7 +770,6 @@ DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS citus_t
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM (public.raw_events_first_13300002 raw_events_first LEFT JOIN public.raw_events_second_13300006 raw_events_second ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 0) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 1073741823))
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM (public.raw_events_first_13300002 raw_events_first LEFT JOIN public.raw_events_second_13300006 raw_events_second ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 0) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 1073741823))
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM (public.raw_events_first_13300003 raw_events_first LEFT JOIN public.raw_events_second_13300007 raw_events_second ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 2147483647))
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM (public.raw_events_first_13300003 raw_events_first LEFT JOIN public.raw_events_second_13300007 raw_events_second ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 2147483647))
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
|
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
SELECT
|
SELECT
|
||||||
raw_events_second.user_id
|
raw_events_second.user_id
|
||||||
|
@ -781,7 +780,6 @@ DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS citus_t
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id) SELECT raw_events_second.user_id FROM (public.reference_table_13300012 reference_table LEFT JOIN public.raw_events_second_13300006 raw_events_second ON ((reference_table.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((worker_hash(raw_events_second.user_id) OPERATOR(pg_catalog.>=) 0) AND (worker_hash(raw_events_second.user_id) OPERATOR(pg_catalog.<=) 1073741823))
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id) SELECT raw_events_second.user_id FROM (public.reference_table_13300012 reference_table LEFT JOIN public.raw_events_second_13300006 raw_events_second ON ((reference_table.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((worker_hash(raw_events_second.user_id) OPERATOR(pg_catalog.>=) 0) AND (worker_hash(raw_events_second.user_id) OPERATOR(pg_catalog.<=) 1073741823))
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id) SELECT raw_events_second.user_id FROM (public.reference_table_13300012 reference_table LEFT JOIN public.raw_events_second_13300007 raw_events_second ON ((reference_table.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((worker_hash(raw_events_second.user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(raw_events_second.user_id) OPERATOR(pg_catalog.<=) 2147483647))
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id) SELECT raw_events_second.user_id FROM (public.reference_table_13300012 reference_table LEFT JOIN public.raw_events_second_13300007 raw_events_second ON ((reference_table.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((worker_hash(raw_events_second.user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(raw_events_second.user_id) OPERATOR(pg_catalog.<=) 2147483647))
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
|
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
SELECT
|
SELECT
|
||||||
raw_events_first.user_id
|
raw_events_first.user_id
|
||||||
|
@ -793,7 +791,6 @@ DEBUG: Skipping target shard interval 13300009 since SELECT query for it pruned
|
||||||
DEBUG: Skipping target shard interval 13300010 since SELECT query for it pruned away
|
DEBUG: Skipping target shard interval 13300010 since SELECT query for it pruned away
|
||||||
DEBUG: Skipping target shard interval 13300011 since SELECT query for it pruned away
|
DEBUG: Skipping target shard interval 13300011 since SELECT query for it pruned away
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
|
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
SELECT
|
SELECT
|
||||||
raw_events_first.user_id
|
raw_events_first.user_id
|
||||||
|
@ -805,7 +802,6 @@ DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS citus_t
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM (public.raw_events_first_13300002 raw_events_first LEFT JOIN (SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", NULL::integer AS value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 WHERE false) raw_events_second(user_id, "time", value_1, value_2, value_3, value_4) ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE (((raw_events_second.user_id OPERATOR(pg_catalog.=) 10) OR (raw_events_second.user_id OPERATOR(pg_catalog.=) 11)) AND ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 0) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 1073741823)))
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM (public.raw_events_first_13300002 raw_events_first LEFT JOIN (SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", NULL::integer AS value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 WHERE false) raw_events_second(user_id, "time", value_1, value_2, value_3, value_4) ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE (((raw_events_second.user_id OPERATOR(pg_catalog.=) 10) OR (raw_events_second.user_id OPERATOR(pg_catalog.=) 11)) AND ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 0) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 1073741823)))
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM (public.raw_events_first_13300003 raw_events_first LEFT JOIN public.raw_events_second_13300007 raw_events_second ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE (((raw_events_second.user_id OPERATOR(pg_catalog.=) 10) OR (raw_events_second.user_id OPERATOR(pg_catalog.=) 11)) AND ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 2147483647)))
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM (public.raw_events_first_13300003 raw_events_first LEFT JOIN public.raw_events_second_13300007 raw_events_second ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE (((raw_events_second.user_id OPERATOR(pg_catalog.=) 10) OR (raw_events_second.user_id OPERATOR(pg_catalog.=) 11)) AND ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 2147483647)))
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
|
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
SELECT
|
SELECT
|
||||||
raw_events_first.user_id
|
raw_events_first.user_id
|
||||||
|
@ -817,7 +813,6 @@ DEBUG: Skipping target shard interval 13300009 since SELECT query for it pruned
|
||||||
DEBUG: Skipping target shard interval 13300010 since SELECT query for it pruned away
|
DEBUG: Skipping target shard interval 13300010 since SELECT query for it pruned away
|
||||||
DEBUG: Skipping target shard interval 13300011 since SELECT query for it pruned away
|
DEBUG: Skipping target shard interval 13300011 since SELECT query for it pruned away
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
|
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
SELECT
|
SELECT
|
||||||
raw_events_first.user_id
|
raw_events_first.user_id
|
||||||
|
@ -829,7 +824,6 @@ DEBUG: Skipping target shard interval 13300009 since SELECT query for it pruned
|
||||||
DEBUG: Skipping target shard interval 13300010 since SELECT query for it pruned away
|
DEBUG: Skipping target shard interval 13300010 since SELECT query for it pruned away
|
||||||
DEBUG: Skipping target shard interval 13300011 since SELECT query for it pruned away
|
DEBUG: Skipping target shard interval 13300011 since SELECT query for it pruned away
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
|
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
SELECT
|
SELECT
|
||||||
raw_events_first.user_id
|
raw_events_first.user_id
|
||||||
|
@ -841,7 +835,6 @@ DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS citus_t
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM (public.raw_events_first_13300002 raw_events_first LEFT JOIN public.raw_events_second_13300006 raw_events_second ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((raw_events_first.user_id OPERATOR(pg_catalog.=) ANY (ARRAY[19, 20, 21])) AND ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 0) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 1073741823)))
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM (public.raw_events_first_13300002 raw_events_first LEFT JOIN public.raw_events_second_13300006 raw_events_second ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((raw_events_first.user_id OPERATOR(pg_catalog.=) ANY (ARRAY[19, 20, 21])) AND ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 0) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 1073741823)))
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM ((SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", NULL::integer AS value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 WHERE false) raw_events_first(user_id, "time", value_1, value_2, value_3, value_4) LEFT JOIN public.raw_events_second_13300007 raw_events_second ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((raw_events_first.user_id OPERATOR(pg_catalog.=) ANY (ARRAY[19, 20, 21])) AND ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 2147483647)))
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM ((SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", NULL::integer AS value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 WHERE false) raw_events_first(user_id, "time", value_1, value_2, value_3, value_4) LEFT JOIN public.raw_events_second_13300007 raw_events_second ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((raw_events_first.user_id OPERATOR(pg_catalog.=) ANY (ARRAY[19, 20, 21])) AND ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 2147483647)))
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
|
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
SELECT
|
SELECT
|
||||||
raw_events_first.user_id
|
raw_events_first.user_id
|
||||||
|
@ -853,7 +846,6 @@ DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS citus_t
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM (public.raw_events_first_13300002 raw_events_first JOIN public.raw_events_second_13300006 raw_events_second ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((raw_events_second.user_id OPERATOR(pg_catalog.=) ANY (ARRAY[19, 20, 21])) AND ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 0) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 1073741823)))
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM (public.raw_events_first_13300002 raw_events_first JOIN public.raw_events_second_13300006 raw_events_second ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((raw_events_second.user_id OPERATOR(pg_catalog.=) ANY (ARRAY[19, 20, 21])) AND ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 0) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 1073741823)))
|
||||||
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM (public.raw_events_first_13300003 raw_events_first JOIN (SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", NULL::integer AS value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 WHERE false) raw_events_second(user_id, "time", value_1, value_2, value_3, value_4) ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((raw_events_second.user_id OPERATOR(pg_catalog.=) ANY (ARRAY[19, 20, 21])) AND ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 2147483647)))
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM (public.raw_events_first_13300003 raw_events_first JOIN (SELECT NULL::integer AS user_id, NULL::timestamp without time zone AS "time", NULL::integer AS value_1, NULL::integer AS value_2, NULL::double precision AS value_3, NULL::bigint AS value_4 WHERE false) raw_events_second(user_id, "time", value_1, value_2, value_3, value_4) ON ((raw_events_first.user_id OPERATOR(pg_catalog.=) raw_events_second.user_id))) WHERE ((raw_events_second.user_id OPERATOR(pg_catalog.=) ANY (ARRAY[19, 20, 21])) AND ((worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(raw_events_first.user_id) OPERATOR(pg_catalog.<=) 2147483647)))
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
|
|
||||||
-- the following is a very tricky query for Citus
|
-- the following is a very tricky query for Citus
|
||||||
-- although we do not support pushing down JOINs on non-partition
|
-- although we do not support pushing down JOINs on non-partition
|
||||||
-- columns here it is safe to push it down given that we're looking for
|
-- columns here it is safe to push it down given that we're looking for
|
||||||
|
@ -861,16 +853,15 @@ DEBUG: Plan is router executable
|
||||||
-- Note that the query always hits the same shard on raw_events_second
|
-- Note that the query always hits the same shard on raw_events_second
|
||||||
-- and this query wouldn't have worked if we're to use different worker
|
-- and this query wouldn't have worked if we're to use different worker
|
||||||
-- count or shard replication factor
|
-- count or shard replication factor
|
||||||
INSERT INTO agg_events
|
INSERT INTO agg_events
|
||||||
(user_id)
|
(user_id)
|
||||||
SELECT raw_events_first.user_id
|
SELECT raw_events_first.user_id
|
||||||
FROM raw_events_first,
|
FROM raw_events_first,
|
||||||
raw_events_second
|
raw_events_second
|
||||||
WHERE raw_events_second.user_id = raw_events_first.value_1
|
WHERE raw_events_second.user_id = raw_events_first.value_1
|
||||||
AND raw_events_first.value_1 = 12;
|
AND raw_events_first.value_1 = 12;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
|
||||||
-- some unsupported LEFT/INNER JOINs
|
-- some unsupported LEFT/INNER JOINs
|
||||||
-- JOIN on one table with partition column other is not
|
-- JOIN on one table with partition column other is not
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
|
@ -880,7 +871,6 @@ DETAIL: Select query cannot be pushed down to the worker.
|
||||||
raw_events_first LEFT JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.value_1;
|
raw_events_first LEFT JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.value_1;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
|
||||||
-- same as the above with INNER JOIN
|
-- same as the above with INNER JOIN
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -889,17 +879,15 @@ DETAIL: Select query cannot be pushed down to the worker.
|
||||||
raw_events_first INNER JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.value_1;
|
raw_events_first INNER JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.value_1;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
|
||||||
-- a not meaningful query
|
-- a not meaningful query
|
||||||
INSERT INTO agg_events
|
INSERT INTO agg_events
|
||||||
(user_id)
|
(user_id)
|
||||||
SELECT raw_events_second.user_id
|
SELECT raw_events_second.user_id
|
||||||
FROM raw_events_first,
|
FROM raw_events_first,
|
||||||
raw_events_second
|
raw_events_second
|
||||||
WHERE raw_events_first.user_id = raw_events_first.value_1;
|
WHERE raw_events_first.user_id = raw_events_first.value_1;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
|
||||||
-- both tables joined on non-partition columns
|
-- both tables joined on non-partition columns
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -908,7 +896,6 @@ DETAIL: Select query cannot be pushed down to the worker.
|
||||||
raw_events_first LEFT JOIN raw_events_second ON raw_events_first.value_1 = raw_events_second.value_1;
|
raw_events_first LEFT JOIN raw_events_second ON raw_events_first.value_1 = raw_events_second.value_1;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
|
||||||
-- same as the above with INNER JOIN
|
-- same as the above with INNER JOIN
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -917,7 +904,6 @@ DETAIL: Select query cannot be pushed down to the worker.
|
||||||
raw_events_first INNER JOIN raw_events_second ON raw_events_first.value_1 = raw_events_second.value_1;
|
raw_events_first INNER JOIN raw_events_second ON raw_events_first.value_1 = raw_events_second.value_1;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
|
||||||
-- even if there is a filter on the partition key, since the join is not on the partition key we reject
|
-- even if there is a filter on the partition key, since the join is not on the partition key we reject
|
||||||
-- this query
|
-- this query
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
|
@ -925,11 +911,10 @@ SELECT
|
||||||
raw_events_first.user_id
|
raw_events_first.user_id
|
||||||
FROM
|
FROM
|
||||||
raw_events_first LEFT JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.value_1
|
raw_events_first LEFT JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.value_1
|
||||||
WHERE
|
WHERE
|
||||||
raw_events_first.user_id = 10;
|
raw_events_first.user_id = 10;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
|
||||||
-- same as the above with INNER JOIN
|
-- same as the above with INNER JOIN
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -939,7 +924,6 @@ DETAIL: Select query cannot be pushed down to the worker.
|
||||||
WHERE raw_events_first.user_id = 10;
|
WHERE raw_events_first.user_id = 10;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
|
||||||
-- make things a bit more complicate with IN clauses
|
-- make things a bit more complicate with IN clauses
|
||||||
INSERT INTO agg_events (user_id)
|
INSERT INTO agg_events (user_id)
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -949,32 +933,29 @@ DETAIL: Select query cannot be pushed down to the worker.
|
||||||
WHERE raw_events_first.value_1 IN (10, 11,12) OR raw_events_second.user_id IN (1,2,3,4);
|
WHERE raw_events_first.value_1 IN (10, 11,12) OR raw_events_second.user_id IN (1,2,3,4);
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
|
||||||
-- implicit join on non partition column should also not be pushed down
|
-- implicit join on non partition column should also not be pushed down
|
||||||
INSERT INTO agg_events
|
INSERT INTO agg_events
|
||||||
(user_id)
|
(user_id)
|
||||||
SELECT raw_events_first.user_id
|
SELECT raw_events_first.user_id
|
||||||
FROM raw_events_first,
|
FROM raw_events_first,
|
||||||
raw_events_second
|
raw_events_second
|
||||||
WHERE raw_events_second.user_id = raw_events_first.value_1;
|
WHERE raw_events_second.user_id = raw_events_first.value_1;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
|
||||||
-- the following is again a tricky query for Citus
|
-- the following is again a tricky query for Citus
|
||||||
-- if the given filter was on value_1 as shown in the above, Citus could
|
-- if the given filter was on value_1 as shown in the above, Citus could
|
||||||
-- push it down. But here the query is refused
|
-- push it down. But here the query is refused
|
||||||
INSERT INTO agg_events
|
INSERT INTO agg_events
|
||||||
(user_id)
|
(user_id)
|
||||||
SELECT raw_events_first.user_id
|
SELECT raw_events_first.user_id
|
||||||
FROM raw_events_first,
|
FROM raw_events_first,
|
||||||
raw_events_second
|
raw_events_second
|
||||||
WHERE raw_events_second.user_id = raw_events_first.value_1
|
WHERE raw_events_second.user_id = raw_events_first.value_1
|
||||||
AND raw_events_first.value_2 = 12;
|
AND raw_events_first.value_2 = 12;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
|
||||||
-- lets do some unsupported query tests with subqueries
|
-- lets do some unsupported query tests with subqueries
|
||||||
-- foo is not joined on the partition key so the query is not
|
-- foo is not joined on the partition key so the query is not
|
||||||
-- pushed down
|
-- pushed down
|
||||||
INSERT INTO agg_events
|
INSERT INTO agg_events
|
||||||
(user_id, value_4_agg)
|
(user_id, value_4_agg)
|
||||||
|
@ -1008,17 +989,17 @@ ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
-- if the given filter was on value_1 as shown in the above, Citus could
|
-- if the given filter was on value_1 as shown in the above, Citus could
|
||||||
-- push it down. But here the query is refused
|
-- push it down. But here the query is refused
|
||||||
INSERT INTO agg_events
|
INSERT INTO agg_events
|
||||||
(user_id)
|
(user_id)
|
||||||
SELECT raw_events_first.user_id
|
SELECT raw_events_first.user_id
|
||||||
FROM raw_events_first,
|
FROM raw_events_first,
|
||||||
raw_events_second
|
raw_events_second
|
||||||
WHERE raw_events_second.user_id = raw_events_first.value_1
|
WHERE raw_events_second.user_id = raw_events_first.value_1
|
||||||
AND raw_events_first.value_2 = 12;
|
AND raw_events_first.value_2 = 12;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
-- lets do some unsupported query tests with subqueries
|
-- lets do some unsupported query tests with subqueries
|
||||||
-- foo is not joined on the partition key so the query is not
|
-- foo is not joined on the partition key so the query is not
|
||||||
-- pushed down
|
-- pushed down
|
||||||
INSERT INTO agg_events
|
INSERT INTO agg_events
|
||||||
(user_id, value_4_agg)
|
(user_id, value_4_agg)
|
||||||
|
@ -1177,7 +1158,7 @@ INSERT INTO agg_events
|
||||||
SELECT SUM(value_3),
|
SELECT SUM(value_3),
|
||||||
Count(value_4),
|
Count(value_4),
|
||||||
user_id,
|
user_id,
|
||||||
SUM(value_1),
|
SUM(value_1),
|
||||||
value_2
|
value_2
|
||||||
FROM raw_events_first
|
FROM raw_events_first
|
||||||
GROUP BY user_id,
|
GROUP BY user_id,
|
||||||
|
@ -1438,7 +1419,7 @@ ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
-- not supported subqueries in WHERE clause
|
-- not supported subqueries in WHERE clause
|
||||||
-- since the selected value in the WHERE is not
|
-- since the selected value in the WHERE is not
|
||||||
-- partition key
|
-- partition key
|
||||||
INSERT INTO raw_events_second
|
INSERT INTO raw_events_second
|
||||||
(user_id)
|
(user_id)
|
||||||
SELECT user_id
|
SELECT user_id
|
||||||
|
@ -1525,7 +1506,7 @@ DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300005 AS
|
||||||
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300006 AS citus_table_alias (user_id) SELECT user_id FROM public.raw_events_first_13300002 raw_events_first WHERE ((NOT (EXISTS (SELECT 1 FROM public.raw_events_second_13300006 raw_events_second WHERE (raw_events_second.user_id OPERATOR(pg_catalog.=) raw_events_first.user_id)))) AND ((worker_hash(user_id) OPERATOR(pg_catalog.>=) 0) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) 1073741823)))
|
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300006 AS citus_table_alias (user_id) SELECT user_id FROM public.raw_events_first_13300002 raw_events_first WHERE ((NOT (EXISTS (SELECT 1 FROM public.raw_events_second_13300006 raw_events_second WHERE (raw_events_second.user_id OPERATOR(pg_catalog.=) raw_events_first.user_id)))) AND ((worker_hash(user_id) OPERATOR(pg_catalog.>=) 0) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) 1073741823)))
|
||||||
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300007 AS citus_table_alias (user_id) SELECT user_id FROM public.raw_events_first_13300003 raw_events_first WHERE ((NOT (EXISTS (SELECT 1 FROM public.raw_events_second_13300007 raw_events_second WHERE (raw_events_second.user_id OPERATOR(pg_catalog.=) raw_events_first.user_id)))) AND ((worker_hash(user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) 2147483647)))
|
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300007 AS citus_table_alias (user_id) SELECT user_id FROM public.raw_events_first_13300003 raw_events_first WHERE ((NOT (EXISTS (SELECT 1 FROM public.raw_events_second_13300007 raw_events_second WHERE (raw_events_second.user_id OPERATOR(pg_catalog.=) raw_events_first.user_id)))) AND ((worker_hash(user_id) OPERATOR(pg_catalog.>=) 1073741824) AND (worker_hash(user_id) OPERATOR(pg_catalog.<=) 2147483647)))
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
-- more complex LEFT JOINs
|
-- more complex LEFT JOINs
|
||||||
INSERT INTO agg_events
|
INSERT INTO agg_events
|
||||||
(user_id, value_4_agg)
|
(user_id, value_4_agg)
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -1705,39 +1686,39 @@ TRUNCATE raw_events_first;
|
||||||
-- we don't support LIMIT for subquery pushdown, but
|
-- we don't support LIMIT for subquery pushdown, but
|
||||||
-- we recursively plan the query and run it via coordinator
|
-- we recursively plan the query and run it via coordinator
|
||||||
INSERT INTO agg_events(user_id)
|
INSERT INTO agg_events(user_id)
|
||||||
SELECT user_id
|
SELECT user_id
|
||||||
FROM users_table
|
FROM users_table
|
||||||
WHERE user_id
|
WHERE user_id
|
||||||
IN (SELECT
|
IN (SELECT
|
||||||
user_id
|
user_id
|
||||||
FROM (
|
FROM (
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
user_id
|
user_id
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
e1.user_id
|
e1.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table u1, events_table e1
|
users_table u1, events_table e1
|
||||||
WHERE
|
WHERE
|
||||||
e1.user_id = u1.user_id LIMIT 3
|
e1.user_id = u1.user_id LIMIT 3
|
||||||
) as f_inner
|
) as f_inner
|
||||||
)
|
)
|
||||||
) AS f2);
|
) AS f2);
|
||||||
-- Altering a table and selecting from it using a multi-shard statement
|
-- Altering a table and selecting from it using a multi-shard statement
|
||||||
-- in the same transaction is allowed because we will use the same
|
-- in the same transaction is allowed because we will use the same
|
||||||
-- connections for all co-located placements.
|
-- connections for all co-located placements.
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE raw_events_second DROP COLUMN value_4;
|
ALTER TABLE raw_events_second DROP COLUMN value_4;
|
||||||
INSERT INTO raw_events_first SELECT * FROM raw_events_second;
|
INSERT INTO raw_events_first SELECT * FROM raw_events_second;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- Alterating a table and selecting from it using a single-shard statement
|
-- Alterating a table and selecting from it using a single-shard statement
|
||||||
-- in the same transaction is disallowed because we will use a different
|
-- in the same transaction is disallowed because we will use a different
|
||||||
-- connection.
|
-- connection.
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE raw_events_second DROP COLUMN value_4;
|
ALTER TABLE raw_events_second DROP COLUMN value_4;
|
||||||
INSERT INTO raw_events_first SELECT * FROM raw_events_second WHERE user_id = 100;
|
INSERT INTO raw_events_first SELECT * FROM raw_events_second WHERE user_id = 100;
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- Altering a reference table and then performing an INSERT ... SELECT which
|
-- Altering a reference table and then performing an INSERT ... SELECT which
|
||||||
-- joins with the reference table is allowed, since the INSERT ... SELECT
|
-- joins with the reference table is allowed, since the INSERT ... SELECT
|
||||||
|
@ -1897,17 +1878,17 @@ INSERT INTO insert_select_varchar_test (key, value)
|
||||||
SELECT *, 100
|
SELECT *, 100
|
||||||
FROM (SELECT f1.key
|
FROM (SELECT f1.key
|
||||||
FROM (SELECT key
|
FROM (SELECT key
|
||||||
FROM insert_select_varchar_test
|
FROM insert_select_varchar_test
|
||||||
GROUP BY 1
|
GROUP BY 1
|
||||||
HAVING Count(key) < 3) AS f1,
|
HAVING Count(key) < 3) AS f1,
|
||||||
(SELECT key
|
(SELECT key
|
||||||
FROM insert_select_varchar_test
|
FROM insert_select_varchar_test
|
||||||
GROUP BY 1
|
GROUP BY 1
|
||||||
HAVING Sum(COALESCE(insert_select_varchar_test.value, 0)) >
|
HAVING Sum(COALESCE(insert_select_varchar_test.value, 0)) >
|
||||||
20.0)
|
20.0)
|
||||||
AS f2
|
AS f2
|
||||||
WHERE f1.key = f2.key
|
WHERE f1.key = f2.key
|
||||||
GROUP BY 1) AS foo;
|
GROUP BY 1) AS foo;
|
||||||
SELECT * FROM insert_select_varchar_test ORDER BY 1 DESC, 2 DESC;
|
SELECT * FROM insert_select_varchar_test ORDER BY 1 DESC, 2 DESC;
|
||||||
key | value
|
key | value
|
||||||
--------+-------
|
--------+-------
|
||||||
|
@ -1920,7 +1901,7 @@ SELECT * FROM insert_select_varchar_test ORDER BY 1 DESC, 2 DESC;
|
||||||
-- this test is mostly importantly intended for deparsing the query correctly
|
-- this test is mostly importantly intended for deparsing the query correctly
|
||||||
-- but still it is preferable to have this test here instead of multi_deparse_shard_query
|
-- but still it is preferable to have this test here instead of multi_deparse_shard_query
|
||||||
CREATE TABLE table_with_defaults
|
CREATE TABLE table_with_defaults
|
||||||
(
|
(
|
||||||
store_id int,
|
store_id int,
|
||||||
first_name text,
|
first_name text,
|
||||||
default_1 int DEFAULT 1,
|
default_1 int DEFAULT 1,
|
||||||
|
@ -2101,10 +2082,10 @@ SELECT create_distributed_table('table_with_starts_with_defaults', 'c');
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SET client_min_messages TO DEBUG;
|
SET client_min_messages TO DEBUG;
|
||||||
INSERT INTO text_table (part_col)
|
INSERT INTO text_table (part_col)
|
||||||
SELECT
|
SELECT
|
||||||
CASE WHEN part_col = 'onder' THEN 'marco'
|
CASE WHEN part_col = 'onder' THEN 'marco'
|
||||||
END
|
END
|
||||||
FROM text_table ;
|
FROM text_table ;
|
||||||
DEBUG: cannot perform distributed INSERT INTO ... SELECT because the partition columns in the source table and subquery do not match
|
DEBUG: cannot perform distributed INSERT INTO ... SELECT because the partition columns in the source table and subquery do not match
|
||||||
DETAIL: Subquery contains a case expression in the same position as the target table's partition column.
|
DETAIL: Subquery contains a case expression in the same position as the target table's partition column.
|
||||||
|
@ -2166,7 +2147,7 @@ DEBUG: Collecting INSERT ... SELECT results on coordinator
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
insert into table_with_starts_with_defaults (b,c) select b,c FROM table_with_starts_with_defaults;
|
insert into table_with_starts_with_defaults (b,c) select b,c FROM table_with_starts_with_defaults;
|
||||||
-- Test on partition column without native hash function
|
-- Test on partition column without native hash function
|
||||||
CREATE TABLE raw_table
|
CREATE TABLE raw_table
|
||||||
(
|
(
|
||||||
id BIGINT,
|
id BIGINT,
|
||||||
|
@ -2774,9 +2755,9 @@ SELECT * FROM coerce_agg ORDER BY 1 DESC, 2 DESC;
|
||||||
|
|
||||||
-- INSERT..SELECT + prepared statements + recursive planning
|
-- INSERT..SELECT + prepared statements + recursive planning
|
||||||
BEGIN;
|
BEGIN;
|
||||||
PREPARE prepared_recursive_insert_select AS
|
PREPARE prepared_recursive_insert_select AS
|
||||||
INSERT INTO users_table
|
INSERT INTO users_table
|
||||||
SELECT * FROM users_table
|
SELECT * FROM users_table
|
||||||
WHERE value_1 IN (SELECT value_2 FROM events_table OFFSET 0);
|
WHERE value_1 IN (SELECT value_2 FROM events_table OFFSET 0);
|
||||||
EXECUTE prepared_recursive_insert_select;
|
EXECUTE prepared_recursive_insert_select;
|
||||||
EXECUTE prepared_recursive_insert_select;
|
EXECUTE prepared_recursive_insert_select;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
------------------------------------
|
------------------------------------
|
||||||
------------------------------------
|
------------------------------------
|
||||||
CREATE TABLE test_table_1(id int);
|
CREATE TABLE test_table_1(id int);
|
||||||
INSERT INTO test_table_1
|
INSERT INTO test_table_1
|
||||||
SELECT user_id FROM users_table;
|
SELECT user_id FROM users_table;
|
||||||
ERROR: cannot INSERT rows from a distributed query into a local table
|
ERROR: cannot INSERT rows from a distributed query into a local table
|
||||||
HINT: Consider using CREATE TEMPORARY TABLE tmp AS SELECT ... and inserting from the temporary table.
|
HINT: Consider using CREATE TEMPORARY TABLE tmp AS SELECT ... and inserting from the temporary table.
|
||||||
|
@ -67,10 +67,9 @@ FROM (
|
||||||
AND e.event_type IN (103, 104, 105)
|
AND e.event_type IN (103, 104, 105)
|
||||||
)
|
)
|
||||||
) t1 LEFT JOIN (
|
) t1 LEFT JOIN (
|
||||||
SELECT DISTINCT user_id,
|
SELECT DISTINCT user_id,
|
||||||
'Has done event'::TEXT AS hasdone_event
|
'Has done event'::TEXT AS hasdone_event
|
||||||
FROM events_table AS e
|
FROM events_table AS e
|
||||||
|
|
||||||
WHERE e.user_id >= 10
|
WHERE e.user_id >= 10
|
||||||
AND e.user_id <= 25
|
AND e.user_id <= 25
|
||||||
AND e.event_type IN (106, 107, 108)
|
AND e.event_type IN (106, 107, 108)
|
||||||
|
@ -108,10 +107,9 @@ FROM (
|
||||||
AND e.event_type IN (103, 104, 105)
|
AND e.event_type IN (103, 104, 105)
|
||||||
)
|
)
|
||||||
) t1 LEFT JOIN (
|
) t1 LEFT JOIN (
|
||||||
SELECT DISTINCT user_id,
|
SELECT DISTINCT user_id,
|
||||||
'Has done event'::TEXT AS hasdone_event
|
'Has done event'::TEXT AS hasdone_event
|
||||||
FROM events_table AS e
|
FROM events_table AS e
|
||||||
|
|
||||||
WHERE e.user_id >= 10
|
WHERE e.user_id >= 10
|
||||||
AND e.user_id <= 25
|
AND e.user_id <= 25
|
||||||
AND e.event_type IN (106, 107, 108)
|
AND e.event_type IN (106, 107, 108)
|
||||||
|
@ -151,10 +149,9 @@ FROM (
|
||||||
AND e.event_type IN (103, 104, 105)
|
AND e.event_type IN (103, 104, 105)
|
||||||
)
|
)
|
||||||
) t1 LEFT JOIN (
|
) t1 LEFT JOIN (
|
||||||
SELECT DISTINCT user_id,
|
SELECT DISTINCT user_id,
|
||||||
'Has done event'::TEXT AS hasdone_event
|
'Has done event'::TEXT AS hasdone_event
|
||||||
FROM events_table AS e
|
FROM events_table AS e
|
||||||
|
|
||||||
WHERE e.user_id >= 10
|
WHERE e.user_id >= 10
|
||||||
AND e.user_id <= 25
|
AND e.user_id <= 25
|
||||||
AND e.event_type IN (106, 107, 108)
|
AND e.event_type IN (106, 107, 108)
|
||||||
|
@ -225,7 +222,7 @@ SELECT
|
||||||
users_table
|
users_table
|
||||||
WHERE
|
WHERE
|
||||||
user_id >= 10 AND
|
user_id >= 10 AND
|
||||||
user_id <= 70 AND
|
user_id <= 70 AND
|
||||||
users_table.value_1 > 15 AND users_table.value_1 < 17
|
users_table.value_1 > 15 AND users_table.value_1 < 17
|
||||||
GROUP BY
|
GROUP BY
|
||||||
user_id
|
user_id
|
||||||
|
@ -295,7 +292,7 @@ SELECT
|
||||||
users_table
|
users_table
|
||||||
WHERE
|
WHERE
|
||||||
user_id >= 10 AND
|
user_id >= 10 AND
|
||||||
user_id <= 70 AND
|
user_id <= 70 AND
|
||||||
users_table.value_1 > 15 AND users_table.value_1 < 17
|
users_table.value_1 > 15 AND users_table.value_1 < 17
|
||||||
GROUP BY
|
GROUP BY
|
||||||
user_id
|
user_id
|
||||||
|
@ -340,7 +337,6 @@ FROM (
|
||||||
max(u.time) as user_lastseen,
|
max(u.time) as user_lastseen,
|
||||||
array_agg(event_type ORDER BY u.time) AS event_array
|
array_agg(event_type ORDER BY u.time) AS event_array
|
||||||
FROM (
|
FROM (
|
||||||
|
|
||||||
SELECT user_id, time
|
SELECT user_id, time
|
||||||
FROM users_table
|
FROM users_table
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -370,7 +366,6 @@ FROM (
|
||||||
max(u.time) as user_lastseen,
|
max(u.time) as user_lastseen,
|
||||||
array_agg(event_type ORDER BY u.time) AS event_array
|
array_agg(event_type ORDER BY u.time) AS event_array
|
||||||
FROM (
|
FROM (
|
||||||
|
|
||||||
SELECT user_id, time
|
SELECT user_id, time
|
||||||
FROM users_table
|
FROM users_table
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -400,7 +395,6 @@ FROM (
|
||||||
max(u.time) as user_lastseen,
|
max(u.time) as user_lastseen,
|
||||||
array_agg(event_type ORDER BY u.time) AS event_array
|
array_agg(event_type ORDER BY u.time) AS event_array
|
||||||
FROM (
|
FROM (
|
||||||
|
|
||||||
SELECT user_id, time, value_3 as val_3
|
SELECT user_id, time, value_3 as val_3
|
||||||
FROM users_table
|
FROM users_table
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -519,7 +513,6 @@ SELECT user_id, value_2 FROM users_table WHERE
|
||||||
AND NOT EXISTS (SELECT user_id FROM events_table WHERE event_type > 300 AND event_type <= 350 AND value_3 > 100 AND user_id=users_table.user_id);
|
AND NOT EXISTS (SELECT user_id FROM events_table WHERE event_type > 300 AND event_type <= 350 AND value_3 > 100 AND user_id=users_table.user_id);
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
|
||||||
------------------------------------
|
------------------------------------
|
||||||
------------------------------------
|
------------------------------------
|
||||||
-- Customers who have done X more than 2 times, and satisfy other customer specific criteria
|
-- Customers who have done X more than 2 times, and satisfy other customer specific criteria
|
||||||
|
@ -527,55 +520,55 @@ DETAIL: Select query cannot be pushed down to the worker.
|
||||||
------------------------------------
|
------------------------------------
|
||||||
-- not pushable since the second join is not an equi join
|
-- not pushable since the second join is not an equi join
|
||||||
INSERT INTO agg_results_third(user_id, value_2_agg)
|
INSERT INTO agg_results_third(user_id, value_2_agg)
|
||||||
SELECT user_id,
|
SELECT user_id,
|
||||||
value_2
|
value_2
|
||||||
FROM users_table
|
FROM users_table
|
||||||
WHERE value_1 > 100
|
WHERE value_1 > 100
|
||||||
AND value_1 < 124
|
AND value_1 < 124
|
||||||
AND value_2 >= 5
|
AND value_2 >= 5
|
||||||
AND EXISTS (SELECT user_id
|
AND EXISTS (SELECT user_id
|
||||||
FROM events_table
|
FROM events_table
|
||||||
WHERE event_type > 100
|
WHERE event_type > 100
|
||||||
AND event_type < 124
|
AND event_type < 124
|
||||||
AND value_3 > 100
|
AND value_3 > 100
|
||||||
AND user_id != users_table.user_id
|
AND user_id != users_table.user_id
|
||||||
GROUP BY user_id
|
GROUP BY user_id
|
||||||
HAVING Count(*) > 2);
|
HAVING Count(*) > 2);
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
-- not pushable since the second join is not on the partition key
|
-- not pushable since the second join is not on the partition key
|
||||||
INSERT INTO agg_results_third(user_id, value_2_agg)
|
INSERT INTO agg_results_third(user_id, value_2_agg)
|
||||||
SELECT user_id,
|
SELECT user_id,
|
||||||
value_2
|
value_2
|
||||||
FROM users_table
|
FROM users_table
|
||||||
WHERE value_1 > 100
|
WHERE value_1 > 100
|
||||||
AND value_1 < 124
|
AND value_1 < 124
|
||||||
AND value_2 >= 5
|
AND value_2 >= 5
|
||||||
AND EXISTS (SELECT user_id
|
AND EXISTS (SELECT user_id
|
||||||
FROM events_table
|
FROM events_table
|
||||||
WHERE event_type > 100
|
WHERE event_type > 100
|
||||||
AND event_type < 124
|
AND event_type < 124
|
||||||
AND value_3 > 100
|
AND value_3 > 100
|
||||||
AND event_type = users_table.user_id
|
AND event_type = users_table.user_id
|
||||||
GROUP BY user_id
|
GROUP BY user_id
|
||||||
HAVING Count(*) > 2);
|
HAVING Count(*) > 2);
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
-- not pushable since the second join is not on the partition key
|
-- not pushable since the second join is not on the partition key
|
||||||
INSERT INTO agg_results_third(user_id, value_2_agg)
|
INSERT INTO agg_results_third(user_id, value_2_agg)
|
||||||
SELECT user_id,
|
SELECT user_id,
|
||||||
value_2
|
value_2
|
||||||
FROM users_table
|
FROM users_table
|
||||||
WHERE value_1 > 100
|
WHERE value_1 > 100
|
||||||
AND value_1 < 124
|
AND value_1 < 124
|
||||||
AND value_2 >= 5
|
AND value_2 >= 5
|
||||||
AND EXISTS (SELECT user_id
|
AND EXISTS (SELECT user_id
|
||||||
FROM events_table
|
FROM events_table
|
||||||
WHERE event_type > 100
|
WHERE event_type > 100
|
||||||
AND event_type < 124
|
AND event_type < 124
|
||||||
AND value_3 > 100
|
AND value_3 > 100
|
||||||
AND user_id = users_table.value_1
|
AND user_id = users_table.value_1
|
||||||
GROUP BY user_id
|
GROUP BY user_id
|
||||||
HAVING Count(*) > 2);
|
HAVING Count(*) > 2);
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
@ -594,7 +587,7 @@ And user_id NOT in
|
||||||
(select user_id
|
(select user_id
|
||||||
From users_table
|
From users_table
|
||||||
Where value_1 = 15
|
Where value_1 = 15
|
||||||
And value_2 > 25);
|
And value_2 > 25);
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
-- not pushable since we're not selecting the partition key
|
-- not pushable since we're not selecting the partition key
|
||||||
|
@ -607,10 +600,9 @@ And user_id in
|
||||||
(select value_3
|
(select value_3
|
||||||
From users_table
|
From users_table
|
||||||
Where value_1 = 15
|
Where value_1 = 15
|
||||||
And value_2 > 25);
|
And value_2 > 25);
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
|
||||||
-- not pushable since we're not selecting the partition key
|
-- not pushable since we're not selecting the partition key
|
||||||
-- from the events table
|
-- from the events table
|
||||||
INSERT INTO agg_results_third(user_id)
|
INSERT INTO agg_results_third(user_id)
|
||||||
|
@ -622,7 +614,7 @@ And event_type in
|
||||||
(select user_id
|
(select user_id
|
||||||
From users_table
|
From users_table
|
||||||
Where value_1 = 15
|
Where value_1 = 15
|
||||||
And value_2 > 25);
|
And value_2 > 25);
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
@ -660,17 +652,17 @@ DETAIL: Select query cannot be pushed down to the worker.
|
||||||
INSERT INTO agg_results_third(user_id, value_1_agg, value_3_agg)
|
INSERT INTO agg_results_third(user_id, value_1_agg, value_3_agg)
|
||||||
SELECT
|
SELECT
|
||||||
users_table.user_id, users_table.value_1, prob
|
users_table.user_id, users_table.value_1, prob
|
||||||
FROM
|
FROM
|
||||||
users_table
|
users_table
|
||||||
JOIN
|
JOIN
|
||||||
(SELECT
|
(SELECT
|
||||||
ma.user_id, (GREATEST(coalesce(ma.value_4 / 250, 0.0) + GREATEST(1.0))) / 2 AS prob
|
ma.user_id, (GREATEST(coalesce(ma.value_4 / 250, 0.0) + GREATEST(1.0))) / 2 AS prob
|
||||||
FROM
|
FROM
|
||||||
users_table AS ma, events_table as short_list
|
users_table AS ma, events_table as short_list
|
||||||
WHERE
|
WHERE
|
||||||
short_list.user_id != ma.user_id and ma.value_1 < 50 and short_list.event_type < 50
|
short_list.user_id != ma.user_id and ma.value_1 < 50 and short_list.event_type < 50
|
||||||
) temp
|
) temp
|
||||||
ON users_table.user_id = temp.user_id
|
ON users_table.user_id = temp.user_id
|
||||||
WHERE users_table.value_1 < 50;
|
WHERE users_table.value_1 < 50;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
@ -678,17 +670,17 @@ DETAIL: Select query cannot be pushed down to the worker.
|
||||||
INSERT INTO agg_results_third(user_id, value_1_agg, value_3_agg)
|
INSERT INTO agg_results_third(user_id, value_1_agg, value_3_agg)
|
||||||
SELECT
|
SELECT
|
||||||
users_table.user_id, users_table.value_1, prob
|
users_table.user_id, users_table.value_1, prob
|
||||||
FROM
|
FROM
|
||||||
users_table
|
users_table
|
||||||
JOIN
|
JOIN
|
||||||
(SELECT
|
(SELECT
|
||||||
ma.user_id, (GREATEST(coalesce(ma.value_4 / 250, 0.0) + GREATEST(1.0))) / 2 AS prob
|
ma.user_id, (GREATEST(coalesce(ma.value_4 / 250, 0.0) + GREATEST(1.0))) / 2 AS prob
|
||||||
FROM
|
FROM
|
||||||
users_table AS ma, events_table as short_list
|
users_table AS ma, events_table as short_list
|
||||||
WHERE
|
WHERE
|
||||||
short_list.user_id = ma.value_2 and ma.value_1 < 50 and short_list.event_type < 50
|
short_list.user_id = ma.value_2 and ma.value_1 < 50 and short_list.event_type < 50
|
||||||
) temp
|
) temp
|
||||||
ON users_table.user_id = temp.user_id
|
ON users_table.user_id = temp.user_id
|
||||||
WHERE users_table.value_1 < 50;
|
WHERE users_table.value_1 < 50;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
|
|
|
@ -10,7 +10,7 @@ SELECT json_agg(value) FROM (
|
||||||
) t
|
) t
|
||||||
$$;
|
$$;
|
||||||
-- Check multi_cat_agg() aggregate which is used to implement json_agg()
|
-- Check multi_cat_agg() aggregate which is used to implement json_agg()
|
||||||
SELECT json_cat_agg(i) FROM
|
SELECT json_cat_agg(i) FROM
|
||||||
(VALUES ('[1,{"a":2}]'::json), ('[null]'::json), (NULL), ('["3",5,4]'::json)) AS t(i);
|
(VALUES ('[1,{"a":2}]'::json), ('[null]'::json), (NULL), ('["3",5,4]'::json)) AS t(i);
|
||||||
json_cat_agg
|
json_cat_agg
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
@ -141,7 +141,6 @@ SELECT json_agg(case when l_quantity > 20 then l_quantity else NULL end)
|
||||||
[null, 36.00, null, 28.00, 24.00, 32.00, 38.00, 45.00, 49.00, 27.00, null, 28.00, 26.00, 30.00]
|
[null, 36.00, null, 28.00, 24.00, 32.00, 38.00, 45.00, 49.00, 27.00, null, 28.00, 26.00, 30.00]
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- Check that we can execute json_agg() with an expression containing different types
|
-- Check that we can execute json_agg() with an expression containing different types
|
||||||
SELECT json_agg(case when l_quantity > 20 then to_json(l_quantity) else '"f"'::json end)
|
SELECT json_agg(case when l_quantity > 20 then to_json(l_quantity) else '"f"'::json end)
|
||||||
FROM lineitem WHERE l_orderkey < 5;
|
FROM lineitem WHERE l_orderkey < 5;
|
||||||
|
@ -150,7 +149,6 @@ SELECT json_agg(case when l_quantity > 20 then to_json(l_quantity) else '"f"'::j
|
||||||
["f", 36.00, "f", 28.00, 24.00, 32.00, 38.00, 45.00, 49.00, 27.00, "f", 28.00, 26.00, 30.00]
|
["f", 36.00, "f", 28.00, 24.00, 32.00, 38.00, 45.00, 49.00, 27.00, "f", 28.00, 26.00, 30.00]
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- Check that we can execute json_agg() with an expression containing json arrays
|
-- Check that we can execute json_agg() with an expression containing json arrays
|
||||||
SELECT json_agg(json_build_array(l_quantity, l_shipdate))
|
SELECT json_agg(json_build_array(l_quantity, l_shipdate))
|
||||||
FROM lineitem WHERE l_orderkey < 3;
|
FROM lineitem WHERE l_orderkey < 3;
|
||||||
|
@ -159,7 +157,6 @@ SELECT json_agg(json_build_array(l_quantity, l_shipdate))
|
||||||
[[17.00, "1996-03-13"], [36.00, "1996-04-12"], [8.00, "1996-01-29"], [28.00, "1996-04-21"], [24.00, "1996-03-30"], [32.00, "1996-01-30"], [38.00, "1997-01-28"]]
|
[[17.00, "1996-03-13"], [36.00, "1996-04-12"], [8.00, "1996-01-29"], [28.00, "1996-04-21"], [24.00, "1996-03-30"], [32.00, "1996-01-30"], [38.00, "1997-01-28"]]
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- Check that we can execute json_agg() with an expression containing arrays
|
-- Check that we can execute json_agg() with an expression containing arrays
|
||||||
SELECT json_agg(ARRAY[l_quantity, l_orderkey])
|
SELECT json_agg(ARRAY[l_quantity, l_orderkey])
|
||||||
FROM lineitem WHERE l_orderkey < 3;
|
FROM lineitem WHERE l_orderkey < 3;
|
||||||
|
|
|
@ -15,7 +15,7 @@ SELECT json_object_agg(key, value) FROM (
|
||||||
) t
|
) t
|
||||||
$$;
|
$$;
|
||||||
-- Check multi_cat_agg() aggregate which is used to implement json_object_agg()
|
-- Check multi_cat_agg() aggregate which is used to implement json_object_agg()
|
||||||
SELECT json_cat_agg(i) FROM
|
SELECT json_cat_agg(i) FROM
|
||||||
(VALUES ('{"c":[], "b":2}'::json), (NULL), ('{"d":null, "a":{"b":3}, "b":2}'::json)) AS t(i);
|
(VALUES ('{"c":[], "b":2}'::json), (NULL), ('{"d":null, "a":{"b":3}, "b":2}'::json)) AS t(i);
|
||||||
json_cat_agg
|
json_cat_agg
|
||||||
-----------------------------------------------------------
|
-----------------------------------------------------------
|
||||||
|
@ -30,7 +30,7 @@ ERROR: json_object_agg with order by is unsupported
|
||||||
SELECT json_object_agg(distinct l_orderkey, l_shipmode ORDER BY l_orderkey) FROM lineitem;
|
SELECT json_object_agg(distinct l_orderkey, l_shipmode ORDER BY l_orderkey) FROM lineitem;
|
||||||
ERROR: json_object_agg with order by is unsupported
|
ERROR: json_object_agg with order by is unsupported
|
||||||
-- Check json_object_agg() for different data types and LIMIT clauses
|
-- Check json_object_agg() for different data types and LIMIT clauses
|
||||||
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_partkey))
|
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_partkey))
|
||||||
FROM lineitem GROUP BY l_orderkey
|
FROM lineitem GROUP BY l_orderkey
|
||||||
ORDER BY l_orderkey LIMIT 10;
|
ORDER BY l_orderkey LIMIT 10;
|
||||||
keys_sort
|
keys_sort
|
||||||
|
@ -47,7 +47,7 @@ SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_partk
|
||||||
{ "341" : 88362, "342" : 89414, "343" : 169544 }
|
{ "341" : 88362, "342" : 89414, "343" : 169544 }
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_extendedprice))
|
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_extendedprice))
|
||||||
FROM lineitem GROUP BY l_orderkey
|
FROM lineitem GROUP BY l_orderkey
|
||||||
ORDER BY l_orderkey LIMIT 10;
|
ORDER BY l_orderkey LIMIT 10;
|
||||||
keys_sort
|
keys_sort
|
||||||
|
@ -64,7 +64,7 @@ SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_exten
|
||||||
{ "341" : 17554.68, "342" : 30875.02, "343" : 9681.24 }
|
{ "341" : 17554.68, "342" : 30875.02, "343" : 9681.24 }
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_shipmode))
|
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_shipmode))
|
||||||
FROM lineitem GROUP BY l_orderkey
|
FROM lineitem GROUP BY l_orderkey
|
||||||
ORDER BY l_orderkey LIMIT 10;
|
ORDER BY l_orderkey LIMIT 10;
|
||||||
keys_sort
|
keys_sort
|
||||||
|
@ -81,7 +81,7 @@ SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_shipm
|
||||||
{ "341" : "REG AIR ", "342" : "FOB ", "343" : "FOB " }
|
{ "341" : "REG AIR ", "342" : "FOB ", "343" : "FOB " }
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_shipdate))
|
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_shipdate))
|
||||||
FROM lineitem GROUP BY l_orderkey
|
FROM lineitem GROUP BY l_orderkey
|
||||||
ORDER BY l_orderkey LIMIT 10;
|
ORDER BY l_orderkey LIMIT 10;
|
||||||
keys_sort
|
keys_sort
|
||||||
|
@ -109,8 +109,8 @@ SELECT count_keys(json_object_agg(l_shipdate, l_orderkey)) FROM lineitem;
|
||||||
-- shards and contain different aggregates, filter clauses and other complex
|
-- shards and contain different aggregates, filter clauses and other complex
|
||||||
-- expressions. Note that the l_orderkey ranges are such that the matching rows
|
-- expressions. Note that the l_orderkey ranges are such that the matching rows
|
||||||
-- lie in different shards.
|
-- lie in different shards.
|
||||||
SELECT l_quantity, count(*), avg(l_extendedprice),
|
SELECT l_quantity, count(*), avg(l_extendedprice),
|
||||||
keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_shipdate))
|
keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_shipdate))
|
||||||
FROM lineitem
|
FROM lineitem
|
||||||
WHERE l_quantity < 5 AND l_orderkey > 5000 AND l_orderkey < 5300
|
WHERE l_quantity < 5 AND l_orderkey > 5000 AND l_orderkey < 5300
|
||||||
GROUP BY l_quantity ORDER BY l_quantity;
|
GROUP BY l_quantity ORDER BY l_quantity;
|
||||||
|
@ -122,7 +122,7 @@ SELECT l_quantity, count(*), avg(l_extendedprice),
|
||||||
4.00 | 4 | 5795.6800000000000000 | { "50313" : "1994-12-26", "50622" : "1993-02-06", "50891" : "1992-09-18", "51893" : "1993-12-21" }
|
4.00 | 4 | 5795.6800000000000000 | { "50313" : "1994-12-26", "50622" : "1993-02-06", "50891" : "1992-09-18", "51893" : "1993-12-21" }
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT l_quantity, keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text,
|
SELECT l_quantity, keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text,
|
||||||
extract (month FROM o_orderdate)))
|
extract (month FROM o_orderdate)))
|
||||||
FROM lineitem, orders WHERE l_orderkey = o_orderkey AND l_quantity < 5
|
FROM lineitem, orders WHERE l_orderkey = o_orderkey AND l_quantity < 5
|
||||||
AND l_orderkey > 5000 AND l_orderkey < 5300 GROUP BY l_quantity ORDER BY l_quantity;
|
AND l_orderkey > 5000 AND l_orderkey < 5300 GROUP BY l_quantity ORDER BY l_quantity;
|
||||||
|
@ -134,7 +134,7 @@ SELECT l_quantity, keys_sort(json_object_agg(l_orderkey::text || l_linenumber::t
|
||||||
4.00 | { "50313" : 12, "50622" : 10, "50891" : 7, "51893" : 11 }
|
4.00 | { "50313" : 12, "50622" : 10, "50891" : 7, "51893" : 11 }
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT l_quantity, keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_orderkey * 2 + 1))
|
SELECT l_quantity, keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, l_orderkey * 2 + 1))
|
||||||
FROM lineitem WHERE l_quantity < 5
|
FROM lineitem WHERE l_quantity < 5
|
||||||
AND octet_length(l_comment) + octet_length('randomtext'::text) > 40
|
AND octet_length(l_comment) + octet_length('randomtext'::text) > 40
|
||||||
AND l_orderkey > 5000 AND l_orderkey < 6000 GROUP BY l_quantity ORDER BY l_quantity;
|
AND l_orderkey > 5000 AND l_orderkey < 6000 GROUP BY l_quantity ORDER BY l_quantity;
|
||||||
|
@ -147,7 +147,7 @@ SELECT l_quantity, keys_sort(json_object_agg(l_orderkey::text || l_linenumber::t
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
-- Check that we can execute json_object_agg() with an expression containing NULL values
|
-- Check that we can execute json_object_agg() with an expression containing NULL values
|
||||||
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text,
|
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text,
|
||||||
case when l_quantity > 20 then l_quantity else NULL end))
|
case when l_quantity > 20 then l_quantity else NULL end))
|
||||||
FROM lineitem WHERE l_orderkey < 5;
|
FROM lineitem WHERE l_orderkey < 5;
|
||||||
keys_sort
|
keys_sort
|
||||||
|
@ -155,9 +155,8 @@ SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text,
|
||||||
{ "11" : null, "12" : 36.00, "13" : null, "14" : 28.00, "15" : 24.00, "16" : 32.00, "21" : 38.00, "31" : 45.00, "32" : 49.00, "33" : 27.00, "34" : null, "35" : 28.00, "36" : 26.00, "41" : 30.00 }
|
{ "11" : null, "12" : 36.00, "13" : null, "14" : 28.00, "15" : 24.00, "16" : 32.00, "21" : 38.00, "31" : 45.00, "32" : 49.00, "33" : 27.00, "34" : null, "35" : 28.00, "36" : 26.00, "41" : 30.00 }
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- Check that we can execute json_object_agg() with an expression containing different types
|
-- Check that we can execute json_object_agg() with an expression containing different types
|
||||||
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text,
|
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text,
|
||||||
case when l_quantity > 20 then to_json(l_quantity) else '"f"'::json end))
|
case when l_quantity > 20 then to_json(l_quantity) else '"f"'::json end))
|
||||||
FROM lineitem WHERE l_orderkey < 5;
|
FROM lineitem WHERE l_orderkey < 5;
|
||||||
keys_sort
|
keys_sort
|
||||||
|
@ -165,7 +164,6 @@ SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text,
|
||||||
{ "11" : "f", "12" : 36.00, "13" : "f", "14" : 28.00, "15" : 24.00, "16" : 32.00, "21" : 38.00, "31" : 45.00, "32" : 49.00, "33" : 27.00, "34" : "f", "35" : 28.00, "36" : 26.00, "41" : 30.00 }
|
{ "11" : "f", "12" : 36.00, "13" : "f", "14" : 28.00, "15" : 24.00, "16" : 32.00, "21" : 38.00, "31" : 45.00, "32" : 49.00, "33" : 27.00, "34" : "f", "35" : 28.00, "36" : 26.00, "41" : 30.00 }
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- Check that we can execute json_object_agg() with an expression containing json arrays
|
-- Check that we can execute json_object_agg() with an expression containing json arrays
|
||||||
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, json_build_array(l_quantity, l_shipdate)))
|
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, json_build_array(l_quantity, l_shipdate)))
|
||||||
FROM lineitem WHERE l_orderkey < 3;
|
FROM lineitem WHERE l_orderkey < 3;
|
||||||
|
@ -174,7 +172,6 @@ SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, json_bu
|
||||||
{ "11" : [17.00, "1996-03-13"], "12" : [36.00, "1996-04-12"], "13" : [8.00, "1996-01-29"], "14" : [28.00, "1996-04-21"], "15" : [24.00, "1996-03-30"], "16" : [32.00, "1996-01-30"], "21" : [38.00, "1997-01-28"] }
|
{ "11" : [17.00, "1996-03-13"], "12" : [36.00, "1996-04-12"], "13" : [8.00, "1996-01-29"], "14" : [28.00, "1996-04-21"], "15" : [24.00, "1996-03-30"], "16" : [32.00, "1996-01-30"], "21" : [38.00, "1997-01-28"] }
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- Check that we can execute json_object_agg() with an expression containing arrays
|
-- Check that we can execute json_object_agg() with an expression containing arrays
|
||||||
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, ARRAY[l_quantity, l_orderkey]))
|
SELECT keys_sort(json_object_agg(l_orderkey::text || l_linenumber::text, ARRAY[l_quantity, l_orderkey]))
|
||||||
FROM lineitem WHERE l_orderkey < 3;
|
FROM lineitem WHERE l_orderkey < 3;
|
||||||
|
|
|
@ -10,7 +10,7 @@ SELECT jsonb_agg(value) FROM (
|
||||||
) t
|
) t
|
||||||
$$;
|
$$;
|
||||||
-- Check multi_cat_agg() aggregate which is used to implement jsonb_agg()
|
-- Check multi_cat_agg() aggregate which is used to implement jsonb_agg()
|
||||||
SELECT jsonb_cat_agg(i) FROM
|
SELECT jsonb_cat_agg(i) FROM
|
||||||
(VALUES ('[1,{"a":2}]'::jsonb), ('[null]'::jsonb), (NULL), ('["3",5,4]'::jsonb)) AS t(i);
|
(VALUES ('[1,{"a":2}]'::jsonb), ('[null]'::jsonb), (NULL), ('["3",5,4]'::jsonb)) AS t(i);
|
||||||
jsonb_cat_agg
|
jsonb_cat_agg
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
@ -141,7 +141,6 @@ SELECT jsonb_agg(case when l_quantity > 20 then l_quantity else NULL end)
|
||||||
[null, 36.00, null, 28.00, 24.00, 32.00, 38.00, 45.00, 49.00, 27.00, null, 28.00, 26.00, 30.00]
|
[null, 36.00, null, 28.00, 24.00, 32.00, 38.00, 45.00, 49.00, 27.00, null, 28.00, 26.00, 30.00]
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- Check that we can execute jsonb_agg() with an expression containing different types
|
-- Check that we can execute jsonb_agg() with an expression containing different types
|
||||||
SELECT jsonb_agg(case when l_quantity > 20 then to_jsonb(l_quantity) else '"f"'::jsonb end)
|
SELECT jsonb_agg(case when l_quantity > 20 then to_jsonb(l_quantity) else '"f"'::jsonb end)
|
||||||
FROM lineitem WHERE l_orderkey < 5;
|
FROM lineitem WHERE l_orderkey < 5;
|
||||||
|
@ -150,7 +149,6 @@ SELECT jsonb_agg(case when l_quantity > 20 then to_jsonb(l_quantity) else '"f"':
|
||||||
["f", 36.00, "f", 28.00, 24.00, 32.00, 38.00, 45.00, 49.00, 27.00, "f", 28.00, 26.00, 30.00]
|
["f", 36.00, "f", 28.00, 24.00, 32.00, 38.00, 45.00, 49.00, 27.00, "f", 28.00, 26.00, 30.00]
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- Check that we can execute jsonb_agg() with an expression containing jsonb arrays
|
-- Check that we can execute jsonb_agg() with an expression containing jsonb arrays
|
||||||
SELECT jsonb_agg(jsonb_build_array(l_quantity, l_shipdate))
|
SELECT jsonb_agg(jsonb_build_array(l_quantity, l_shipdate))
|
||||||
FROM lineitem WHERE l_orderkey < 3;
|
FROM lineitem WHERE l_orderkey < 3;
|
||||||
|
@ -159,7 +157,6 @@ SELECT jsonb_agg(jsonb_build_array(l_quantity, l_shipdate))
|
||||||
[[17.00, "1996-03-13"], [36.00, "1996-04-12"], [8.00, "1996-01-29"], [28.00, "1996-04-21"], [24.00, "1996-03-30"], [32.00, "1996-01-30"], [38.00, "1997-01-28"]]
|
[[17.00, "1996-03-13"], [36.00, "1996-04-12"], [8.00, "1996-01-29"], [28.00, "1996-04-21"], [24.00, "1996-03-30"], [32.00, "1996-01-30"], [38.00, "1997-01-28"]]
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- Check that we can execute jsonb_agg() with an expression containing arrays
|
-- Check that we can execute jsonb_agg() with an expression containing arrays
|
||||||
SELECT jsonb_agg(ARRAY[l_quantity, l_orderkey])
|
SELECT jsonb_agg(ARRAY[l_quantity, l_orderkey])
|
||||||
FROM lineitem WHERE l_orderkey < 3;
|
FROM lineitem WHERE l_orderkey < 3;
|
||||||
|
|
|
@ -8,7 +8,7 @@ AS $$
|
||||||
SELECT count(*) FROM (SELECT * FROM jsonb_object_keys($1)) t
|
SELECT count(*) FROM (SELECT * FROM jsonb_object_keys($1)) t
|
||||||
$$;
|
$$;
|
||||||
-- Check multi_cat_agg() aggregate which is used to implement jsonb_object_agg()
|
-- Check multi_cat_agg() aggregate which is used to implement jsonb_object_agg()
|
||||||
SELECT jsonb_cat_agg(i) FROM
|
SELECT jsonb_cat_agg(i) FROM
|
||||||
(VALUES ('{"c":[], "b":2}'::jsonb), (NULL), ('{"d":null, "a":{"b":3}, "b":2}'::jsonb)) AS t(i);
|
(VALUES ('{"c":[], "b":2}'::jsonb), (NULL), ('{"d":null, "a":{"b":3}, "b":2}'::jsonb)) AS t(i);
|
||||||
jsonb_cat_agg
|
jsonb_cat_agg
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
@ -23,7 +23,7 @@ ERROR: jsonb_object_agg with order by is unsupported
|
||||||
SELECT jsonb_object_agg(distinct l_orderkey, l_shipmode ORDER BY l_orderkey) FROM lineitem;
|
SELECT jsonb_object_agg(distinct l_orderkey, l_shipmode ORDER BY l_orderkey) FROM lineitem;
|
||||||
ERROR: jsonb_object_agg with order by is unsupported
|
ERROR: jsonb_object_agg with order by is unsupported
|
||||||
-- Check jsonb_object_agg() for different data types and LIMIT clauses
|
-- Check jsonb_object_agg() for different data types and LIMIT clauses
|
||||||
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_partkey)
|
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_partkey)
|
||||||
FROM lineitem GROUP BY l_orderkey
|
FROM lineitem GROUP BY l_orderkey
|
||||||
ORDER BY l_orderkey LIMIT 10;
|
ORDER BY l_orderkey LIMIT 10;
|
||||||
jsonb_object_agg
|
jsonb_object_agg
|
||||||
|
@ -40,7 +40,7 @@ SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_partkey)
|
||||||
{"341": 88362, "342": 89414, "343": 169544}
|
{"341": 88362, "342": 89414, "343": 169544}
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_extendedprice)
|
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_extendedprice)
|
||||||
FROM lineitem GROUP BY l_orderkey
|
FROM lineitem GROUP BY l_orderkey
|
||||||
ORDER BY l_orderkey LIMIT 10;
|
ORDER BY l_orderkey LIMIT 10;
|
||||||
jsonb_object_agg
|
jsonb_object_agg
|
||||||
|
@ -57,7 +57,7 @@ SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_extendedprice)
|
||||||
{"341": 17554.68, "342": 30875.02, "343": 9681.24}
|
{"341": 17554.68, "342": 30875.02, "343": 9681.24}
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_shipmode)
|
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_shipmode)
|
||||||
FROM lineitem GROUP BY l_orderkey
|
FROM lineitem GROUP BY l_orderkey
|
||||||
ORDER BY l_orderkey LIMIT 10;
|
ORDER BY l_orderkey LIMIT 10;
|
||||||
jsonb_object_agg
|
jsonb_object_agg
|
||||||
|
@ -74,7 +74,7 @@ SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_shipmode)
|
||||||
{"341": "REG AIR ", "342": "FOB ", "343": "FOB "}
|
{"341": "REG AIR ", "342": "FOB ", "343": "FOB "}
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_shipdate)
|
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_shipdate)
|
||||||
FROM lineitem GROUP BY l_orderkey
|
FROM lineitem GROUP BY l_orderkey
|
||||||
ORDER BY l_orderkey LIMIT 10;
|
ORDER BY l_orderkey LIMIT 10;
|
||||||
jsonb_object_agg
|
jsonb_object_agg
|
||||||
|
@ -102,8 +102,8 @@ SELECT count_keys(jsonb_object_agg(l_shipdate, l_orderkey)) FROM lineitem;
|
||||||
-- shards and contain different aggregates, filter clauses and other complex
|
-- shards and contain different aggregates, filter clauses and other complex
|
||||||
-- expressions. Note that the l_orderkey ranges are such that the matching rows
|
-- expressions. Note that the l_orderkey ranges are such that the matching rows
|
||||||
-- lie in different shards.
|
-- lie in different shards.
|
||||||
SELECT l_quantity, count(*), avg(l_extendedprice),
|
SELECT l_quantity, count(*), avg(l_extendedprice),
|
||||||
jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_shipdate)
|
jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_shipdate)
|
||||||
FROM lineitem
|
FROM lineitem
|
||||||
WHERE l_quantity < 5 AND l_orderkey > 5000 AND l_orderkey < 5300
|
WHERE l_quantity < 5 AND l_orderkey > 5000 AND l_orderkey < 5300
|
||||||
GROUP BY l_quantity ORDER BY l_quantity;
|
GROUP BY l_quantity ORDER BY l_quantity;
|
||||||
|
@ -115,7 +115,7 @@ SELECT l_quantity, count(*), avg(l_extendedprice),
|
||||||
4.00 | 4 | 5795.6800000000000000 | {"50313": "1994-12-26", "50622": "1993-02-06", "50891": "1992-09-18", "51893": "1993-12-21"}
|
4.00 | 4 | 5795.6800000000000000 | {"50313": "1994-12-26", "50622": "1993-02-06", "50891": "1992-09-18", "51893": "1993-12-21"}
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT l_quantity, jsonb_object_agg(l_orderkey::text || l_linenumber::text,
|
SELECT l_quantity, jsonb_object_agg(l_orderkey::text || l_linenumber::text,
|
||||||
extract (month FROM o_orderdate))
|
extract (month FROM o_orderdate))
|
||||||
FROM lineitem, orders WHERE l_orderkey = o_orderkey AND l_quantity < 5
|
FROM lineitem, orders WHERE l_orderkey = o_orderkey AND l_quantity < 5
|
||||||
AND l_orderkey > 5000 AND l_orderkey < 5300 GROUP BY l_quantity ORDER BY l_quantity;
|
AND l_orderkey > 5000 AND l_orderkey < 5300 GROUP BY l_quantity ORDER BY l_quantity;
|
||||||
|
@ -127,7 +127,7 @@ SELECT l_quantity, jsonb_object_agg(l_orderkey::text || l_linenumber::text,
|
||||||
4.00 | {"50313": 12, "50622": 10, "50891": 7, "51893": 11}
|
4.00 | {"50313": 12, "50622": 10, "50891": 7, "51893": 11}
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
SELECT l_quantity, jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_orderkey * 2 + 1)
|
SELECT l_quantity, jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_orderkey * 2 + 1)
|
||||||
FROM lineitem WHERE l_quantity < 5
|
FROM lineitem WHERE l_quantity < 5
|
||||||
AND octet_length(l_comment) + octet_length('randomtext'::text) > 40
|
AND octet_length(l_comment) + octet_length('randomtext'::text) > 40
|
||||||
AND l_orderkey > 5000 AND l_orderkey < 6000 GROUP BY l_quantity ORDER BY l_quantity;
|
AND l_orderkey > 5000 AND l_orderkey < 6000 GROUP BY l_quantity ORDER BY l_quantity;
|
||||||
|
@ -140,7 +140,7 @@ SELECT l_quantity, jsonb_object_agg(l_orderkey::text || l_linenumber::text, l_or
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
-- Check that we can execute jsonb_object_agg() with an expression containing NULL values
|
-- Check that we can execute jsonb_object_agg() with an expression containing NULL values
|
||||||
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text,
|
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text,
|
||||||
case when l_quantity > 20 then l_quantity else NULL end)
|
case when l_quantity > 20 then l_quantity else NULL end)
|
||||||
FROM lineitem WHERE l_orderkey < 5;
|
FROM lineitem WHERE l_orderkey < 5;
|
||||||
jsonb_object_agg
|
jsonb_object_agg
|
||||||
|
@ -148,9 +148,8 @@ SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text,
|
||||||
{"11": null, "12": 36.00, "13": null, "14": 28.00, "15": 24.00, "16": 32.00, "21": 38.00, "31": 45.00, "32": 49.00, "33": 27.00, "34": null, "35": 28.00, "36": 26.00, "41": 30.00}
|
{"11": null, "12": 36.00, "13": null, "14": 28.00, "15": 24.00, "16": 32.00, "21": 38.00, "31": 45.00, "32": 49.00, "33": 27.00, "34": null, "35": 28.00, "36": 26.00, "41": 30.00}
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- Check that we can execute jsonb_object_agg() with an expression containing different types
|
-- Check that we can execute jsonb_object_agg() with an expression containing different types
|
||||||
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text,
|
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text,
|
||||||
case when l_quantity > 20 then to_jsonb(l_quantity) else '"f"'::jsonb end)
|
case when l_quantity > 20 then to_jsonb(l_quantity) else '"f"'::jsonb end)
|
||||||
FROM lineitem WHERE l_orderkey < 5;
|
FROM lineitem WHERE l_orderkey < 5;
|
||||||
jsonb_object_agg
|
jsonb_object_agg
|
||||||
|
@ -158,7 +157,6 @@ SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text,
|
||||||
{"11": "f", "12": 36.00, "13": "f", "14": 28.00, "15": 24.00, "16": 32.00, "21": 38.00, "31": 45.00, "32": 49.00, "33": 27.00, "34": "f", "35": 28.00, "36": 26.00, "41": 30.00}
|
{"11": "f", "12": 36.00, "13": "f", "14": 28.00, "15": 24.00, "16": 32.00, "21": 38.00, "31": 45.00, "32": 49.00, "33": 27.00, "34": "f", "35": 28.00, "36": 26.00, "41": 30.00}
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- Check that we can execute jsonb_object_agg() with an expression containing jsonb arrays
|
-- Check that we can execute jsonb_object_agg() with an expression containing jsonb arrays
|
||||||
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, jsonb_build_array(l_quantity, l_shipdate))
|
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, jsonb_build_array(l_quantity, l_shipdate))
|
||||||
FROM lineitem WHERE l_orderkey < 3;
|
FROM lineitem WHERE l_orderkey < 3;
|
||||||
|
@ -167,7 +165,6 @@ SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, jsonb_build_arra
|
||||||
{"11": [17.00, "1996-03-13"], "12": [36.00, "1996-04-12"], "13": [8.00, "1996-01-29"], "14": [28.00, "1996-04-21"], "15": [24.00, "1996-03-30"], "16": [32.00, "1996-01-30"], "21": [38.00, "1997-01-28"]}
|
{"11": [17.00, "1996-03-13"], "12": [36.00, "1996-04-12"], "13": [8.00, "1996-01-29"], "14": [28.00, "1996-04-21"], "15": [24.00, "1996-03-30"], "16": [32.00, "1996-01-30"], "21": [38.00, "1997-01-28"]}
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- Check that we can execute jsonb_object_agg() with an expression containing arrays
|
-- Check that we can execute jsonb_object_agg() with an expression containing arrays
|
||||||
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, ARRAY[l_quantity, l_orderkey])
|
SELECT jsonb_object_agg(l_orderkey::text || l_linenumber::text, ARRAY[l_quantity, l_orderkey])
|
||||||
FROM lineitem WHERE l_orderkey < 3;
|
FROM lineitem WHERE l_orderkey < 3;
|
||||||
|
|
|
@ -15,7 +15,6 @@ SELECT start_metadata_sync_to_node('localhost', :worker_1_port);
|
||||||
-- 1-) Distributing partitioned table
|
-- 1-) Distributing partitioned table
|
||||||
-- create partitioned table
|
-- create partitioned table
|
||||||
CREATE TABLE partitioning_test(id int, time date) PARTITION BY RANGE (time);
|
CREATE TABLE partitioning_test(id int, time date) PARTITION BY RANGE (time);
|
||||||
|
|
||||||
-- create its partitions
|
-- create its partitions
|
||||||
CREATE TABLE partitioning_test_2009 PARTITION OF partitioning_test FOR VALUES FROM ('2009-01-01') TO ('2010-01-01');
|
CREATE TABLE partitioning_test_2009 PARTITION OF partitioning_test FOR VALUES FROM ('2009-01-01') TO ('2010-01-01');
|
||||||
CREATE TABLE partitioning_test_2010 PARTITION OF partitioning_test FOR VALUES FROM ('2010-01-01') TO ('2011-01-01');
|
CREATE TABLE partitioning_test_2010 PARTITION OF partitioning_test FOR VALUES FROM ('2010-01-01') TO ('2011-01-01');
|
||||||
|
@ -45,11 +44,11 @@ SELECT * FROM partitioning_test ORDER BY 1;
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
-- see from MX node, partitioned table and its partitions are distributed
|
-- see from MX node, partitioned table and its partitions are distributed
|
||||||
SELECT
|
SELECT
|
||||||
logicalrelid
|
logicalrelid
|
||||||
FROM
|
FROM
|
||||||
pg_dist_partition
|
pg_dist_partition
|
||||||
WHERE
|
WHERE
|
||||||
logicalrelid IN ('partitioning_test', 'partitioning_test_2009', 'partitioning_test_2010')
|
logicalrelid IN ('partitioning_test', 'partitioning_test_2009', 'partitioning_test_2010')
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
||||||
logicalrelid
|
logicalrelid
|
||||||
|
@ -59,9 +58,9 @@ ORDER BY 1;
|
||||||
partitioning_test_2010
|
partitioning_test_2010
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
logicalrelid, count(*)
|
logicalrelid, count(*)
|
||||||
FROM pg_dist_shard
|
FROM pg_dist_shard
|
||||||
WHERE logicalrelid IN ('partitioning_test', 'partitioning_test_2009', 'partitioning_test_2010')
|
WHERE logicalrelid IN ('partitioning_test', 'partitioning_test_2009', 'partitioning_test_2010')
|
||||||
GROUP BY
|
GROUP BY
|
||||||
logicalrelid
|
logicalrelid
|
||||||
|
@ -89,11 +88,11 @@ SET citus.shard_replication_factor TO 1;
|
||||||
CREATE TABLE partitioning_test_2011 PARTITION OF partitioning_test FOR VALUES FROM ('2011-01-01') TO ('2012-01-01');
|
CREATE TABLE partitioning_test_2011 PARTITION OF partitioning_test FOR VALUES FROM ('2011-01-01') TO ('2012-01-01');
|
||||||
-- see from MX node, new partition is automatically distributed as well
|
-- see from MX node, new partition is automatically distributed as well
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
SELECT
|
SELECT
|
||||||
logicalrelid
|
logicalrelid
|
||||||
FROM
|
FROM
|
||||||
pg_dist_partition
|
pg_dist_partition
|
||||||
WHERE
|
WHERE
|
||||||
logicalrelid IN ('partitioning_test', 'partitioning_test_2011')
|
logicalrelid IN ('partitioning_test', 'partitioning_test_2011')
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
||||||
logicalrelid
|
logicalrelid
|
||||||
|
@ -102,9 +101,9 @@ ORDER BY 1;
|
||||||
partitioning_test_2011
|
partitioning_test_2011
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
logicalrelid, count(*)
|
logicalrelid, count(*)
|
||||||
FROM pg_dist_shard
|
FROM pg_dist_shard
|
||||||
WHERE logicalrelid IN ('partitioning_test', 'partitioning_test_2011')
|
WHERE logicalrelid IN ('partitioning_test', 'partitioning_test_2011')
|
||||||
GROUP BY
|
GROUP BY
|
||||||
logicalrelid
|
logicalrelid
|
||||||
|
@ -137,11 +136,11 @@ ALTER TABLE partitioning_test ATTACH PARTITION partitioning_test_2012 FOR VALUES
|
||||||
NOTICE: Copying data from local table...
|
NOTICE: Copying data from local table...
|
||||||
-- see from MX node, attached partition is distributed as well
|
-- see from MX node, attached partition is distributed as well
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
SELECT
|
SELECT
|
||||||
logicalrelid
|
logicalrelid
|
||||||
FROM
|
FROM
|
||||||
pg_dist_partition
|
pg_dist_partition
|
||||||
WHERE
|
WHERE
|
||||||
logicalrelid IN ('partitioning_test', 'partitioning_test_2012')
|
logicalrelid IN ('partitioning_test', 'partitioning_test_2012')
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
||||||
logicalrelid
|
logicalrelid
|
||||||
|
@ -150,9 +149,9 @@ ORDER BY 1;
|
||||||
partitioning_test_2012
|
partitioning_test_2012
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
logicalrelid, count(*)
|
logicalrelid, count(*)
|
||||||
FROM pg_dist_shard
|
FROM pg_dist_shard
|
||||||
WHERE logicalrelid IN ('partitioning_test', 'partitioning_test_2012')
|
WHERE logicalrelid IN ('partitioning_test', 'partitioning_test_2012')
|
||||||
GROUP BY
|
GROUP BY
|
||||||
logicalrelid
|
logicalrelid
|
||||||
|
|
|
@ -47,7 +47,7 @@ CREATE TABLE repartition_udt_other (
|
||||||
udtcol test_udt,
|
udtcol test_udt,
|
||||||
txtcol text
|
txtcol text
|
||||||
);
|
);
|
||||||
-- Connect directly to a worker, create and drop the type, then
|
-- Connect directly to a worker, create and drop the type, then
|
||||||
-- proceed with type creation as above; thus the OIDs will be different.
|
-- proceed with type creation as above; thus the OIDs will be different.
|
||||||
-- so that the OID is off.
|
-- so that the OID is off.
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
|
@ -194,6 +194,5 @@ LOG: join order: [ "repartition_udt" ][ dual partition join "repartition_udt_ot
|
||||||
6 | (2,3) | foo | 12 | (2,3) | foo
|
6 | (2,3) | foo | 12 | (2,3) | foo
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
\c - - - :worker_2_port
|
\c - - - :worker_2_port
|
||||||
|
|
|
@ -65,8 +65,8 @@ DEBUG: Plan is router executable
|
||||||
DETAIL: distribution column value: 10
|
DETAIL: distribution column value: 10
|
||||||
-- single-shard tests
|
-- single-shard tests
|
||||||
-- many of the tests in this file is intended for testing non-fast-path
|
-- many of the tests in this file is intended for testing non-fast-path
|
||||||
-- router planner, so we're explicitly disabling it in this file.
|
-- router planner, so we're explicitly disabling it in this file.
|
||||||
-- We've bunch of other tests that triggers fast-path-router
|
-- We've bunch of other tests that triggers fast-path-router
|
||||||
SET citus.enable_fast_path_router_planner TO false;
|
SET citus.enable_fast_path_router_planner TO false;
|
||||||
-- test simple select for a single row
|
-- test simple select for a single row
|
||||||
SELECT * FROM articles_hash_mx WHERE author_id = 10 AND id = 50;
|
SELECT * FROM articles_hash_mx WHERE author_id = 10 AND id = 50;
|
||||||
|
@ -195,7 +195,7 @@ DETAIL: distribution column value: 1
|
||||||
|
|
||||||
-- query is a single shard query but can't do shard pruning,
|
-- query is a single shard query but can't do shard pruning,
|
||||||
-- not router-plannable due to <= and IN
|
-- not router-plannable due to <= and IN
|
||||||
SELECT * FROM articles_hash_mx WHERE author_id <= 1;
|
SELECT * FROM articles_hash_mx WHERE author_id <= 1;
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
id | author_id | title | word_count
|
id | author_id | title | word_count
|
||||||
----+-----------+--------------+------------
|
----+-----------+--------------+------------
|
||||||
|
@ -206,7 +206,7 @@ DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
41 | 1 | aznavour | 11814
|
41 | 1 | aznavour | 11814
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
SELECT * FROM articles_hash_mx WHERE author_id IN (1, 3);
|
SELECT * FROM articles_hash_mx WHERE author_id IN (1, 3);
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
id | author_id | title | word_count
|
id | author_id | title | word_count
|
||||||
|
@ -335,7 +335,7 @@ DETAIL: distribution column value: 3
|
||||||
WITH RECURSIVE hierarchy as (
|
WITH RECURSIVE hierarchy as (
|
||||||
SELECT *, 1 AS level
|
SELECT *, 1 AS level
|
||||||
FROM company_employees_mx
|
FROM company_employees_mx
|
||||||
WHERE company_id = 1 and manager_id = 0
|
WHERE company_id = 1 and manager_id = 0
|
||||||
UNION
|
UNION
|
||||||
SELECT ce.*, (h.level+1)
|
SELECT ce.*, (h.level+1)
|
||||||
FROM hierarchy h JOIN company_employees_mx ce
|
FROM hierarchy h JOIN company_employees_mx ce
|
||||||
|
@ -358,7 +358,7 @@ DETAIL: distribution column value: 1
|
||||||
WITH RECURSIVE hierarchy as (
|
WITH RECURSIVE hierarchy as (
|
||||||
SELECT *, 1 AS level
|
SELECT *, 1 AS level
|
||||||
FROM company_employees_mx
|
FROM company_employees_mx
|
||||||
WHERE company_id = 1 and manager_id = 0
|
WHERE company_id = 1 and manager_id = 0
|
||||||
UNION
|
UNION
|
||||||
SELECT ce.*, (h.level+1)
|
SELECT ce.*, (h.level+1)
|
||||||
FROM hierarchy h JOIN company_employees_mx ce
|
FROM hierarchy h JOIN company_employees_mx ce
|
||||||
|
@ -373,7 +373,7 @@ ERROR: recursive CTEs are not supported in distributed queries
|
||||||
WITH RECURSIVE hierarchy as (
|
WITH RECURSIVE hierarchy as (
|
||||||
SELECT *, 1 AS level
|
SELECT *, 1 AS level
|
||||||
FROM company_employees_mx
|
FROM company_employees_mx
|
||||||
WHERE company_id = 3 and manager_id = 0
|
WHERE company_id = 3 and manager_id = 0
|
||||||
UNION
|
UNION
|
||||||
SELECT ce.*, (h.level+1)
|
SELECT ce.*, (h.level+1)
|
||||||
FROM hierarchy h JOIN company_employees_mx ce
|
FROM hierarchy h JOIN company_employees_mx ce
|
||||||
|
@ -488,7 +488,7 @@ DEBUG: push down of limit count: 5
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
SELECT articles_hash_mx.id,test.word_count
|
SELECT articles_hash_mx.id,test.word_count
|
||||||
FROM articles_hash_mx, (SELECT id, word_count FROM articles_hash_mx) AS test
|
FROM articles_hash_mx, (SELECT id, word_count FROM articles_hash_mx) AS test
|
||||||
WHERE test.id = articles_hash_mx.id and articles_hash_mx.author_id = 1
|
WHERE test.id = articles_hash_mx.id and articles_hash_mx.author_id = 1
|
||||||
ORDER BY articles_hash_mx.id;
|
ORDER BY articles_hash_mx.id;
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
|
@ -591,7 +591,7 @@ DETAIL: distribution column value: 10
|
||||||
10 | 6363
|
10 | 6363
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
-- following join is router plannable since the same worker
|
-- following join is router plannable since the same worker
|
||||||
-- has both shards
|
-- has both shards
|
||||||
SELECT a.author_id as first_author, b.word_count as second_word_count
|
SELECT a.author_id as first_author, b.word_count as second_word_count
|
||||||
FROM articles_hash_mx a, articles_single_shard_hash_mx b
|
FROM articles_hash_mx a, articles_single_shard_hash_mx b
|
||||||
|
@ -607,7 +607,6 @@ DETAIL: distribution column value: 10
|
||||||
10 | 19519
|
10 | 19519
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
|
|
||||||
-- following join is not router plannable since there are no
|
-- following join is not router plannable since there are no
|
||||||
-- workers containing both shards, but will work through recursive
|
-- workers containing both shards, but will work through recursive
|
||||||
-- planning
|
-- planning
|
||||||
|
@ -675,7 +674,6 @@ DETAIL: distribution column value: 1
|
||||||
21 | 1 | arcading | 5890
|
21 | 1 | arcading | 5890
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
-- single shard select with group by on non-partition column is router plannable
|
-- single shard select with group by on non-partition column is router plannable
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM articles_hash_mx
|
FROM articles_hash_mx
|
||||||
|
@ -749,7 +747,6 @@ DETAIL: distribution column value: 1
|
||||||
11814
|
11814
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- router plannable union queries are supported
|
-- router plannable union queries are supported
|
||||||
SELECT * FROM (
|
SELECT * FROM (
|
||||||
SELECT * FROM articles_hash_mx WHERE author_id = 1
|
SELECT * FROM articles_hash_mx WHERE author_id = 1
|
||||||
|
@ -913,7 +910,6 @@ DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
41 | 1 | aznavour | 11814
|
41 | 1 | aznavour | 11814
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
|
|
||||||
-- router plannable
|
-- router plannable
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash_mx
|
FROM articles_hash_mx
|
||||||
|
@ -966,7 +962,6 @@ DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
41 | 1 | aznavour | 11814
|
41 | 1 | aznavour | 11814
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
|
|
||||||
-- router plannable due to abs(-1) getting converted to 1 by postgresql
|
-- router plannable due to abs(-1) getting converted to 1 by postgresql
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash_mx
|
FROM articles_hash_mx
|
||||||
|
@ -1123,7 +1118,7 @@ DETAIL: distribution column value: 1
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
-- window functions are supported if query is router plannable
|
-- window functions are supported if query is router plannable
|
||||||
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
||||||
FROM articles_hash_mx
|
FROM articles_hash_mx
|
||||||
WHERE author_id = 5;
|
WHERE author_id = 5;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1138,7 +1133,7 @@ DETAIL: distribution column value: 5
|
||||||
aminate | aruru | 11389
|
aminate | aruru | 11389
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
||||||
FROM articles_hash_mx
|
FROM articles_hash_mx
|
||||||
WHERE author_id = 5
|
WHERE author_id = 5
|
||||||
ORDER BY word_count DESC;
|
ORDER BY word_count DESC;
|
||||||
|
@ -1184,8 +1179,8 @@ DETAIL: distribution column value: 1
|
||||||
41 | 11814 | 7178.8000000000000000
|
41 | 11814 | 7178.8000000000000000
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
SELECT word_count, rank() OVER (PARTITION BY author_id ORDER BY word_count)
|
SELECT word_count, rank() OVER (PARTITION BY author_id ORDER BY word_count)
|
||||||
FROM articles_hash_mx
|
FROM articles_hash_mx
|
||||||
WHERE author_id = 1;
|
WHERE author_id = 1;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
|
@ -1206,16 +1201,16 @@ SELECT id, MIN(id) over (order by word_count)
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
ERROR: could not run distributed query because the window function that is used cannot be pushed down
|
ERROR: could not run distributed query because the window function that is used cannot be pushed down
|
||||||
HINT: Window functions are supported in two ways. Either add an equality filter on the distributed tables' partition column or use the window functions with a PARTITION BY clause containing the distribution column
|
HINT: Window functions are supported in two ways. Either add an equality filter on the distributed tables' partition column or use the window functions with a PARTITION BY clause containing the distribution column
|
||||||
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
||||||
FROM articles_hash_mx
|
FROM articles_hash_mx
|
||||||
WHERE author_id = 5 or author_id = 2;
|
WHERE author_id = 5 or author_id = 2;
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
ERROR: could not run distributed query because the window function that is used cannot be pushed down
|
ERROR: could not run distributed query because the window function that is used cannot be pushed down
|
||||||
HINT: Window functions are supported in two ways. Either add an equality filter on the distributed tables' partition column or use the window functions with a PARTITION BY clause containing the distribution column
|
HINT: Window functions are supported in two ways. Either add an equality filter on the distributed tables' partition column or use the window functions with a PARTITION BY clause containing the distribution column
|
||||||
-- complex query hitting a single shard
|
-- complex query hitting a single shard
|
||||||
SELECT
|
SELECT
|
||||||
count(DISTINCT CASE
|
count(DISTINCT CASE
|
||||||
WHEN
|
WHEN
|
||||||
word_count > 100
|
word_count > 100
|
||||||
THEN
|
THEN
|
||||||
id
|
id
|
||||||
|
@ -1237,7 +1232,7 @@ DETAIL: distribution column value: 5
|
||||||
-- same query is not router plannable if hits multiple shards
|
-- same query is not router plannable if hits multiple shards
|
||||||
SELECT
|
SELECT
|
||||||
count(DISTINCT CASE
|
count(DISTINCT CASE
|
||||||
WHEN
|
WHEN
|
||||||
word_count > 100
|
word_count > 100
|
||||||
THEN
|
THEN
|
||||||
id
|
id
|
||||||
|
@ -1285,7 +1280,7 @@ DETAIL: distribution column value: 1
|
||||||
END;
|
END;
|
||||||
-- cursor queries are router plannable
|
-- cursor queries are router plannable
|
||||||
BEGIN;
|
BEGIN;
|
||||||
DECLARE test_cursor CURSOR FOR
|
DECLARE test_cursor CURSOR FOR
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash_mx
|
FROM articles_hash_mx
|
||||||
WHERE author_id = 1
|
WHERE author_id = 1
|
||||||
|
@ -1326,7 +1321,6 @@ DETAIL: distribution column value: 1
|
||||||
21 1 arcading 5890
|
21 1 arcading 5890
|
||||||
31 1 athwartships 7271
|
31 1 athwartships 7271
|
||||||
41 1 aznavour 11814
|
41 1 aznavour 11814
|
||||||
|
|
||||||
-- table creation queries inside can be router plannable
|
-- table creation queries inside can be router plannable
|
||||||
CREATE TEMP TABLE temp_articles_hash_mx as
|
CREATE TEMP TABLE temp_articles_hash_mx as
|
||||||
SELECT *
|
SELECT *
|
||||||
|
@ -1474,7 +1468,6 @@ SET client_min_messages to 'DEBUG2';
|
||||||
CREATE MATERIALIZED VIEW mv_articles_hash_mx_error AS
|
CREATE MATERIALIZED VIEW mv_articles_hash_mx_error AS
|
||||||
SELECT * FROM articles_hash_mx WHERE author_id in (1,2);
|
SELECT * FROM articles_hash_mx WHERE author_id in (1,2);
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
|
|
||||||
-- router planner/executor is disabled for task-tracker executor
|
-- router planner/executor is disabled for task-tracker executor
|
||||||
-- following query is router plannable, but router planner is disabled
|
-- following query is router plannable, but router planner is disabled
|
||||||
-- TODO: Uncomment once we fix task-tracker issue
|
-- TODO: Uncomment once we fix task-tracker issue
|
||||||
|
|
|
@ -145,7 +145,6 @@ WHERE colocationid IN
|
||||||
10004 | 1 | -1 | 0
|
10004 | 1 | -1 | 0
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
SELECT COUNT(*) FROM pg_dist_node WHERE nodeport = :worker_2_port;
|
SELECT COUNT(*) FROM pg_dist_node WHERE nodeport = :worker_2_port;
|
||||||
count
|
count
|
||||||
|
@ -164,7 +163,6 @@ WHERE
|
||||||
1380000 | 1 | 0 | localhost | 57638
|
1380000 | 1 | 0 | localhost | 57638
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
SELECT master_remove_node('localhost', :worker_2_port);
|
SELECT master_remove_node('localhost', :worker_2_port);
|
||||||
master_remove_node
|
master_remove_node
|
||||||
|
@ -217,7 +215,6 @@ WHERE
|
||||||
---------+------------+-------------+----------+----------
|
---------+------------+-------------+----------+----------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
-- remove same node twice
|
-- remove same node twice
|
||||||
SELECT master_remove_node('localhost', :worker_2_port);
|
SELECT master_remove_node('localhost', :worker_2_port);
|
||||||
|
@ -281,7 +278,6 @@ WHERE colocationid IN
|
||||||
10004 | 1 | -1 | 0
|
10004 | 1 | -1 | 0
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
SELECT COUNT(*) FROM pg_dist_node WHERE nodeport = :worker_2_port;
|
SELECT COUNT(*) FROM pg_dist_node WHERE nodeport = :worker_2_port;
|
||||||
count
|
count
|
||||||
|
@ -300,7 +296,6 @@ WHERE
|
||||||
1380000 | 1 | 0 | localhost | 57638
|
1380000 | 1 | 0 | localhost | 57638
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT master_remove_node('localhost', :worker_2_port);
|
SELECT master_remove_node('localhost', :worker_2_port);
|
||||||
|
@ -357,7 +352,6 @@ WHERE
|
||||||
1380000 | 1 | 0 | localhost | 57638
|
1380000 | 1 | 0 | localhost | 57638
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
-- remove node in a transaction and COMMIT
|
-- remove node in a transaction and COMMIT
|
||||||
-- status before master_remove_node
|
-- status before master_remove_node
|
||||||
|
@ -389,7 +383,6 @@ WHERE colocationid IN
|
||||||
10004 | 1 | -1 | 0
|
10004 | 1 | -1 | 0
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
SELECT COUNT(*) FROM pg_dist_node WHERE nodeport = :worker_2_port;
|
SELECT COUNT(*) FROM pg_dist_node WHERE nodeport = :worker_2_port;
|
||||||
count
|
count
|
||||||
|
@ -408,7 +401,6 @@ WHERE
|
||||||
1380000 | 1 | 0 | localhost | 57638
|
1380000 | 1 | 0 | localhost | 57638
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT master_remove_node('localhost', :worker_2_port);
|
SELECT master_remove_node('localhost', :worker_2_port);
|
||||||
|
@ -446,7 +438,6 @@ WHERE colocationid IN
|
||||||
10004 | 1 | -1 | 0
|
10004 | 1 | -1 | 0
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
SELECT COUNT(*) FROM pg_dist_node WHERE nodeport = :worker_2_port;
|
SELECT COUNT(*) FROM pg_dist_node WHERE nodeport = :worker_2_port;
|
||||||
count
|
count
|
||||||
|
@ -464,7 +455,6 @@ WHERE
|
||||||
---------+------------+-------------+----------+----------
|
---------+------------+-------------+----------+----------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
-- re-add the node for next tests
|
-- re-add the node for next tests
|
||||||
SELECT 1 FROM master_add_node('localhost', :worker_2_port);
|
SELECT 1 FROM master_add_node('localhost', :worker_2_port);
|
||||||
|
@ -522,9 +512,7 @@ WHERE
|
||||||
1380000 | 1 | 0 | localhost | 57638
|
1380000 | 1 | 0 | localhost | 57638
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
\c - - - :master_port
|
||||||
\c - - - :master_port
|
|
||||||
|
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO remove_node_reference_table VALUES(1);
|
INSERT INTO remove_node_reference_table VALUES(1);
|
||||||
SELECT master_remove_node('localhost', :worker_2_port);
|
SELECT master_remove_node('localhost', :worker_2_port);
|
||||||
|
@ -586,14 +574,12 @@ WHERE
|
||||||
---------+------------+-------------+----------+----------
|
---------+------------+-------------+----------+----------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
|
|
||||||
SELECT * FROM remove_node_reference_table;
|
SELECT * FROM remove_node_reference_table;
|
||||||
column1
|
column1
|
||||||
---------
|
---------
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
-- re-add the node for next tests
|
-- re-add the node for next tests
|
||||||
SELECT 1 FROM master_add_node('localhost', :worker_2_port);
|
SELECT 1 FROM master_add_node('localhost', :worker_2_port);
|
||||||
|
@ -651,7 +637,6 @@ WHERE
|
||||||
1380000 | 1 | 0 | localhost | 57638
|
1380000 | 1 | 0 | localhost | 57638
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE remove_node_reference_table ADD column2 int;
|
ALTER TABLE remove_node_reference_table ADD column2 int;
|
||||||
|
@ -690,7 +675,6 @@ WHERE colocationid IN
|
||||||
10004 | 1 | -1 | 0
|
10004 | 1 | -1 | 0
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
SELECT COUNT(*) FROM pg_dist_node WHERE nodeport = :worker_2_port;
|
SELECT COUNT(*) FROM pg_dist_node WHERE nodeport = :worker_2_port;
|
||||||
count
|
count
|
||||||
|
@ -708,7 +692,6 @@ WHERE
|
||||||
---------+------------+-------------+----------+----------
|
---------+------------+-------------+----------+----------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
SET citus.next_shard_id TO 1380001;
|
SET citus.next_shard_id TO 1380001;
|
||||||
-- verify table structure is changed
|
-- verify table structure is changed
|
||||||
|
@ -844,7 +827,6 @@ WHERE colocationid IN
|
||||||
10004 | 1 | -1 | 0
|
10004 | 1 | -1 | 0
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
SELECT COUNT(*) FROM pg_dist_node WHERE nodeport = :worker_2_port;
|
SELECT COUNT(*) FROM pg_dist_node WHERE nodeport = :worker_2_port;
|
||||||
count
|
count
|
||||||
|
@ -918,9 +900,7 @@ WHERE
|
||||||
---------+------------+-------------+----------+----------
|
---------+------------+-------------+----------+----------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
|
\c - - - :master_port
|
||||||
\c - - - :master_port
|
|
||||||
|
|
||||||
-- re-add the node for next tests
|
-- re-add the node for next tests
|
||||||
SELECT 1 FROM master_add_node('localhost', :worker_2_port);
|
SELECT 1 FROM master_add_node('localhost', :worker_2_port);
|
||||||
NOTICE: Replicating reference table "remove_node_reference_table" to the node localhost:57638
|
NOTICE: Replicating reference table "remove_node_reference_table" to the node localhost:57638
|
||||||
|
@ -983,9 +963,7 @@ ORDER BY shardid ASC;
|
||||||
1380002 | 1 | 0 | localhost | 57638
|
1380002 | 1 | 0 | localhost | 57638
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
|
\c - - - :master_port
|
||||||
\c - - - :master_port
|
|
||||||
|
|
||||||
SELECT master_disable_node('localhost', :worker_2_port);
|
SELECT master_disable_node('localhost', :worker_2_port);
|
||||||
master_disable_node
|
master_disable_node
|
||||||
---------------------
|
---------------------
|
||||||
|
@ -1037,7 +1015,6 @@ WHERE
|
||||||
---------+------------+-------------+----------+----------
|
---------+------------+-------------+----------+----------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
-- re-add the node for next tests
|
-- re-add the node for next tests
|
||||||
SELECT 1 FROM master_activate_node('localhost', :worker_2_port);
|
SELECT 1 FROM master_activate_node('localhost', :worker_2_port);
|
||||||
|
|
|
@ -255,7 +255,7 @@ DETAIL: distribution column value: 1
|
||||||
|
|
||||||
-- query is a single shard query but can't do shard pruning,
|
-- query is a single shard query but can't do shard pruning,
|
||||||
-- not router-plannable due to <= and IN
|
-- not router-plannable due to <= and IN
|
||||||
SELECT * FROM articles_hash WHERE author_id <= 1;
|
SELECT * FROM articles_hash WHERE author_id <= 1;
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
id | author_id | title | word_count
|
id | author_id | title | word_count
|
||||||
----+-----------+--------------+------------
|
----+-----------+--------------+------------
|
||||||
|
@ -266,7 +266,7 @@ DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
41 | 1 | aznavour | 11814
|
41 | 1 | aznavour | 11814
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
SELECT * FROM articles_hash WHERE author_id IN (1, 3);
|
SELECT * FROM articles_hash WHERE author_id IN (1, 3);
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
id | author_id | title | word_count
|
id | author_id | title | word_count
|
||||||
|
@ -359,7 +359,7 @@ DEBUG: Plan is router executable
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- recursive CTEs are supported when filtered on partition column
|
-- recursive CTEs are supported when filtered on partition column
|
||||||
CREATE TABLE company_employees (company_id int, employee_id int, manager_id int);
|
CREATE TABLE company_employees (company_id int, employee_id int, manager_id int);
|
||||||
SELECT master_create_distributed_table('company_employees', 'company_id', 'hash');
|
SELECT master_create_distributed_table('company_employees', 'company_id', 'hash');
|
||||||
master_create_distributed_table
|
master_create_distributed_table
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
@ -408,7 +408,7 @@ DETAIL: distribution column value: 3
|
||||||
WITH RECURSIVE hierarchy as (
|
WITH RECURSIVE hierarchy as (
|
||||||
SELECT *, 1 AS level
|
SELECT *, 1 AS level
|
||||||
FROM company_employees
|
FROM company_employees
|
||||||
WHERE company_id = 1 and manager_id = 0
|
WHERE company_id = 1 and manager_id = 0
|
||||||
UNION
|
UNION
|
||||||
SELECT ce.*, (h.level+1)
|
SELECT ce.*, (h.level+1)
|
||||||
FROM hierarchy h JOIN company_employees ce
|
FROM hierarchy h JOIN company_employees ce
|
||||||
|
@ -431,7 +431,7 @@ DETAIL: distribution column value: 1
|
||||||
WITH RECURSIVE hierarchy as (
|
WITH RECURSIVE hierarchy as (
|
||||||
SELECT *, 1 AS level
|
SELECT *, 1 AS level
|
||||||
FROM company_employees
|
FROM company_employees
|
||||||
WHERE company_id = 1 and manager_id = 0
|
WHERE company_id = 1 and manager_id = 0
|
||||||
UNION
|
UNION
|
||||||
SELECT ce.*, (h.level+1)
|
SELECT ce.*, (h.level+1)
|
||||||
FROM hierarchy h JOIN company_employees ce
|
FROM hierarchy h JOIN company_employees ce
|
||||||
|
@ -445,7 +445,7 @@ ERROR: recursive CTEs are not supported in distributed queries
|
||||||
WITH RECURSIVE hierarchy as (
|
WITH RECURSIVE hierarchy as (
|
||||||
SELECT *, 1 AS level
|
SELECT *, 1 AS level
|
||||||
FROM company_employees
|
FROM company_employees
|
||||||
WHERE company_id = 3 and manager_id = 0
|
WHERE company_id = 3 and manager_id = 0
|
||||||
UNION
|
UNION
|
||||||
SELECT ce.*, (h.level+1)
|
SELECT ce.*, (h.level+1)
|
||||||
FROM hierarchy h JOIN company_employees ce
|
FROM hierarchy h JOIN company_employees ce
|
||||||
|
@ -647,7 +647,7 @@ DEBUG: push down of limit count: 5
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
SELECT articles_hash.id,test.word_count
|
SELECT articles_hash.id,test.word_count
|
||||||
FROM articles_hash, (SELECT id, word_count FROM articles_hash) AS test
|
FROM articles_hash, (SELECT id, word_count FROM articles_hash) AS test
|
||||||
WHERE test.id = articles_hash.id and articles_hash.author_id = 1
|
WHERE test.id = articles_hash.id and articles_hash.author_id = 1
|
||||||
ORDER BY articles_hash.id;
|
ORDER BY articles_hash.id;
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
|
@ -751,7 +751,7 @@ DETAIL: distribution column value: 10
|
||||||
10 | 6363
|
10 | 6363
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
-- following join is router plannable since the same worker
|
-- following join is router plannable since the same worker
|
||||||
-- has both shards
|
-- has both shards
|
||||||
SELECT a.author_id as first_author, b.word_count as second_word_count
|
SELECT a.author_id as first_author, b.word_count as second_word_count
|
||||||
FROM articles_hash a, articles_single_shard_hash b
|
FROM articles_hash a, articles_single_shard_hash b
|
||||||
|
@ -767,7 +767,6 @@ DETAIL: distribution column value: 10
|
||||||
10 | 19519
|
10 | 19519
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
|
|
||||||
-- following join is not router plannable since there are no
|
-- following join is not router plannable since there are no
|
||||||
-- workers containing both shards, but will work through recursive
|
-- workers containing both shards, but will work through recursive
|
||||||
-- planning
|
-- planning
|
||||||
|
@ -835,7 +834,6 @@ DETAIL: distribution column value: 1
|
||||||
21 | 1 | arcading | 5890
|
21 | 1 | arcading | 5890
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
-- single shard select with group by on non-partition column is router plannable
|
-- single shard select with group by on non-partition column is router plannable
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
|
@ -1094,7 +1092,6 @@ DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
41 | 1 | aznavour | 11814
|
41 | 1 | aznavour | 11814
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
|
|
||||||
-- router plannable
|
-- router plannable
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
|
@ -1147,7 +1144,6 @@ DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
41 | 1 | aznavour | 11814
|
41 | 1 | aznavour | 11814
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
|
|
||||||
-- router plannable due to abs(-1) getting converted to 1 by postgresql
|
-- router plannable due to abs(-1) getting converted to 1 by postgresql
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
|
@ -1304,7 +1300,7 @@ DETAIL: distribution column value: 1
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
-- window functions are supported if query is router plannable
|
-- window functions are supported if query is router plannable
|
||||||
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 5;
|
WHERE author_id = 5;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1319,7 +1315,7 @@ DETAIL: distribution column value: 5
|
||||||
aminate | aruru | 11389
|
aminate | aruru | 11389
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 5
|
WHERE author_id = 5
|
||||||
ORDER BY word_count DESC;
|
ORDER BY word_count DESC;
|
||||||
|
@ -1365,8 +1361,8 @@ DETAIL: distribution column value: 1
|
||||||
41 | 11814 | 7178.8000000000000000
|
41 | 11814 | 7178.8000000000000000
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
SELECT word_count, rank() OVER (PARTITION BY author_id ORDER BY word_count)
|
SELECT word_count, rank() OVER (PARTITION BY author_id ORDER BY word_count)
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 1;
|
WHERE author_id = 1;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
|
@ -1387,14 +1383,14 @@ SELECT id, MIN(id) over (order by word_count)
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
ERROR: could not run distributed query because the window function that is used cannot be pushed down
|
ERROR: could not run distributed query because the window function that is used cannot be pushed down
|
||||||
HINT: Window functions are supported in two ways. Either add an equality filter on the distributed tables' partition column or use the window functions with a PARTITION BY clause containing the distribution column
|
HINT: Window functions are supported in two ways. Either add an equality filter on the distributed tables' partition column or use the window functions with a PARTITION BY clause containing the distribution column
|
||||||
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 5 or author_id = 2;
|
WHERE author_id = 5 or author_id = 2;
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
ERROR: could not run distributed query because the window function that is used cannot be pushed down
|
ERROR: could not run distributed query because the window function that is used cannot be pushed down
|
||||||
HINT: Window functions are supported in two ways. Either add an equality filter on the distributed tables' partition column or use the window functions with a PARTITION BY clause containing the distribution column
|
HINT: Window functions are supported in two ways. Either add an equality filter on the distributed tables' partition column or use the window functions with a PARTITION BY clause containing the distribution column
|
||||||
-- where false queries are router plannable
|
-- where false queries are router plannable
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE false;
|
WHERE false;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1403,7 +1399,7 @@ DEBUG: Plan is router executable
|
||||||
----+-----------+-------+------------
|
----+-----------+-------+------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 1 and false;
|
WHERE author_id = 1 and false;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1412,7 +1408,7 @@ DEBUG: Plan is router executable
|
||||||
----+-----------+-------+------------
|
----+-----------+-------+------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 1 and 1=0;
|
WHERE author_id = 1 and 1=0;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1430,7 +1426,7 @@ DEBUG: Plan is router executable
|
||||||
--------------+-------------------
|
--------------+-------------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE null;
|
WHERE null;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1440,7 +1436,7 @@ DEBUG: Plan is router executable
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- where false with immutable function returning false
|
-- where false with immutable function returning false
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash a
|
FROM articles_hash a
|
||||||
WHERE a.author_id = 10 and int4eq(1, 2);
|
WHERE a.author_id = 10 and int4eq(1, 2);
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1449,7 +1445,7 @@ DEBUG: Plan is router executable
|
||||||
----+-----------+-------+------------
|
----+-----------+-------+------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash a
|
FROM articles_hash a
|
||||||
WHERE int4eq(1, 2);
|
WHERE int4eq(1, 2);
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1484,7 +1480,7 @@ DEBUG: Plan is router executable
|
||||||
|
|
||||||
-- partition_column is null clause does not prune out any shards,
|
-- partition_column is null clause does not prune out any shards,
|
||||||
-- all shards remain after shard pruning, not router plannable
|
-- all shards remain after shard pruning, not router plannable
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash a
|
FROM articles_hash a
|
||||||
WHERE a.author_id is null;
|
WHERE a.author_id is null;
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
|
@ -1494,7 +1490,7 @@ DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
|
|
||||||
-- partition_column equals to null clause prunes out all shards
|
-- partition_column equals to null clause prunes out all shards
|
||||||
-- no shards after shard pruning, router plannable
|
-- no shards after shard pruning, router plannable
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash a
|
FROM articles_hash a
|
||||||
WHERE a.author_id = null;
|
WHERE a.author_id = null;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1504,7 +1500,7 @@ DEBUG: Plan is router executable
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- stable function returning bool
|
-- stable function returning bool
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash a
|
FROM articles_hash a
|
||||||
WHERE date_ne_timestamp('1954-04-11', '1954-04-11'::timestamp);
|
WHERE date_ne_timestamp('1954-04-11', '1954-04-11'::timestamp);
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1597,7 +1593,7 @@ DEBUG: Plan is router executable
|
||||||
WITH RECURSIVE hierarchy as (
|
WITH RECURSIVE hierarchy as (
|
||||||
SELECT *, 1 AS level
|
SELECT *, 1 AS level
|
||||||
FROM company_employees
|
FROM company_employees
|
||||||
WHERE company_id = 1 and manager_id = 0
|
WHERE company_id = 1 and manager_id = 0
|
||||||
UNION
|
UNION
|
||||||
SELECT ce.*, (h.level+1)
|
SELECT ce.*, (h.level+1)
|
||||||
FROM hierarchy h JOIN company_employees ce
|
FROM hierarchy h JOIN company_employees ce
|
||||||
|
@ -1615,7 +1611,7 @@ DETAIL: distribution column value: 1
|
||||||
WITH RECURSIVE hierarchy as (
|
WITH RECURSIVE hierarchy as (
|
||||||
SELECT *, 1 AS level
|
SELECT *, 1 AS level
|
||||||
FROM company_employees
|
FROM company_employees
|
||||||
WHERE company_id = 1 and manager_id = 0
|
WHERE company_id = 1 and manager_id = 0
|
||||||
UNION
|
UNION
|
||||||
SELECT ce.*, (h.level+1)
|
SELECT ce.*, (h.level+1)
|
||||||
FROM hierarchy h JOIN company_employees ce
|
FROM hierarchy h JOIN company_employees ce
|
||||||
|
@ -1650,8 +1646,8 @@ DETAIL: distribution column value: 1
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- window functions with where false
|
-- window functions with where false
|
||||||
SELECT word_count, rank() OVER (PARTITION BY author_id ORDER BY word_count)
|
SELECT word_count, rank() OVER (PARTITION BY author_id ORDER BY word_count)
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 1 and 1=0;
|
WHERE author_id = 1 and 1=0;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
|
@ -1661,7 +1657,7 @@ DEBUG: Plan is router executable
|
||||||
|
|
||||||
-- function calls in WHERE clause with non-relational arguments
|
-- function calls in WHERE clause with non-relational arguments
|
||||||
SELECT author_id FROM articles_hash
|
SELECT author_id FROM articles_hash
|
||||||
WHERE
|
WHERE
|
||||||
substring('hello world', 1, 5) = 'hello'
|
substring('hello world', 1, 5) = 'hello'
|
||||||
ORDER BY
|
ORDER BY
|
||||||
author_id
|
author_id
|
||||||
|
@ -1675,7 +1671,7 @@ DEBUG: push down of limit count: 1
|
||||||
|
|
||||||
-- when expression evaluates to false
|
-- when expression evaluates to false
|
||||||
SELECT author_id FROM articles_hash
|
SELECT author_id FROM articles_hash
|
||||||
WHERE
|
WHERE
|
||||||
substring('hello world', 1, 4) = 'hello'
|
substring('hello world', 1, 4) = 'hello'
|
||||||
ORDER BY
|
ORDER BY
|
||||||
author_id
|
author_id
|
||||||
|
@ -1686,9 +1682,8 @@ DEBUG: Plan is router executable
|
||||||
-----------
|
-----------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
|
|
||||||
-- verify range partitioned tables can be used in router plannable queries
|
-- verify range partitioned tables can be used in router plannable queries
|
||||||
-- just 4 shards to be created for each table to make sure
|
-- just 4 shards to be created for each table to make sure
|
||||||
-- they are 'co-located' pairwise
|
-- they are 'co-located' pairwise
|
||||||
SET citus.shard_replication_factor TO 1;
|
SET citus.shard_replication_factor TO 1;
|
||||||
SELECT master_create_distributed_table('authors_range', 'id', 'range');
|
SELECT master_create_distributed_table('authors_range', 'id', 'range');
|
||||||
|
@ -1743,7 +1738,7 @@ DEBUG: Plan is router executable
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- single shard joins on range partitioned table are router plannable
|
-- single shard joins on range partitioned table are router plannable
|
||||||
SELECT * FROM articles_range ar join authors_range au on (ar.author_id = au.id)
|
SELECT * FROM articles_range ar join authors_range au on (ar.author_id = au.id)
|
||||||
WHERE ar.author_id = 1;
|
WHERE ar.author_id = 1;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
|
@ -1801,7 +1796,7 @@ DETAIL: Creating dependency on merge taskId 20
|
||||||
-- This query was intended to test "this is a bug, it is a single shard join
|
-- This query was intended to test "this is a bug, it is a single shard join
|
||||||
-- query but not router plannable". To run it using repartition join logic we
|
-- query but not router plannable". To run it using repartition join logic we
|
||||||
-- change the join columns.
|
-- change the join columns.
|
||||||
SELECT * FROM articles_range ar join authors_range au on (ar.title = au.name)
|
SELECT * FROM articles_range ar join authors_range au on (ar.title = au.name)
|
||||||
WHERE ar.author_id = 1 or au.id = 5;
|
WHERE ar.author_id = 1 or au.id = 5;
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
DEBUG: join prunable for task partitionId 0 and 1
|
DEBUG: join prunable for task partitionId 0 and 1
|
||||||
|
@ -1838,7 +1833,7 @@ DETAIL: Creating dependency on merge taskId 20
|
||||||
|
|
||||||
RESET citus.task_executor_type;
|
RESET citus.task_executor_type;
|
||||||
-- bogus query, join on non-partition column, but router plannable due to filters
|
-- bogus query, join on non-partition column, but router plannable due to filters
|
||||||
SELECT * FROM articles_range ar join authors_range au on (ar.id = au.id)
|
SELECT * FROM articles_range ar join authors_range au on (ar.id = au.id)
|
||||||
WHERE ar.author_id = 1 and au.id < 10;
|
WHERE ar.author_id = 1 and au.id < 10;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
|
@ -1916,7 +1911,6 @@ DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
----+-----------+-------+------------+------+----
|
----+-----------+-------+------------+------+----
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
|
|
||||||
-- following is a bug, function should have been
|
-- following is a bug, function should have been
|
||||||
-- evaluated at master before going to worker
|
-- evaluated at master before going to worker
|
||||||
-- need to use a append distributed table here
|
-- need to use a append distributed table here
|
||||||
|
@ -1948,7 +1942,7 @@ SET client_min_messages TO ERROR;
|
||||||
\set VERBOSITY terse
|
\set VERBOSITY terse
|
||||||
SELECT raise_failed_execution_router($$
|
SELECT raise_failed_execution_router($$
|
||||||
SELECT author_id FROM articles_append
|
SELECT author_id FROM articles_append
|
||||||
WHERE
|
WHERE
|
||||||
substring('articles_append'::regclass::text, 1, 5) = 'hello'
|
substring('articles_append'::regclass::text, 1, 5) = 'hello'
|
||||||
ORDER BY
|
ORDER BY
|
||||||
author_id
|
author_id
|
||||||
|
@ -1958,7 +1952,7 @@ ERROR: Task failed to execute
|
||||||
-- same query with where false but evaluation left to worker
|
-- same query with where false but evaluation left to worker
|
||||||
SELECT raise_failed_execution_router($$
|
SELECT raise_failed_execution_router($$
|
||||||
SELECT author_id FROM articles_append
|
SELECT author_id FROM articles_append
|
||||||
WHERE
|
WHERE
|
||||||
substring('articles_append'::regclass::text, 1, 4) = 'hello'
|
substring('articles_append'::regclass::text, 1, 4) = 'hello'
|
||||||
ORDER BY
|
ORDER BY
|
||||||
author_id
|
author_id
|
||||||
|
@ -1968,7 +1962,7 @@ ERROR: Task failed to execute
|
||||||
-- same query on router planner with where false but evaluation left to worker
|
-- same query on router planner with where false but evaluation left to worker
|
||||||
SELECT raise_failed_execution_router($$
|
SELECT raise_failed_execution_router($$
|
||||||
SELECT author_id FROM articles_single_shard_hash
|
SELECT author_id FROM articles_single_shard_hash
|
||||||
WHERE
|
WHERE
|
||||||
substring('articles_single_shard_hash'::regclass::text, 1, 4) = 'hello'
|
substring('articles_single_shard_hash'::regclass::text, 1, 4) = 'hello'
|
||||||
ORDER BY
|
ORDER BY
|
||||||
author_id
|
author_id
|
||||||
|
@ -1977,7 +1971,7 @@ $$);
|
||||||
ERROR: Task failed to execute
|
ERROR: Task failed to execute
|
||||||
SELECT raise_failed_execution_router($$
|
SELECT raise_failed_execution_router($$
|
||||||
SELECT author_id FROM articles_hash
|
SELECT author_id FROM articles_hash
|
||||||
WHERE
|
WHERE
|
||||||
author_id = 1
|
author_id = 1
|
||||||
AND substring('articles_hash'::regclass::text, 1, 5) = 'hello'
|
AND substring('articles_hash'::regclass::text, 1, 5) = 'hello'
|
||||||
ORDER BY
|
ORDER BY
|
||||||
|
@ -1993,7 +1987,7 @@ BEGIN
|
||||||
RETURN md5($1::text);
|
RETURN md5($1::text);
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql' IMMUTABLE;
|
$$ LANGUAGE 'plpgsql' IMMUTABLE;
|
||||||
-- not router plannable, returns all rows
|
-- not router plannable, returns all rows
|
||||||
SELECT * FROM articles_hash
|
SELECT * FROM articles_hash
|
||||||
WHERE
|
WHERE
|
||||||
someDummyFunction('articles_hash') = md5('articles_hash')
|
someDummyFunction('articles_hash') = md5('articles_hash')
|
||||||
|
@ -2024,10 +2018,10 @@ ERROR: Task failed to execute
|
||||||
SET client_min_messages TO 'NOTICE';
|
SET client_min_messages TO 'NOTICE';
|
||||||
DROP FUNCTION someDummyFunction(regclass);
|
DROP FUNCTION someDummyFunction(regclass);
|
||||||
SET client_min_messages TO 'DEBUG2';
|
SET client_min_messages TO 'DEBUG2';
|
||||||
-- complex query hitting a single shard
|
-- complex query hitting a single shard
|
||||||
SELECT
|
SELECT
|
||||||
count(DISTINCT CASE
|
count(DISTINCT CASE
|
||||||
WHEN
|
WHEN
|
||||||
word_count > 100
|
word_count > 100
|
||||||
THEN
|
THEN
|
||||||
id
|
id
|
||||||
|
@ -2049,7 +2043,7 @@ DETAIL: distribution column value: 5
|
||||||
-- same query is not router plannable if hits multiple shards
|
-- same query is not router plannable if hits multiple shards
|
||||||
SELECT
|
SELECT
|
||||||
count(DISTINCT CASE
|
count(DISTINCT CASE
|
||||||
WHEN
|
WHEN
|
||||||
word_count > 100
|
word_count > 100
|
||||||
THEN
|
THEN
|
||||||
id
|
id
|
||||||
|
@ -2117,7 +2111,7 @@ DETAIL: distribution column value: 1
|
||||||
END;
|
END;
|
||||||
-- cursor queries are router plannable
|
-- cursor queries are router plannable
|
||||||
BEGIN;
|
BEGIN;
|
||||||
DECLARE test_cursor CURSOR FOR
|
DECLARE test_cursor CURSOR FOR
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 1
|
WHERE author_id = 1
|
||||||
|
@ -2166,7 +2160,6 @@ DETAIL: distribution column value: 1
|
||||||
21 1 arcading 5890
|
21 1 arcading 5890
|
||||||
31 1 athwartships 7271
|
31 1 athwartships 7271
|
||||||
41 1 aznavour 11814
|
41 1 aznavour 11814
|
||||||
|
|
||||||
-- table creation queries inside can be router plannable
|
-- table creation queries inside can be router plannable
|
||||||
CREATE TEMP TABLE temp_articles_hash as
|
CREATE TEMP TABLE temp_articles_hash as
|
||||||
SELECT *
|
SELECT *
|
||||||
|
|
|
@ -2,12 +2,12 @@ CREATE SCHEMA fast_path_router_select;
|
||||||
SET search_path TO fast_path_router_select;
|
SET search_path TO fast_path_router_select;
|
||||||
SET citus.next_shard_id TO 1840000;
|
SET citus.next_shard_id TO 1840000;
|
||||||
-- all the tests in this file is intended for testing fast-path
|
-- all the tests in this file is intended for testing fast-path
|
||||||
-- router planner, so we're explicitly enabling itin this file.
|
-- router planner, so we're explicitly enabling itin this file.
|
||||||
-- We've bunch of other tests that triggers non-fast-path-router
|
-- We've bunch of other tests that triggers non-fast-path-router
|
||||||
-- planner (note this is already true by default)
|
-- planner (note this is already true by default)
|
||||||
SET citus.enable_fast_path_router_planner TO true;
|
SET citus.enable_fast_path_router_planner TO true;
|
||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
-- test router planner functionality for via fast path on
|
-- test router planner functionality for via fast path on
|
||||||
-- single shard select queries
|
-- single shard select queries
|
||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
CREATE TABLE articles_hash (
|
CREATE TABLE articles_hash (
|
||||||
|
@ -161,7 +161,7 @@ DETAIL: distribution column value: 1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- fast path planner only support = operator
|
-- fast path planner only support = operator
|
||||||
SELECT * FROM articles_hash WHERE author_id <= 1;
|
SELECT * FROM articles_hash WHERE author_id <= 1;
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
id | author_id | title | word_count
|
id | author_id | title | word_count
|
||||||
----+-----------+--------------+------------
|
----+-----------+--------------+------------
|
||||||
|
@ -172,7 +172,7 @@ DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
41 | 1 | aznavour | 11814
|
41 | 1 | aznavour | 11814
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
SELECT * FROM articles_hash WHERE author_id IN (1, 3);
|
SELECT * FROM articles_hash WHERE author_id IN (1, 3);
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
DEBUG: Plan is router executable
|
DEBUG: Plan is router executable
|
||||||
id | author_id | title | word_count
|
id | author_id | title | word_count
|
||||||
|
@ -221,7 +221,7 @@ DETAIL: distribution column value: 1
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
-- this is a different case where each CTE is recursively planned and those goes
|
-- this is a different case where each CTE is recursively planned and those goes
|
||||||
-- through the fast-path router planner, but the top level join is not
|
-- through the fast-path router planner, but the top level join is not
|
||||||
WITH id_author AS ( SELECT id, author_id FROM articles_hash WHERE author_id = 1),
|
WITH id_author AS ( SELECT id, author_id FROM articles_hash WHERE author_id = 1),
|
||||||
id_title AS (SELECT id, title from articles_hash WHERE author_id = 2)
|
id_title AS (SELECT id, title from articles_hash WHERE author_id = 2)
|
||||||
SELECT * FROM id_author, id_title WHERE id_author.id = id_title.id;
|
SELECT * FROM id_author, id_title WHERE id_author.id = id_title.id;
|
||||||
|
@ -243,7 +243,7 @@ DEBUG: Plan is router executable
|
||||||
----+-----------+----+-------
|
----+-----------+----+-------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
CREATE TABLE company_employees (company_id int, employee_id int, manager_id int);
|
CREATE TABLE company_employees (company_id int, employee_id int, manager_id int);
|
||||||
SELECT master_create_distributed_table('company_employees', 'company_id', 'hash');
|
SELECT master_create_distributed_table('company_employees', 'company_id', 'hash');
|
||||||
master_create_distributed_table
|
master_create_distributed_table
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
@ -296,7 +296,7 @@ DETAIL: distribution column value: 3
|
||||||
WITH RECURSIVE hierarchy as (
|
WITH RECURSIVE hierarchy as (
|
||||||
SELECT *, 1 AS level
|
SELECT *, 1 AS level
|
||||||
FROM company_employees
|
FROM company_employees
|
||||||
WHERE company_id = 1 and manager_id = 0
|
WHERE company_id = 1 and manager_id = 0
|
||||||
UNION
|
UNION
|
||||||
SELECT ce.*, (h.level+1)
|
SELECT ce.*, (h.level+1)
|
||||||
FROM hierarchy h JOIN company_employees ce
|
FROM hierarchy h JOIN company_employees ce
|
||||||
|
@ -428,7 +428,7 @@ DEBUG: push down of limit count: 5
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
SELECT articles_hash.id,test.word_count
|
SELECT articles_hash.id,test.word_count
|
||||||
FROM articles_hash, (SELECT id, word_count FROM articles_hash) AS test
|
FROM articles_hash, (SELECT id, word_count FROM articles_hash) AS test
|
||||||
WHERE test.id = articles_hash.id and articles_hash.author_id = 1
|
WHERE test.id = articles_hash.id and articles_hash.author_id = 1
|
||||||
ORDER BY articles_hash.id;
|
ORDER BY articles_hash.id;
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
|
@ -568,7 +568,6 @@ DETAIL: distribution column value: 1
|
||||||
21 | 1 | arcading | 5890
|
21 | 1 | arcading | 5890
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
-- single shard select with group by on non-partition column goes through fast-path planning
|
-- single shard select with group by on non-partition column goes through fast-path planning
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
|
@ -698,7 +697,7 @@ DETAIL: distribution column value: 1
|
||||||
|
|
||||||
-- Test various filtering options for router plannable check
|
-- Test various filtering options for router plannable check
|
||||||
SET client_min_messages to 'DEBUG2';
|
SET client_min_messages to 'DEBUG2';
|
||||||
-- cannot go through fast-path if there is
|
-- cannot go through fast-path if there is
|
||||||
-- explicit coercion
|
-- explicit coercion
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
|
@ -715,7 +714,7 @@ DETAIL: distribution column value: 1
|
||||||
41 | 1 | aznavour | 11814
|
41 | 1 | aznavour | 11814
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
-- can go through fast-path if there is
|
-- can go through fast-path if there is
|
||||||
-- implicit coercion
|
-- implicit coercion
|
||||||
-- This doesn't work see the related issue
|
-- This doesn't work see the related issue
|
||||||
-- reported https://github.com/citusdata/citus/issues/2605
|
-- reported https://github.com/citusdata/citus/issues/2605
|
||||||
|
@ -765,7 +764,6 @@ DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
41 | 1 | aznavour | 11814
|
41 | 1 | aznavour | 11814
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
|
|
||||||
-- goes through fast-path planning because
|
-- goes through fast-path planning because
|
||||||
-- the dist. key is ANDed with the rest of the
|
-- the dist. key is ANDed with the rest of the
|
||||||
-- filters
|
-- filters
|
||||||
|
@ -822,9 +820,8 @@ DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
41 | 1 | aznavour | 11814
|
41 | 1 | aznavour | 11814
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
|
|
||||||
-- Citus does not qualify this as a fast-path because
|
-- Citus does not qualify this as a fast-path because
|
||||||
-- dist_key = func()
|
-- dist_key = func()
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = abs(-1);
|
WHERE author_id = abs(-1);
|
||||||
|
@ -841,7 +838,7 @@ DETAIL: distribution column value: 1
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
-- Citus does not qualify this as a fast-path because
|
-- Citus does not qualify this as a fast-path because
|
||||||
-- dist_key = func()
|
-- dist_key = func()
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE 1 = abs(author_id);
|
WHERE 1 = abs(author_id);
|
||||||
|
@ -856,7 +853,7 @@ DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
-- Citus does not qualify this as a fast-path because
|
-- Citus does not qualify this as a fast-path because
|
||||||
-- dist_key = func()
|
-- dist_key = func()
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = abs(author_id - 2);
|
WHERE author_id = abs(author_id - 2);
|
||||||
|
@ -1058,7 +1055,7 @@ DETAIL: distribution column value: 1
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
-- window functions are supported with fast-path router plannable
|
-- window functions are supported with fast-path router plannable
|
||||||
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 5;
|
WHERE author_id = 5;
|
||||||
DEBUG: Distributed planning for a fast-path router query
|
DEBUG: Distributed planning for a fast-path router query
|
||||||
|
@ -1074,7 +1071,7 @@ DETAIL: distribution column value: 5
|
||||||
aminate | aruru | 11389
|
aminate | aruru | 11389
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 5
|
WHERE author_id = 5
|
||||||
ORDER BY word_count DESC;
|
ORDER BY word_count DESC;
|
||||||
|
@ -1123,8 +1120,8 @@ DETAIL: distribution column value: 1
|
||||||
41 | 11814 | 7178.8000000000000000
|
41 | 11814 | 7178.8000000000000000
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
SELECT word_count, rank() OVER (PARTITION BY author_id ORDER BY word_count)
|
SELECT word_count, rank() OVER (PARTITION BY author_id ORDER BY word_count)
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 1;
|
WHERE author_id = 1;
|
||||||
DEBUG: Distributed planning for a fast-path router query
|
DEBUG: Distributed planning for a fast-path router query
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1142,7 +1139,7 @@ DETAIL: distribution column value: 1
|
||||||
-- some more tests on complex target lists
|
-- some more tests on complex target lists
|
||||||
SELECT DISTINCT ON (author_id, id) author_id, id,
|
SELECT DISTINCT ON (author_id, id) author_id, id,
|
||||||
MIN(id) over (order by avg(word_count)) * AVG(id * 5.2 + (1.0/max(word_count))) over (order by max(word_count)) as t1,
|
MIN(id) over (order by avg(word_count)) * AVG(id * 5.2 + (1.0/max(word_count))) over (order by max(word_count)) as t1,
|
||||||
count(*) FILTER (WHERE title LIKE 'al%') as cnt_with_filter,
|
count(*) FILTER (WHERE title LIKE 'al%') as cnt_with_filter,
|
||||||
count(*) FILTER (WHERE '0300030' LIKE '%3%') as cnt_with_filter_2,
|
count(*) FILTER (WHERE '0300030' LIKE '%3%') as cnt_with_filter_2,
|
||||||
avg(case when id > 2 then char_length(word_count::text) * (id * strpos(word_count::text, '1')) end) as case_cnt,
|
avg(case when id > 2 then char_length(word_count::text) * (id * strpos(word_count::text, '1')) end) as case_cnt,
|
||||||
COALESCE(strpos(avg(word_count)::text, '1'), 20)
|
COALESCE(strpos(avg(word_count)::text, '1'), 20)
|
||||||
|
@ -1165,7 +1162,7 @@ DETAIL: distribution column value: 1
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
-- where false queries are router plannable but not fast-path
|
-- where false queries are router plannable but not fast-path
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE false;
|
WHERE false;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1175,7 +1172,7 @@ DEBUG: Plan is router executable
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- fast-path with false
|
-- fast-path with false
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 1 and false;
|
WHERE author_id = 1 and false;
|
||||||
DEBUG: Distributed planning for a fast-path router query
|
DEBUG: Distributed planning for a fast-path router query
|
||||||
|
@ -1186,7 +1183,7 @@ DEBUG: Plan is router executable
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- fast-path with false
|
-- fast-path with false
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 1 and 1=0;
|
WHERE author_id = 1 and 1=0;
|
||||||
DEBUG: Distributed planning for a fast-path router query
|
DEBUG: Distributed planning for a fast-path router query
|
||||||
|
@ -1197,7 +1194,7 @@ DETAIL: distribution column value: 1
|
||||||
----+-----------+-------+------------
|
----+-----------+-------+------------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE null and author_id = 1;
|
WHERE null and author_id = 1;
|
||||||
DEBUG: Distributed planning for a fast-path router query
|
DEBUG: Distributed planning for a fast-path router query
|
||||||
|
@ -1209,7 +1206,7 @@ DEBUG: Plan is router executable
|
||||||
|
|
||||||
-- we cannot qualify dist_key = X operator Y via
|
-- we cannot qualify dist_key = X operator Y via
|
||||||
-- fast-path planning
|
-- fast-path planning
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 1 + 1;
|
WHERE author_id = 1 + 1;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1226,7 +1223,7 @@ DETAIL: distribution column value: 2
|
||||||
|
|
||||||
-- where false with immutable function returning false
|
-- where false with immutable function returning false
|
||||||
-- goes through fast-path
|
-- goes through fast-path
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash a
|
FROM articles_hash a
|
||||||
WHERE a.author_id = 10 and int4eq(1, 2);
|
WHERE a.author_id = 10 and int4eq(1, 2);
|
||||||
DEBUG: Distributed planning for a fast-path router query
|
DEBUG: Distributed planning for a fast-path router query
|
||||||
|
@ -1240,7 +1237,7 @@ DETAIL: distribution column value: 10
|
||||||
-- partition_column is null clause does not prune out any shards,
|
-- partition_column is null clause does not prune out any shards,
|
||||||
-- all shards remain after shard pruning, not router plannable
|
-- all shards remain after shard pruning, not router plannable
|
||||||
-- not fast-path router either
|
-- not fast-path router either
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash a
|
FROM articles_hash a
|
||||||
WHERE a.author_id is null;
|
WHERE a.author_id is null;
|
||||||
DEBUG: Router planner cannot handle multi-shard select queries
|
DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
|
@ -1251,7 +1248,7 @@ DEBUG: Router planner cannot handle multi-shard select queries
|
||||||
-- partition_column equals to null clause prunes out all shards
|
-- partition_column equals to null clause prunes out all shards
|
||||||
-- no shards after shard pruning, router plannable
|
-- no shards after shard pruning, router plannable
|
||||||
-- not fast-path router either
|
-- not fast-path router either
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash a
|
FROM articles_hash a
|
||||||
WHERE a.author_id = null;
|
WHERE a.author_id = null;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1295,8 +1292,8 @@ DEBUG: Plan is router executable
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- window functions with where false
|
-- window functions with where false
|
||||||
SELECT word_count, rank() OVER (PARTITION BY author_id ORDER BY word_count)
|
SELECT word_count, rank() OVER (PARTITION BY author_id ORDER BY word_count)
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 1 and 1=0;
|
WHERE author_id = 1 and 1=0;
|
||||||
DEBUG: Distributed planning for a fast-path router query
|
DEBUG: Distributed planning for a fast-path router query
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -1331,7 +1328,7 @@ END;
|
||||||
$$LANGUAGE plpgsql;
|
$$LANGUAGE plpgsql;
|
||||||
SET client_min_messages TO ERROR;
|
SET client_min_messages TO ERROR;
|
||||||
\set VERBOSITY terse
|
\set VERBOSITY terse
|
||||||
-- fast path router plannable, but errors
|
-- fast path router plannable, but errors
|
||||||
SELECT raise_failed_execution_f_router($$
|
SELECT raise_failed_execution_f_router($$
|
||||||
SELECT * FROM articles_hash
|
SELECT * FROM articles_hash
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -1350,7 +1347,7 @@ SET client_min_messages TO 'DEBUG2';
|
||||||
-- complex query hitting a single shard and a fast-path
|
-- complex query hitting a single shard and a fast-path
|
||||||
SELECT
|
SELECT
|
||||||
count(DISTINCT CASE
|
count(DISTINCT CASE
|
||||||
WHEN
|
WHEN
|
||||||
word_count > 100
|
word_count > 100
|
||||||
THEN
|
THEN
|
||||||
id
|
id
|
||||||
|
@ -1414,7 +1411,7 @@ END;
|
||||||
WARNING: there is no transaction in progress
|
WARNING: there is no transaction in progress
|
||||||
-- cursor queries are fast-path router plannable
|
-- cursor queries are fast-path router plannable
|
||||||
BEGIN;
|
BEGIN;
|
||||||
DECLARE test_cursor CURSOR FOR
|
DECLARE test_cursor CURSOR FOR
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM articles_hash
|
FROM articles_hash
|
||||||
WHERE author_id = 1
|
WHERE author_id = 1
|
||||||
|
@ -1465,7 +1462,6 @@ DETAIL: distribution column value: 1
|
||||||
21 1 arcading 5890
|
21 1 arcading 5890
|
||||||
31 1 athwartships 7271
|
31 1 athwartships 7271
|
||||||
41 1 aznavour 11814
|
41 1 aznavour 11814
|
||||||
|
|
||||||
-- table creation queries inside can be fast-path router plannable
|
-- table creation queries inside can be fast-path router plannable
|
||||||
CREATE TEMP TABLE temp_articles_hash as
|
CREATE TEMP TABLE temp_articles_hash as
|
||||||
SELECT *
|
SELECT *
|
||||||
|
@ -1659,8 +1655,8 @@ BEGIN
|
||||||
return max_id;
|
return max_id;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
-- we don't want too many details. though we're omitting
|
-- we don't want too many details. though we're omitting
|
||||||
-- "DETAIL: distribution column value:", we see it acceptable
|
-- "DETAIL: distribution column value:", we see it acceptable
|
||||||
-- since the query results verifies the correctness
|
-- since the query results verifies the correctness
|
||||||
\set VERBOSITY terse
|
\set VERBOSITY terse
|
||||||
SELECT author_articles_max_id();
|
SELECT author_articles_max_id();
|
||||||
|
@ -1936,7 +1932,7 @@ DEBUG: Plan is router executable
|
||||||
-- insert .. select via coordinator could also
|
-- insert .. select via coordinator could also
|
||||||
-- use fast-path queries
|
-- use fast-path queries
|
||||||
PREPARE insert_sel(int, int) AS
|
PREPARE insert_sel(int, int) AS
|
||||||
INSERT INTO articles_hash
|
INSERT INTO articles_hash
|
||||||
SELECT * FROM articles_hash WHERE author_id = $2 AND word_count = $1 OFFSET 0;
|
SELECT * FROM articles_hash WHERE author_id = $2 AND word_count = $1 OFFSET 0;
|
||||||
EXECUTE insert_sel(1,1);
|
EXECUTE insert_sel(1,1);
|
||||||
DEBUG: OFFSET clauses are not allowed in distributed INSERT ... SELECT queries
|
DEBUG: OFFSET clauses are not allowed in distributed INSERT ... SELECT queries
|
||||||
|
@ -1983,10 +1979,10 @@ DETAIL: distribution column value: 1
|
||||||
-- one final interesting preperad statement
|
-- one final interesting preperad statement
|
||||||
-- where one of the filters is on the target list
|
-- where one of the filters is on the target list
|
||||||
PREPARE fast_path_agg_filter(int, int) AS
|
PREPARE fast_path_agg_filter(int, int) AS
|
||||||
SELECT
|
SELECT
|
||||||
count(*) FILTER (WHERE word_count=$1)
|
count(*) FILTER (WHERE word_count=$1)
|
||||||
FROM
|
FROM
|
||||||
articles_hash
|
articles_hash
|
||||||
WHERE author_id = $2;
|
WHERE author_id = $2;
|
||||||
EXECUTE fast_path_agg_filter(1,1);
|
EXECUTE fast_path_agg_filter(1,1);
|
||||||
DEBUG: Distributed planning for a fast-path router query
|
DEBUG: Distributed planning for a fast-path router query
|
||||||
|
@ -2050,7 +2046,7 @@ DETAIL: distribution column value: 6
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- views internally become subqueries, so not fast-path router query
|
-- views internally become subqueries, so not fast-path router query
|
||||||
CREATE VIEW test_view AS
|
CREATE VIEW test_view AS
|
||||||
SELECT * FROM articles_hash WHERE author_id = 1;
|
SELECT * FROM articles_hash WHERE author_id = 1;
|
||||||
SELECT * FROM test_view;
|
SELECT * FROM test_view;
|
||||||
DEBUG: Creating router plan
|
DEBUG: Creating router plan
|
||||||
|
@ -2131,7 +2127,7 @@ CREATE TABLE collections_list (
|
||||||
collection_id integer,
|
collection_id integer,
|
||||||
value numeric
|
value numeric
|
||||||
) PARTITION BY LIST (collection_id );
|
) PARTITION BY LIST (collection_id );
|
||||||
CREATE TABLE collections_list_1
|
CREATE TABLE collections_list_1
|
||||||
PARTITION OF collections_list (key, ts, collection_id, value)
|
PARTITION OF collections_list (key, ts, collection_id, value)
|
||||||
FOR VALUES IN ( 1 );
|
FOR VALUES IN ( 1 );
|
||||||
CREATE TABLE collections_list_2
|
CREATE TABLE collections_list_2
|
||||||
|
|
|
@ -10,7 +10,7 @@ SELECT DISTINCT l_orderkey, now() FROM lineitem_hash_part LIMIT 0;
|
||||||
------------+-----
|
------------+-----
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
SELECT DISTINCT l_partkey, 1 + (random() * 0)::int FROM lineitem_hash_part ORDER BY 1 DESC LIMIT 3;
|
SELECT DISTINCT l_partkey, 1 + (random() * 0)::int FROM lineitem_hash_part ORDER BY 1 DESC LIMIT 3;
|
||||||
l_partkey | ?column?
|
l_partkey | ?column?
|
||||||
-----------+----------
|
-----------+----------
|
||||||
199973 | 1
|
199973 | 1
|
||||||
|
@ -152,9 +152,9 @@ SELECT DISTINCT l_shipmode FROM lineitem_hash_part ORDER BY 1 DESC;
|
||||||
AIR
|
AIR
|
||||||
(7 rows)
|
(7 rows)
|
||||||
|
|
||||||
-- distinct with multiple columns
|
-- distinct with multiple columns
|
||||||
SELECT DISTINCT l_orderkey, o_orderdate
|
SELECT DISTINCT l_orderkey, o_orderdate
|
||||||
FROM lineitem_hash_part JOIN orders_hash_part ON (l_orderkey = o_orderkey)
|
FROM lineitem_hash_part JOIN orders_hash_part ON (l_orderkey = o_orderkey)
|
||||||
WHERE l_orderkey < 10
|
WHERE l_orderkey < 10
|
||||||
ORDER BY l_orderkey;
|
ORDER BY l_orderkey;
|
||||||
l_orderkey | o_orderdate
|
l_orderkey | o_orderdate
|
||||||
|
@ -199,7 +199,6 @@ SELECT DISTINCT l_orderkey, count(*)
|
||||||
197 | 6
|
197 | 6
|
||||||
(19 rows)
|
(19 rows)
|
||||||
|
|
||||||
|
|
||||||
-- explain the query to see actual plan
|
-- explain the query to see actual plan
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT l_orderkey, count(*)
|
SELECT DISTINCT l_orderkey, count(*)
|
||||||
|
@ -272,8 +271,7 @@ SELECT DISTINCT count(*)
|
||||||
4
|
4
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
|
-- explain the query to see actual plan. We expect to see Aggregate node having
|
||||||
-- explain the query to see actual plan. We expect to see Aggregate node having
|
|
||||||
-- group by key on count(*) column, since columns in the Group By doesn't guarantee
|
-- group by key on count(*) column, since columns in the Group By doesn't guarantee
|
||||||
-- the uniqueness of the result.
|
-- the uniqueness of the result.
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
|
@ -350,7 +348,6 @@ SELECT DISTINCT l_suppkey, count(*)
|
||||||
14 | 1
|
14 | 1
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
|
|
||||||
-- explain the query to see actual plan. Similar to the explain of the query above.
|
-- explain the query to see actual plan. Similar to the explain of the query above.
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT l_suppkey, count(*)
|
SELECT DISTINCT l_suppkey, count(*)
|
||||||
|
@ -377,7 +374,7 @@ EXPLAIN (COSTS FALSE)
|
||||||
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
||||||
(15 rows)
|
(15 rows)
|
||||||
|
|
||||||
-- check the plan if the hash aggreate is disabled. Similar to the explain of
|
-- check the plan if the hash aggreate is disabled. Similar to the explain of
|
||||||
-- the query above.
|
-- the query above.
|
||||||
SET enable_hashagg TO off;
|
SET enable_hashagg TO off;
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
|
@ -430,7 +427,6 @@ SELECT DISTINCT l_suppkey, avg(l_partkey)
|
||||||
12 | 17510.0000000000000000
|
12 | 17510.0000000000000000
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
|
|
||||||
-- explain the query to see actual plan. Similar to the explain of the query above.
|
-- explain the query to see actual plan. Similar to the explain of the query above.
|
||||||
-- Only aggregate functions will be changed.
|
-- Only aggregate functions will be changed.
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
|
@ -510,7 +506,6 @@ SELECT DISTINCT ON (l_suppkey) avg(l_partkey)
|
||||||
77506.000000000000
|
77506.000000000000
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
|
|
||||||
-- explain the query to see actual plan. We expect to see sort+unique to handle
|
-- explain the query to see actual plan. We expect to see sort+unique to handle
|
||||||
-- distinct on.
|
-- distinct on.
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
|
@ -537,7 +532,7 @@ EXPLAIN (COSTS FALSE)
|
||||||
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
||||||
(14 rows)
|
(14 rows)
|
||||||
|
|
||||||
-- check the plan if the hash aggreate is disabled. We expect to see sort+unique to
|
-- check the plan if the hash aggreate is disabled. We expect to see sort+unique to
|
||||||
-- handle distinct on.
|
-- handle distinct on.
|
||||||
SET enable_hashagg TO off;
|
SET enable_hashagg TO off;
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
|
@ -587,7 +582,6 @@ SELECT DISTINCT avg(ceil(l_partkey / 2))
|
||||||
122
|
122
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
|
|
||||||
-- explain the query to see actual plan
|
-- explain the query to see actual plan
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT avg(ceil(l_partkey / 2))
|
SELECT DISTINCT avg(ceil(l_partkey / 2))
|
||||||
|
@ -622,7 +616,7 @@ EXPLAIN (COSTS FALSE)
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
GROUP BY l_suppkey, l_linenumber
|
GROUP BY l_suppkey, l_linenumber
|
||||||
ORDER BY 1
|
ORDER BY 1
|
||||||
LIMIT 10;
|
LIMIT 10;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
----------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------
|
||||||
Limit
|
Limit
|
||||||
|
@ -645,11 +639,10 @@ EXPLAIN (COSTS FALSE)
|
||||||
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
||||||
(18 rows)
|
(18 rows)
|
||||||
|
|
||||||
|
SET enable_hashagg TO on;
|
||||||
SET enable_hashagg TO on;
|
|
||||||
-- expression among aggregations.
|
-- expression among aggregations.
|
||||||
SELECT DISTINCT sum(l_suppkey) + count(l_partkey) AS dis
|
SELECT DISTINCT sum(l_suppkey) + count(l_partkey) AS dis
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
GROUP BY l_suppkey, l_linenumber
|
GROUP BY l_suppkey, l_linenumber
|
||||||
ORDER BY 1
|
ORDER BY 1
|
||||||
LIMIT 10;
|
LIMIT 10;
|
||||||
|
@ -667,11 +660,10 @@ SELECT DISTINCT sum(l_suppkey) + count(l_partkey) AS dis
|
||||||
15
|
15
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
|
|
||||||
-- explain the query to see actual plan
|
-- explain the query to see actual plan
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT sum(l_suppkey) + count(l_partkey) AS dis
|
SELECT DISTINCT sum(l_suppkey) + count(l_partkey) AS dis
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
GROUP BY l_suppkey, l_linenumber
|
GROUP BY l_suppkey, l_linenumber
|
||||||
ORDER BY 1
|
ORDER BY 1
|
||||||
LIMIT 10;
|
LIMIT 10;
|
||||||
|
@ -698,11 +690,11 @@ EXPLAIN (COSTS FALSE)
|
||||||
-- to a bug right now, expectation must be corrected after fixing it.
|
-- to a bug right now, expectation must be corrected after fixing it.
|
||||||
SET enable_hashagg TO off;
|
SET enable_hashagg TO off;
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT sum(l_suppkey) + count(l_partkey) AS dis
|
SELECT DISTINCT sum(l_suppkey) + count(l_partkey) AS dis
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
GROUP BY l_suppkey, l_linenumber
|
GROUP BY l_suppkey, l_linenumber
|
||||||
ORDER BY 1
|
ORDER BY 1
|
||||||
LIMIT 10;
|
LIMIT 10;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
--------------------------------------------------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
Limit
|
Limit
|
||||||
|
@ -725,13 +717,11 @@ EXPLAIN (COSTS FALSE)
|
||||||
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
||||||
(18 rows)
|
(18 rows)
|
||||||
|
|
||||||
|
SET enable_hashagg TO on;
|
||||||
SET enable_hashagg TO on;
|
|
||||||
|
|
||||||
-- distinct on all columns, note Group By columns guarantees uniqueness of the
|
-- distinct on all columns, note Group By columns guarantees uniqueness of the
|
||||||
-- result list.
|
-- result list.
|
||||||
SELECT DISTINCT *
|
SELECT DISTINCT *
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
|
GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
|
||||||
ORDER BY 1,2
|
ORDER BY 1,2
|
||||||
LIMIT 10;
|
LIMIT 10;
|
||||||
|
@ -749,12 +739,11 @@ SELECT DISTINCT *
|
||||||
3 | 29380 | 1883 | 4 | 2.00 | 2618.76 | 0.01 | 0.06 | A | F | 12-04-1993 | 01-07-1994 | 01-01-1994 | NONE | TRUCK | y. fluffily pending d
|
3 | 29380 | 1883 | 4 | 2.00 | 2618.76 | 0.01 | 0.06 | A | F | 12-04-1993 | 01-07-1994 | 01-01-1994 | NONE | TRUCK | y. fluffily pending d
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
|
|
||||||
-- explain the query to see actual plan. We expect to see only one aggregation
|
-- explain the query to see actual plan. We expect to see only one aggregation
|
||||||
-- node since group by columns guarantees the uniqueness.
|
-- node since group by columns guarantees the uniqueness.
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT *
|
SELECT DISTINCT *
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
|
GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
|
||||||
ORDER BY 1,2
|
ORDER BY 1,2
|
||||||
LIMIT 10;
|
LIMIT 10;
|
||||||
|
@ -779,15 +768,15 @@ EXPLAIN (COSTS FALSE)
|
||||||
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
||||||
(17 rows)
|
(17 rows)
|
||||||
|
|
||||||
-- check the plan if the hash aggreate is disabled. We expect to see only one
|
-- check the plan if the hash aggreate is disabled. We expect to see only one
|
||||||
-- aggregation node since group by columns guarantees the uniqueness.
|
-- aggregation node since group by columns guarantees the uniqueness.
|
||||||
SET enable_hashagg TO off;
|
SET enable_hashagg TO off;
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT *
|
SELECT DISTINCT *
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
|
GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
|
||||||
ORDER BY 1,2
|
ORDER BY 1,2
|
||||||
LIMIT 10;
|
LIMIT 10;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
Limit
|
Limit
|
||||||
|
@ -811,7 +800,6 @@ EXPLAIN (COSTS FALSE)
|
||||||
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
||||||
(19 rows)
|
(19 rows)
|
||||||
|
|
||||||
|
|
||||||
SET enable_hashagg TO on;
|
SET enable_hashagg TO on;
|
||||||
-- distinct on count distinct
|
-- distinct on count distinct
|
||||||
SELECT DISTINCT count(DISTINCT l_partkey), count(DISTINCT l_shipmode)
|
SELECT DISTINCT count(DISTINCT l_partkey), count(DISTINCT l_shipmode)
|
||||||
|
@ -847,7 +835,6 @@ SELECT DISTINCT count(DISTINCT l_partkey), count(DISTINCT l_shipmode)
|
||||||
7 | 7
|
7 | 7
|
||||||
(25 rows)
|
(25 rows)
|
||||||
|
|
||||||
|
|
||||||
-- explain the query to see actual plan. We expect to see aggregation plan for
|
-- explain the query to see actual plan. We expect to see aggregation plan for
|
||||||
-- the outer distinct.
|
-- the outer distinct.
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
|
@ -875,7 +862,7 @@ EXPLAIN (COSTS FALSE)
|
||||||
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
||||||
(16 rows)
|
(16 rows)
|
||||||
|
|
||||||
-- check the plan if the hash aggreate is disabled. We expect to see sort + unique
|
-- check the plan if the hash aggreate is disabled. We expect to see sort + unique
|
||||||
-- plans for the outer distinct.
|
-- plans for the outer distinct.
|
||||||
SET enable_hashagg TO off;
|
SET enable_hashagg TO off;
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
|
@ -906,11 +893,10 @@ EXPLAIN (COSTS FALSE)
|
||||||
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
||||||
(19 rows)
|
(19 rows)
|
||||||
|
|
||||||
|
|
||||||
SET enable_hashagg TO on;
|
SET enable_hashagg TO on;
|
||||||
-- distinct on aggregation with filter and expression
|
-- distinct on aggregation with filter and expression
|
||||||
SELECT DISTINCT ceil(count(case when l_partkey > 100000 THEN 1 ELSE 0 END) / 2) AS count
|
SELECT DISTINCT ceil(count(case when l_partkey > 100000 THEN 1 ELSE 0 END) / 2) AS count
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
GROUP BY l_suppkey
|
GROUP BY l_suppkey
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
||||||
count
|
count
|
||||||
|
@ -922,11 +908,10 @@ SELECT DISTINCT ceil(count(case when l_partkey > 100000 THEN 1 ELSE 0 END) / 2)
|
||||||
4
|
4
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
|
|
||||||
-- explain the query to see actual plan
|
-- explain the query to see actual plan
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT ceil(count(case when l_partkey > 100000 THEN 1 ELSE 0 END) / 2) AS count
|
SELECT DISTINCT ceil(count(case when l_partkey > 100000 THEN 1 ELSE 0 END) / 2) AS count
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
GROUP BY l_suppkey
|
GROUP BY l_suppkey
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
|
@ -950,8 +935,8 @@ EXPLAIN (COSTS FALSE)
|
||||||
-- check the plan if the hash aggreate is disabled
|
-- check the plan if the hash aggreate is disabled
|
||||||
SET enable_hashagg TO off;
|
SET enable_hashagg TO off;
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT ceil(count(case when l_partkey > 100000 THEN 1 ELSE 0 END) / 2) AS count
|
SELECT DISTINCT ceil(count(case when l_partkey > 100000 THEN 1 ELSE 0 END) / 2) AS count
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
GROUP BY l_suppkey
|
GROUP BY l_suppkey
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
|
@ -975,13 +960,11 @@ EXPLAIN (COSTS FALSE)
|
||||||
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
||||||
(17 rows)
|
(17 rows)
|
||||||
|
|
||||||
|
|
||||||
SET enable_hashagg TO on;
|
SET enable_hashagg TO on;
|
||||||
|
-- explain the query to see actual plan with array_agg aggregation.
|
||||||
-- explain the query to see actual plan with array_agg aggregation.
|
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT array_agg(l_linenumber), array_length(array_agg(l_linenumber), 1)
|
SELECT DISTINCT array_agg(l_linenumber), array_length(array_agg(l_linenumber), 1)
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
GROUP BY l_orderkey
|
GROUP BY l_orderkey
|
||||||
ORDER BY 2
|
ORDER BY 2
|
||||||
LIMIT 15;
|
LIMIT 15;
|
||||||
|
@ -1006,11 +989,11 @@ EXPLAIN (COSTS FALSE)
|
||||||
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
||||||
(17 rows)
|
(17 rows)
|
||||||
|
|
||||||
-- check the plan if the hash aggreate is disabled.
|
-- check the plan if the hash aggreate is disabled.
|
||||||
SET enable_hashagg TO off;
|
SET enable_hashagg TO off;
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT array_agg(l_linenumber), array_length(array_agg(l_linenumber), 1)
|
SELECT DISTINCT array_agg(l_linenumber), array_length(array_agg(l_linenumber), 1)
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
GROUP BY l_orderkey
|
GROUP BY l_orderkey
|
||||||
ORDER BY 2
|
ORDER BY 2
|
||||||
LIMIT 15;
|
LIMIT 15;
|
||||||
|
@ -1038,13 +1021,12 @@ EXPLAIN (COSTS FALSE)
|
||||||
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
|
||||||
(20 rows)
|
(20 rows)
|
||||||
|
|
||||||
|
|
||||||
SET enable_hashagg TO on;
|
SET enable_hashagg TO on;
|
||||||
-- distinct on non-partition column with aggregate
|
-- distinct on non-partition column with aggregate
|
||||||
-- this is the same as non-distinct version due to group by
|
-- this is the same as non-distinct version due to group by
|
||||||
SELECT DISTINCT l_partkey, count(*)
|
SELECT DISTINCT l_partkey, count(*)
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
GROUP BY 1
|
GROUP BY 1
|
||||||
HAVING count(*) > 2
|
HAVING count(*) > 2
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
||||||
l_partkey | count
|
l_partkey | count
|
||||||
|
@ -1062,12 +1044,11 @@ SELECT DISTINCT l_partkey, count(*)
|
||||||
199146 | 3
|
199146 | 3
|
||||||
(11 rows)
|
(11 rows)
|
||||||
|
|
||||||
|
|
||||||
-- explain the query to see actual plan
|
-- explain the query to see actual plan
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT l_partkey, count(*)
|
SELECT DISTINCT l_partkey, count(*)
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
GROUP BY 1
|
GROUP BY 1
|
||||||
HAVING count(*) > 2
|
HAVING count(*) > 2
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
|
@ -1091,7 +1072,7 @@ EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT l_partkey, avg(l_linenumber)
|
SELECT DISTINCT l_partkey, avg(l_linenumber)
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
WHERE l_partkey < 500
|
WHERE l_partkey < 500
|
||||||
GROUP BY 1
|
GROUP BY 1
|
||||||
HAVING avg(l_linenumber) > 2
|
HAVING avg(l_linenumber) > 2
|
||||||
ORDER BY 1;
|
ORDER BY 1;
|
||||||
l_partkey | avg
|
l_partkey | avg
|
||||||
|
@ -1137,7 +1118,6 @@ SELECT DISTINCT l_partkey, l_suppkey
|
||||||
197921 | 441
|
197921 | 441
|
||||||
(15 rows)
|
(15 rows)
|
||||||
|
|
||||||
|
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT l_partkey, l_suppkey
|
SELECT DISTINCT l_partkey, l_suppkey
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
|
@ -1180,7 +1160,6 @@ SELECT DISTINCT ON (l_orderkey) l_orderkey, l_partkey, l_suppkey
|
||||||
34 | 88362 | 871
|
34 | 88362 | 871
|
||||||
(10 rows)
|
(10 rows)
|
||||||
|
|
||||||
|
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT ON (l_orderkey) l_orderkey, l_partkey, l_suppkey
|
SELECT DISTINCT ON (l_orderkey) l_orderkey, l_partkey, l_suppkey
|
||||||
FROM lineitem_hash_part
|
FROM lineitem_hash_part
|
||||||
|
@ -1261,7 +1240,7 @@ EXPLAIN (COSTS FALSE)
|
||||||
-- distinct on with joins
|
-- distinct on with joins
|
||||||
-- each customer's first order key
|
-- each customer's first order key
|
||||||
SELECT DISTINCT ON (o_custkey) o_custkey, l_orderkey
|
SELECT DISTINCT ON (o_custkey) o_custkey, l_orderkey
|
||||||
FROM lineitem_hash_part JOIN orders_hash_part ON (l_orderkey = o_orderkey)
|
FROM lineitem_hash_part JOIN orders_hash_part ON (l_orderkey = o_orderkey)
|
||||||
WHERE o_custkey < 15
|
WHERE o_custkey < 15
|
||||||
ORDER BY 1,2;
|
ORDER BY 1,2;
|
||||||
o_custkey | l_orderkey
|
o_custkey | l_orderkey
|
||||||
|
@ -1281,7 +1260,7 @@ SELECT DISTINCT ON (o_custkey) o_custkey, l_orderkey
|
||||||
SELECT coordinator_plan($Q$
|
SELECT coordinator_plan($Q$
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT ON (o_custkey) o_custkey, l_orderkey
|
SELECT DISTINCT ON (o_custkey) o_custkey, l_orderkey
|
||||||
FROM lineitem_hash_part JOIN orders_hash_part ON (l_orderkey = o_orderkey)
|
FROM lineitem_hash_part JOIN orders_hash_part ON (l_orderkey = o_orderkey)
|
||||||
WHERE o_custkey < 15
|
WHERE o_custkey < 15
|
||||||
ORDER BY 1,2;
|
ORDER BY 1,2;
|
||||||
$Q$);
|
$Q$);
|
||||||
|
@ -1299,7 +1278,7 @@ $Q$);
|
||||||
SELECT coordinator_plan($Q$
|
SELECT coordinator_plan($Q$
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT ON (o_custkey) o_custkey, l_orderkey
|
SELECT DISTINCT ON (o_custkey) o_custkey, l_orderkey
|
||||||
FROM lineitem_hash_part JOIN orders_hash_part ON (l_orderkey = o_orderkey)
|
FROM lineitem_hash_part JOIN orders_hash_part ON (l_orderkey = o_orderkey)
|
||||||
WHERE o_custkey < 15;
|
WHERE o_custkey < 15;
|
||||||
$Q$);
|
$Q$);
|
||||||
coordinator_plan
|
coordinator_plan
|
||||||
|
@ -1313,7 +1292,7 @@ $Q$);
|
||||||
|
|
||||||
-- each customer's each order's first l_partkey
|
-- each customer's each order's first l_partkey
|
||||||
SELECT DISTINCT ON (o_custkey, l_orderkey) o_custkey, l_orderkey, l_linenumber, l_partkey
|
SELECT DISTINCT ON (o_custkey, l_orderkey) o_custkey, l_orderkey, l_linenumber, l_partkey
|
||||||
FROM lineitem_hash_part JOIN orders_hash_part ON (l_orderkey = o_orderkey)
|
FROM lineitem_hash_part JOIN orders_hash_part ON (l_orderkey = o_orderkey)
|
||||||
WHERE o_custkey < 20
|
WHERE o_custkey < 20
|
||||||
ORDER BY 1,2,3;
|
ORDER BY 1,2,3;
|
||||||
o_custkey | l_orderkey | l_linenumber | l_partkey
|
o_custkey | l_orderkey | l_linenumber | l_partkey
|
||||||
|
@ -1360,7 +1339,7 @@ SELECT DISTINCT ON (o_custkey, l_orderkey) o_custkey, l_orderkey, l_linenumber,
|
||||||
SELECT coordinator_plan($Q$
|
SELECT coordinator_plan($Q$
|
||||||
EXPLAIN (COSTS FALSE)
|
EXPLAIN (COSTS FALSE)
|
||||||
SELECT DISTINCT ON (o_custkey, l_orderkey) o_custkey, l_orderkey, l_linenumber, l_partkey
|
SELECT DISTINCT ON (o_custkey, l_orderkey) o_custkey, l_orderkey, l_linenumber, l_partkey
|
||||||
FROM lineitem_hash_part JOIN orders_hash_part ON (l_orderkey = o_orderkey)
|
FROM lineitem_hash_part JOIN orders_hash_part ON (l_orderkey = o_orderkey)
|
||||||
WHERE o_custkey < 20;
|
WHERE o_custkey < 20;
|
||||||
$Q$);
|
$Q$);
|
||||||
coordinator_plan
|
coordinator_plan
|
||||||
|
@ -1374,7 +1353,7 @@ $Q$);
|
||||||
|
|
||||||
-- each customer's each order's last l_partkey
|
-- each customer's each order's last l_partkey
|
||||||
SELECT DISTINCT ON (o_custkey, l_orderkey) o_custkey, l_orderkey, l_linenumber, l_partkey
|
SELECT DISTINCT ON (o_custkey, l_orderkey) o_custkey, l_orderkey, l_linenumber, l_partkey
|
||||||
FROM lineitem_hash_part JOIN orders_hash_part ON (l_orderkey = o_orderkey)
|
FROM lineitem_hash_part JOIN orders_hash_part ON (l_orderkey = o_orderkey)
|
||||||
WHERE o_custkey < 15
|
WHERE o_custkey < 15
|
||||||
ORDER BY 1,2,3 DESC;
|
ORDER BY 1,2,3 DESC;
|
||||||
o_custkey | l_orderkey | l_linenumber | l_partkey
|
o_custkey | l_orderkey | l_linenumber | l_partkey
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -374,7 +374,6 @@ DEBUG: Plan is router executable
|
||||||
5
|
5
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- union involving reference table and distributed table subqueries
|
-- union involving reference table and distributed table subqueries
|
||||||
-- is supported with pulling data to coordinator
|
-- is supported with pulling data to coordinator
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
|
@ -1512,7 +1511,7 @@ ORDER BY 1 LIMIT 3;
|
||||||
|
|
||||||
-- should be able to pushdown since one of the subqueries has distinct on reference tables
|
-- should be able to pushdown since one of the subqueries has distinct on reference tables
|
||||||
-- and there is only reference table in that subquery
|
-- and there is only reference table in that subquery
|
||||||
SELECT
|
SELECT
|
||||||
distinct_users, event_type, time
|
distinct_users, event_type, time
|
||||||
FROM
|
FROM
|
||||||
(SELECT user_id, time, event_type FROM events_table) as events_dist INNER JOIN
|
(SELECT user_id, time, event_type FROM events_table) as events_dist INNER JOIN
|
||||||
|
@ -1530,11 +1529,11 @@ OFFSET 0;
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
-- the same query wuth multiple reference tables in the subquery
|
-- the same query wuth multiple reference tables in the subquery
|
||||||
SELECT
|
SELECT
|
||||||
distinct_users, event_type, time
|
distinct_users, event_type, time
|
||||||
FROM
|
FROM
|
||||||
(SELECT user_id, time, event_type FROM events_table) as events_dist INNER JOIN
|
(SELECT user_id, time, event_type FROM events_table) as events_dist INNER JOIN
|
||||||
(SELECT DISTINCT users_reference_table.user_id as distinct_users FROM users_reference_table, events_reference_table
|
(SELECT DISTINCT users_reference_table.user_id as distinct_users FROM users_reference_table, events_reference_table
|
||||||
WHERE events_reference_table.user_id = users_reference_table.user_id AND events_reference_table.event_type IN (1,2,3,4)) users_ref
|
WHERE events_reference_table.user_id = users_reference_table.user_id AND events_reference_table.event_type IN (1,2,3,4)) users_ref
|
||||||
ON (events_dist.user_id = users_ref.distinct_users)
|
ON (events_dist.user_id = users_ref.distinct_users)
|
||||||
ORDER BY time DESC
|
ORDER BY time DESC
|
||||||
|
@ -1550,7 +1549,7 @@ OFFSET 0;
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
-- similar query as the above, but with group bys
|
-- similar query as the above, but with group bys
|
||||||
SELECT
|
SELECT
|
||||||
distinct_users, event_type, time
|
distinct_users, event_type, time
|
||||||
FROM
|
FROM
|
||||||
(SELECT user_id, time, event_type FROM events_table) as events_dist INNER JOIN
|
(SELECT user_id, time, event_type FROM events_table) as events_dist INNER JOIN
|
||||||
|
@ -1587,7 +1586,7 @@ SELECT * FROM
|
||||||
---------
|
---------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- similiar to the above examples, this time there is a subquery
|
-- similiar to the above examples, this time there is a subquery
|
||||||
-- whose output is not in the DISTINCT clause
|
-- whose output is not in the DISTINCT clause
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
(
|
(
|
||||||
|
@ -1608,8 +1607,8 @@ ORDER BY 1;
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
(
|
(
|
||||||
SELECT DISTINCT users_reference_table.user_id, us_events.user_id FROM users_reference_table, (SELECT user_id, random() FROM events_table WHERE event_type IN (2,3)) as us_events WHERE users_reference_table.user_id = us_events.user_id
|
SELECT DISTINCT users_reference_table.user_id, us_events.user_id FROM users_reference_table, (SELECT user_id, random() FROM events_table WHERE event_type IN (2,3)) as us_events WHERE users_reference_table.user_id = us_events.user_id
|
||||||
) as foo
|
) as foo
|
||||||
ORDER BY 1 DESC
|
ORDER BY 1 DESC
|
||||||
LIMIT 4;
|
LIMIT 4;
|
||||||
user_id | user_id
|
user_id | user_id
|
||||||
---------+---------
|
---------+---------
|
||||||
|
@ -1624,15 +1623,15 @@ LIMIT 4;
|
||||||
-- is disabled
|
-- is disabled
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT users_reference_table.user_id, us_events.value_4
|
DISTINCT users_reference_table.user_id, us_events.value_4
|
||||||
FROM
|
FROM
|
||||||
users_reference_table,
|
users_reference_table,
|
||||||
(SELECT user_id, value_4, random() FROM events_table WHERE event_type IN (2,3)) as us_events
|
(SELECT user_id, value_4, random() FROM events_table WHERE event_type IN (2,3)) as us_events
|
||||||
WHERE
|
WHERE
|
||||||
users_reference_table.user_id = us_events.user_id
|
users_reference_table.user_id = us_events.user_id
|
||||||
) as foo
|
) as foo
|
||||||
ORDER BY 1 DESC
|
ORDER BY 1 DESC
|
||||||
LIMIT 4;
|
LIMIT 4;
|
||||||
user_id | value_4
|
user_id | value_4
|
||||||
---------+---------
|
---------+---------
|
||||||
|
@ -1644,7 +1643,6 @@ LIMIT 4;
|
||||||
|
|
||||||
-- test the read_intermediate_result() for GROUP BYs
|
-- test the read_intermediate_result() for GROUP BYs
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
SELECT broadcast_intermediate_result('squares', 'SELECT s, s*s FROM generate_series(1,200) s');
|
SELECT broadcast_intermediate_result('squares', 'SELECT s, s*s FROM generate_series(1,200) s');
|
||||||
broadcast_intermediate_result
|
broadcast_intermediate_result
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
@ -1652,15 +1650,15 @@ SELECT broadcast_intermediate_result('squares', 'SELECT s, s*s FROM generate_ser
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- single appereance of read_intermediate_result
|
-- single appereance of read_intermediate_result
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT user_id
|
DISTINCT user_id
|
||||||
FROM
|
FROM
|
||||||
users_table
|
users_table
|
||||||
JOIN
|
JOIN
|
||||||
(SELECT
|
(SELECT
|
||||||
max(res.val) as mx
|
max(res.val) as mx
|
||||||
FROM
|
FROM
|
||||||
read_intermediate_result('squares', 'binary') AS res (val int, val_square int)
|
read_intermediate_result('squares', 'binary') AS res (val int, val_square int)
|
||||||
GROUP BY res.val_square) squares
|
GROUP BY res.val_square) squares
|
||||||
ON (mx = user_id)
|
ON (mx = user_id)
|
||||||
ORDER BY 1
|
ORDER BY 1
|
||||||
|
@ -1692,15 +1690,15 @@ LIMIT 5;
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
-- single appereance of read_intermediate_result but inside a subquery
|
-- single appereance of read_intermediate_result but inside a subquery
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT user_id
|
DISTINCT user_id
|
||||||
FROM
|
FROM
|
||||||
users_table
|
users_table
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT *,random() FROM (SELECT
|
SELECT *,random() FROM (SELECT
|
||||||
max(res.val) as mx
|
max(res.val) as mx
|
||||||
FROM
|
FROM
|
||||||
(SELECT val, val_square FROM read_intermediate_result('squares', 'binary') AS res (val int, val_square int)) res
|
(SELECT val, val_square FROM read_intermediate_result('squares', 'binary') AS res (val int, val_square int)) res
|
||||||
GROUP BY res.val_square) foo)
|
GROUP BY res.val_square) foo)
|
||||||
squares
|
squares
|
||||||
ON (mx = user_id)
|
ON (mx = user_id)
|
||||||
|
@ -1716,16 +1714,16 @@ LIMIT 5;
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
-- multiple read_intermediate_results in the same subquery is OK
|
-- multiple read_intermediate_results in the same subquery is OK
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT user_id
|
DISTINCT user_id
|
||||||
FROM
|
FROM
|
||||||
users_table
|
users_table
|
||||||
JOIN
|
JOIN
|
||||||
(SELECT
|
(SELECT
|
||||||
max(res.val) as mx
|
max(res.val) as mx
|
||||||
FROM
|
FROM
|
||||||
read_intermediate_result('squares', 'binary') AS res (val int, val_square int),
|
read_intermediate_result('squares', 'binary') AS res (val int, val_square int),
|
||||||
read_intermediate_result('squares', 'binary') AS res2 (val int, val_square int)
|
read_intermediate_result('squares', 'binary') AS res2 (val int, val_square int)
|
||||||
WHERE res.val = res2.val_square
|
WHERE res.val = res2.val_square
|
||||||
GROUP BY res2.val_square) squares
|
GROUP BY res2.val_square) squares
|
||||||
ON (mx = user_id)
|
ON (mx = user_id)
|
||||||
|
@ -1738,19 +1736,19 @@ LIMIT 5;
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
-- mixed recurring tuples should be supported
|
-- mixed recurring tuples should be supported
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT user_id
|
DISTINCT user_id
|
||||||
FROM
|
FROM
|
||||||
users_table
|
users_table
|
||||||
JOIN
|
JOIN
|
||||||
(SELECT
|
(SELECT
|
||||||
max(res.val) as mx
|
max(res.val) as mx
|
||||||
FROM
|
FROM
|
||||||
read_intermediate_result('squares', 'binary') AS res (val int, val_square int),
|
read_intermediate_result('squares', 'binary') AS res (val int, val_square int),
|
||||||
generate_series(0, 10) i
|
generate_series(0, 10) i
|
||||||
WHERE
|
WHERE
|
||||||
res.val = i
|
res.val = i
|
||||||
GROUP BY
|
GROUP BY
|
||||||
i) squares
|
i) squares
|
||||||
ON (mx = user_id)
|
ON (mx = user_id)
|
||||||
ORDER BY 1
|
ORDER BY 1
|
||||||
|
@ -1766,16 +1764,16 @@ LIMIT 5;
|
||||||
|
|
||||||
-- should recursively plan since
|
-- should recursively plan since
|
||||||
-- there are no columns on the GROUP BY from the distributed table
|
-- there are no columns on the GROUP BY from the distributed table
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT user_id
|
DISTINCT user_id
|
||||||
FROM
|
FROM
|
||||||
users_reference_table
|
users_reference_table
|
||||||
JOIN
|
JOIN
|
||||||
(SELECT
|
(SELECT
|
||||||
max(val_square) as mx
|
max(val_square) as mx
|
||||||
FROM
|
FROM
|
||||||
read_intermediate_result('squares', 'binary') AS res (val int, val_square int), events_table
|
read_intermediate_result('squares', 'binary') AS res (val int, val_square int), events_table
|
||||||
WHERE
|
WHERE
|
||||||
events_table.user_id = res.val GROUP BY res.val) squares
|
events_table.user_id = res.val GROUP BY res.val) squares
|
||||||
ON (mx = user_id)
|
ON (mx = user_id)
|
||||||
ORDER BY 1
|
ORDER BY 1
|
||||||
|
@ -1788,14 +1786,14 @@ LIMIT 5;
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- should work since we're using an immutable function as recurring tuple
|
-- should work since we're using an immutable function as recurring tuple
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT user_id
|
DISTINCT user_id
|
||||||
FROM
|
FROM
|
||||||
users_table
|
users_table
|
||||||
JOIN
|
JOIN
|
||||||
(SELECT
|
(SELECT
|
||||||
max(i+5)as mx
|
max(i+5)as mx
|
||||||
FROM
|
FROM
|
||||||
generate_series(0, 10) as i GROUP BY i) squares
|
generate_series(0, 10) as i GROUP BY i) squares
|
||||||
ON (mx = user_id)
|
ON (mx = user_id)
|
||||||
ORDER BY 1
|
ORDER BY 1
|
||||||
|
@ -1806,20 +1804,20 @@ LIMIT 5;
|
||||||
6
|
6
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
-- should recursively plan since we're
|
-- should recursively plan since we're
|
||||||
-- using an immutable function as recurring tuple
|
-- using an immutable function as recurring tuple
|
||||||
-- along with a distributed table, where GROUP BY is
|
-- along with a distributed table, where GROUP BY is
|
||||||
-- on the recurring tuple
|
-- on the recurring tuple
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT user_id
|
DISTINCT user_id
|
||||||
FROM
|
FROM
|
||||||
users_reference_table
|
users_reference_table
|
||||||
JOIN
|
JOIN
|
||||||
(SELECT
|
(SELECT
|
||||||
max(i+5)as mx
|
max(i+5)as mx
|
||||||
FROM
|
FROM
|
||||||
generate_series(0, 10) as i, events_table
|
generate_series(0, 10) as i, events_table
|
||||||
WHERE
|
WHERE
|
||||||
events_table.user_id = i GROUP BY i) squares
|
events_table.user_id = i GROUP BY i) squares
|
||||||
ON (mx = user_id)
|
ON (mx = user_id)
|
||||||
ORDER BY 1
|
ORDER BY 1
|
||||||
|
|
|
@ -228,7 +228,6 @@ ORDER BY shardid;
|
||||||
1360009 | t
|
1360009 | t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
DROP TABLE upgrade_reference_table_append;
|
DROP TABLE upgrade_reference_table_append;
|
||||||
-- test valid cases, shard exists at one worker
|
-- test valid cases, shard exists at one worker
|
||||||
CREATE TABLE upgrade_reference_table_one_worker(column1 int);
|
CREATE TABLE upgrade_reference_table_one_worker(column1 int);
|
||||||
|
@ -341,7 +340,6 @@ ORDER BY shardid;
|
||||||
1360010 | t
|
1360010 | t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
DROP TABLE upgrade_reference_table_one_worker;
|
DROP TABLE upgrade_reference_table_one_worker;
|
||||||
-- test valid cases, shard exists at both workers but one is unhealthy
|
-- test valid cases, shard exists at both workers but one is unhealthy
|
||||||
SET citus.shard_replication_factor TO 2;
|
SET citus.shard_replication_factor TO 2;
|
||||||
|
@ -458,7 +456,6 @@ ORDER BY shardid;
|
||||||
1360011 | t
|
1360011 | t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
DROP TABLE upgrade_reference_table_one_unhealthy;
|
DROP TABLE upgrade_reference_table_one_unhealthy;
|
||||||
-- test valid cases, shard exists at both workers and both are healthy
|
-- test valid cases, shard exists at both workers and both are healthy
|
||||||
CREATE TABLE upgrade_reference_table_both_healthy(column1 int);
|
CREATE TABLE upgrade_reference_table_both_healthy(column1 int);
|
||||||
|
@ -570,7 +567,6 @@ ORDER BY shardid;
|
||||||
1360012 | t
|
1360012 | t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
DROP TABLE upgrade_reference_table_both_healthy;
|
DROP TABLE upgrade_reference_table_both_healthy;
|
||||||
-- test valid cases, do it in transaction and ROLLBACK
|
-- test valid cases, do it in transaction and ROLLBACK
|
||||||
SET citus.shard_replication_factor TO 1;
|
SET citus.shard_replication_factor TO 1;
|
||||||
|
@ -686,7 +682,6 @@ ORDER BY shardid;
|
||||||
1360013 | f
|
1360013 | f
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
DROP TABLE upgrade_reference_table_transaction_rollback;
|
DROP TABLE upgrade_reference_table_transaction_rollback;
|
||||||
-- test valid cases, do it in transaction and COMMIT
|
-- test valid cases, do it in transaction and COMMIT
|
||||||
SET citus.shard_replication_factor TO 1;
|
SET citus.shard_replication_factor TO 1;
|
||||||
|
@ -872,11 +867,9 @@ ORDER BY shardid;
|
||||||
1360015
|
1360015
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
SELECT upgrade_to_reference_table('upgrade_reference_table_mx');
|
SELECT upgrade_to_reference_table('upgrade_reference_table_mx');
|
||||||
ERROR: cannot upgrade to reference table
|
ERROR: cannot upgrade to reference table
|
||||||
DETAIL: Upgrade is only supported for statement-based replicated tables but "upgrade_reference_table_mx" is streaming replicated
|
DETAIL: Upgrade is only supported for statement-based replicated tables but "upgrade_reference_table_mx" is streaming replicated
|
||||||
|
|
||||||
-- situation after upgrade_reference_table
|
-- situation after upgrade_reference_table
|
||||||
SELECT
|
SELECT
|
||||||
partmethod, (partkey IS NULL) as partkeyisnull, colocationid, repmodel
|
partmethod, (partkey IS NULL) as partkeyisnull, colocationid, repmodel
|
||||||
|
@ -937,10 +930,9 @@ SELECT create_distributed_table('upgrade_reference_table_mx', 'column1');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
UPDATE pg_dist_shard_placement SET shardstate = 3
|
UPDATE pg_dist_shard_placement SET shardstate = 3
|
||||||
WHERE nodeport = :worker_2_port AND
|
WHERE nodeport = :worker_2_port AND
|
||||||
shardid IN (SELECT shardid FROM pg_dist_shard WHERE logicalrelid='upgrade_reference_table_mx'::regclass);
|
shardid IN (SELECT shardid FROM pg_dist_shard WHERE logicalrelid='upgrade_reference_table_mx'::regclass);
|
||||||
|
|
||||||
SELECT start_metadata_sync_to_node('localhost', :worker_1_port);
|
SELECT start_metadata_sync_to_node('localhost', :worker_1_port);
|
||||||
start_metadata_sync_to_node
|
start_metadata_sync_to_node
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
@ -995,7 +987,6 @@ ORDER BY shardid;
|
||||||
1360016
|
1360016
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
SET client_min_messages TO WARNING;
|
SET client_min_messages TO WARNING;
|
||||||
SELECT upgrade_to_reference_table('upgrade_reference_table_mx');
|
SELECT upgrade_to_reference_table('upgrade_reference_table_mx');
|
||||||
upgrade_to_reference_table
|
upgrade_to_reference_table
|
||||||
|
@ -1003,7 +994,6 @@ SELECT upgrade_to_reference_table('upgrade_reference_table_mx');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- situation after upgrade_reference_table
|
-- situation after upgrade_reference_table
|
||||||
SELECT
|
SELECT
|
||||||
partmethod, (partkey IS NULL) as partkeyisnull, colocationid, repmodel
|
partmethod, (partkey IS NULL) as partkeyisnull, colocationid, repmodel
|
||||||
|
@ -1052,7 +1042,6 @@ ORDER BY shardid;
|
||||||
1360016 | t
|
1360016 | t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- situation on metadata worker
|
-- situation on metadata worker
|
||||||
\c - - - :worker_1_port
|
\c - - - :worker_1_port
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -1091,7 +1080,6 @@ ORDER BY shardid;
|
||||||
1360016 | t
|
1360016 | t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
DROP TABLE upgrade_reference_table_mx;
|
DROP TABLE upgrade_reference_table_mx;
|
||||||
SELECT stop_metadata_sync_to_node('localhost', :worker_1_port);
|
SELECT stop_metadata_sync_to_node('localhost', :worker_1_port);
|
||||||
|
|
|
@ -51,7 +51,6 @@ BEGIN;
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- we can even run queries (sequentially) over the distributed table
|
-- we can even run queries (sequentially) over the distributed table
|
||||||
SELECT * FROM dist_table;
|
SELECT * FROM dist_table;
|
||||||
key | value
|
key | value
|
||||||
|
@ -103,7 +102,7 @@ SELECT run_command_on_workers($$SELECT extversion FROM pg_extension WHERE extnam
|
||||||
|
|
||||||
-- now, update to a newer version
|
-- now, update to a newer version
|
||||||
ALTER EXTENSION isn UPDATE TO '1.2';
|
ALTER EXTENSION isn UPDATE TO '1.2';
|
||||||
-- show that ALTER EXTENSION is propagated
|
-- show that ALTER EXTENSION is propagated
|
||||||
SELECT run_command_on_workers($$SELECT extversion FROM pg_extension WHERE extname = 'isn'$$);
|
SELECT run_command_on_workers($$SELECT extversion FROM pg_extension WHERE extname = 'isn'$$);
|
||||||
run_command_on_workers
|
run_command_on_workers
|
||||||
-------------------------
|
-------------------------
|
||||||
|
@ -145,8 +144,8 @@ DROP EXTENSION isn CASCADE;
|
||||||
-- restore client_min_messages after DROP EXTENSION
|
-- restore client_min_messages after DROP EXTENSION
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
-- now make sure that the reference tables depending on an extension can be succesfully created.
|
-- now make sure that the reference tables depending on an extension can be succesfully created.
|
||||||
-- we should also ensure that we replicate this reference table (and hence the extension)
|
-- we should also ensure that we replicate this reference table (and hence the extension)
|
||||||
-- to new nodes after calling master_activate_node.
|
-- to new nodes after calling master_activate_node.
|
||||||
-- now, first drop seg and existing objects before next test
|
-- now, first drop seg and existing objects before next test
|
||||||
SET client_min_messages TO WARNING;
|
SET client_min_messages TO WARNING;
|
||||||
DROP EXTENSION seg CASCADE;
|
DROP EXTENSION seg CASCADE;
|
||||||
|
@ -207,7 +206,7 @@ SELECT run_command_on_workers($$SELECT extversion FROM pg_extension WHERE extnam
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
-- and similarly check for the reference table
|
-- and similarly check for the reference table
|
||||||
select count(*) from pg_dist_partition where partmethod='n' and logicalrelid='ref_table_2'::regclass;
|
select count(*) from pg_dist_partition where partmethod='n' and logicalrelid='ref_table_2'::regclass;
|
||||||
count
|
count
|
||||||
-------
|
-------
|
||||||
1
|
1
|
||||||
|
@ -241,7 +240,7 @@ SELECT run_command_on_workers($$SELECT count(*) FROM pg_extension WHERE extname
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
-- give a notice for the following commands saying that it is not
|
-- give a notice for the following commands saying that it is not
|
||||||
-- propagated to the workers. the user should run it manually on the workers
|
-- propagated to the workers. the user should run it manually on the workers
|
||||||
CREATE TABLE t1 (A int);
|
CREATE TABLE t1 (A int);
|
||||||
CREATE VIEW v1 AS select * from t1;
|
CREATE VIEW v1 AS select * from t1;
|
||||||
ALTER EXTENSION seg ADD VIEW v1;
|
ALTER EXTENSION seg ADD VIEW v1;
|
||||||
|
@ -346,8 +345,8 @@ BEGIN;
|
||||||
SET citus.shard_replication_factor TO 1;
|
SET citus.shard_replication_factor TO 1;
|
||||||
CREATE EXTENSION seg;
|
CREATE EXTENSION seg;
|
||||||
CREATE EXTENSION isn;
|
CREATE EXTENSION isn;
|
||||||
CREATE TYPE test_type AS (a int, b seg);
|
CREATE TYPE test_type AS (a int, b seg);
|
||||||
CREATE TYPE test_type_2 AS (a int, b test_type);
|
CREATE TYPE test_type_2 AS (a int, b test_type);
|
||||||
CREATE TABLE t2 (a int, b test_type_2, c issn);
|
CREATE TABLE t2 (a int, b test_type_2, c issn);
|
||||||
SELECT create_distributed_table('t2', 'a');
|
SELECT create_distributed_table('t2', 'a');
|
||||||
create_distributed_table
|
create_distributed_table
|
||||||
|
@ -355,8 +354,7 @@ BEGIN;
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
CREATE TYPE test_type_3 AS (a int, b test_type, c issn);
|
||||||
CREATE TYPE test_type_3 AS (a int, b test_type, c issn);
|
|
||||||
CREATE TABLE t3 (a int, b test_type_3);
|
CREATE TABLE t3 (a int, b test_type_3);
|
||||||
SELECT create_reference_table('t3');
|
SELECT create_reference_table('t3');
|
||||||
create_reference_table
|
create_reference_table
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
--
|
--
|
||||||
-- Tests sequential and parallel DDL command execution
|
-- Tests sequential and parallel DDL command execution
|
||||||
-- in combination with 1PC and 2PC
|
-- in combination with 1PC and 2PC
|
||||||
-- Note: this test should not be executed in parallel with
|
-- Note: this test should not be executed in parallel with
|
||||||
-- other tests since we're relying on disabling 2PC recovery
|
-- other tests since we're relying on disabling 2PC recovery
|
||||||
--
|
--
|
||||||
-- We're also setting force_max_query_parallelization throughout
|
-- We're also setting force_max_query_parallelization throughout
|
||||||
-- the tests because the test file has the assumption that
|
-- the tests because the test file has the assumption that
|
||||||
|
@ -29,7 +29,7 @@ $$
|
||||||
LANGUAGE 'plpgsql' IMMUTABLE;
|
LANGUAGE 'plpgsql' IMMUTABLE;
|
||||||
-- this function simply checks the equality of the number of transactions in the
|
-- this function simply checks the equality of the number of transactions in the
|
||||||
-- pg_dist_transaction and number of shard placements for a distributed table
|
-- pg_dist_transaction and number of shard placements for a distributed table
|
||||||
-- The function is useful to ensure that a single connection is opened per
|
-- The function is useful to ensure that a single connection is opened per
|
||||||
-- shard placement in a distributed transaction
|
-- shard placement in a distributed transaction
|
||||||
CREATE OR REPLACE FUNCTION distributed_2PCs_are_equal_to_placement_count()
|
CREATE OR REPLACE FUNCTION distributed_2PCs_are_equal_to_placement_count()
|
||||||
RETURNS bool AS
|
RETURNS bool AS
|
||||||
|
@ -184,7 +184,7 @@ SELECT distributed_2PCs_are_equal_to_worker_count();
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- tables with replication factor > 1 should also obey
|
-- tables with replication factor > 1 should also obey
|
||||||
-- both multi_shard_commit_protocol and multi_shard_modify_mode
|
-- both multi_shard_commit_protocol and multi_shard_modify_mode
|
||||||
SET citus.shard_replication_factor TO 2;
|
SET citus.shard_replication_factor TO 2;
|
||||||
CREATE TABLE test_table_rep_2 (a int);
|
CREATE TABLE test_table_rep_2 (a int);
|
||||||
|
@ -194,7 +194,6 @@ SELECT create_distributed_table('test_table_rep_2', 'a');
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
|
||||||
-- 1PC should never use 2PC with rep > 1
|
-- 1PC should never use 2PC with rep > 1
|
||||||
SET citus.multi_shard_commit_protocol TO '1pc';
|
SET citus.multi_shard_commit_protocol TO '1pc';
|
||||||
SET citus.multi_shard_modify_mode TO 'sequential';
|
SET citus.multi_shard_modify_mode TO 'sequential';
|
||||||
|
|
|
@ -26,19 +26,19 @@ WITH cte AS (
|
||||||
)
|
)
|
||||||
SELECT dist_cte.user_id FROM local_cte JOIN dist_cte ON dist_cte.user_id=local_cte.user_id
|
SELECT dist_cte.user_id FROM local_cte JOIN dist_cte ON dist_cte.user_id=local_cte.user_id
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
count(*)
|
count(*)
|
||||||
FROM
|
FROM
|
||||||
cte,
|
cte,
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT users_table.user_id
|
DISTINCT users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.user_id AND
|
users_table.user_id = events_table.user_id AND
|
||||||
event_type IN (1,2,3,4)
|
event_type IN (1,2,3,4)
|
||||||
ORDER BY 1 DESC LIMIT 5
|
ORDER BY 1 DESC LIMIT 5
|
||||||
) as foo
|
) as foo
|
||||||
WHERE foo.user_id = cte.user_id;
|
WHERE foo.user_id = cte.user_id;
|
||||||
DEBUG: generating subplan 3_1 for CTE cte: WITH local_cte AS (SELECT users_table_local.user_id, users_table_local."time", users_table_local.value_1, users_table_local.value_2, users_table_local.value_3, users_table_local.value_4 FROM subquery_and_ctes.users_table_local), dist_cte AS (SELECT events_table.user_id FROM subquery_and_ctes.events_table) SELECT dist_cte.user_id FROM (local_cte JOIN dist_cte ON ((dist_cte.user_id OPERATOR(pg_catalog.=) local_cte.user_id)))
|
DEBUG: generating subplan 3_1 for CTE cte: WITH local_cte AS (SELECT users_table_local.user_id, users_table_local."time", users_table_local.value_1, users_table_local.value_2, users_table_local.value_3, users_table_local.value_4 FROM subquery_and_ctes.users_table_local), dist_cte AS (SELECT events_table.user_id FROM subquery_and_ctes.events_table) SELECT dist_cte.user_id FROM (local_cte JOIN dist_cte ON ((dist_cte.user_id OPERATOR(pg_catalog.=) local_cte.user_id)))
|
||||||
DEBUG: generating subplan 4_1 for CTE local_cte: SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM subquery_and_ctes.users_table_local
|
DEBUG: generating subplan 4_1 for CTE local_cte: SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM subquery_and_ctes.users_table_local
|
||||||
|
@ -125,8 +125,8 @@ FROM cte1 WHERE dt.id = 1;
|
||||||
DEBUG: generating subplan 16_1 for CTE cte1: SELECT id, value FROM subquery_and_ctes.func() func(id, value)
|
DEBUG: generating subplan 16_1 for CTE cte1: SELECT id, value FROM subquery_and_ctes.func() func(id, value)
|
||||||
DEBUG: Plan 16 query after replacing subqueries and CTEs: UPDATE subquery_and_ctes.dist_table dt SET value = cte1.value FROM (SELECT intermediate_result.id, intermediate_result.value FROM read_intermediate_result('16_1'::text, 'binary'::citus_copy_format) intermediate_result(id integer, value integer)) cte1 WHERE (dt.id OPERATOR(pg_catalog.=) 1)
|
DEBUG: Plan 16 query after replacing subqueries and CTEs: UPDATE subquery_and_ctes.dist_table dt SET value = cte1.value FROM (SELECT intermediate_result.id, intermediate_result.value FROM read_intermediate_result('16_1'::text, 'binary'::citus_copy_format) intermediate_result(id integer, value integer)) cte1 WHERE (dt.id OPERATOR(pg_catalog.=) 1)
|
||||||
-- CTEs are recursively planned, and subquery foo is also recursively planned
|
-- CTEs are recursively planned, and subquery foo is also recursively planned
|
||||||
-- final plan becomes a real-time plan since we also have events_table in the
|
-- final plan becomes a real-time plan since we also have events_table in the
|
||||||
-- range table entries
|
-- range table entries
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
WITH local_cte AS (
|
WITH local_cte AS (
|
||||||
SELECT * FROM users_table_local
|
SELECT * FROM users_table_local
|
||||||
|
@ -136,16 +136,16 @@ WITH cte AS (
|
||||||
)
|
)
|
||||||
SELECT dist_cte.user_id FROM local_cte JOIN dist_cte ON dist_cte.user_id=local_cte.user_id
|
SELECT dist_cte.user_id FROM local_cte JOIN dist_cte ON dist_cte.user_id=local_cte.user_id
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
count(*)
|
count(*)
|
||||||
FROM
|
FROM
|
||||||
cte,
|
cte,
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT users_table.user_id
|
DISTINCT users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.user_id AND
|
users_table.user_id = events_table.user_id AND
|
||||||
event_type IN (1,2,3,4)
|
event_type IN (1,2,3,4)
|
||||||
ORDER BY 1 DESC LIMIT 5
|
ORDER BY 1 DESC LIMIT 5
|
||||||
) as foo, events_table
|
) as foo, events_table
|
||||||
|
@ -163,7 +163,7 @@ DEBUG: Plan 17 query after replacing subqueries and CTEs: SELECT count(*) AS co
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- CTEs are replaced and subquery in WHERE is also replaced
|
-- CTEs are replaced and subquery in WHERE is also replaced
|
||||||
-- but the query is still real-time query since users_table is in the
|
-- but the query is still real-time query since users_table is in the
|
||||||
-- range table list
|
-- range table list
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
WITH local_cte AS (
|
WITH local_cte AS (
|
||||||
|
@ -176,7 +176,7 @@ WITH cte AS (
|
||||||
)
|
)
|
||||||
SELECT DISTINCT cte.user_id
|
SELECT DISTINCT cte.user_id
|
||||||
FROM users_table, cte
|
FROM users_table, cte
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = cte.user_id AND
|
users_table.user_id = cte.user_id AND
|
||||||
users_table.user_id IN (SELECT DISTINCT value_2 FROM users_table WHERE value_1 >= 1 AND value_1 <= 20 ORDER BY 1 LIMIT 5)
|
users_table.user_id IN (SELECT DISTINCT value_2 FROM users_table WHERE value_1 >= 1 AND value_1 <= 20 ORDER BY 1 LIMIT 5)
|
||||||
ORDER BY 1 DESC;
|
ORDER BY 1 DESC;
|
||||||
|
@ -208,7 +208,7 @@ WITH cte AS (
|
||||||
)
|
)
|
||||||
SELECT DISTINCT cte.user_id
|
SELECT DISTINCT cte.user_id
|
||||||
FROM cte
|
FROM cte
|
||||||
WHERE
|
WHERE
|
||||||
cte.user_id IN (SELECT DISTINCT user_id FROM users_table WHERE value_1 >= 1 AND value_1 <= 20)
|
cte.user_id IN (SELECT DISTINCT user_id FROM users_table WHERE value_1 >= 1 AND value_1 <= 20)
|
||||||
ORDER BY 1 DESC;
|
ORDER BY 1 DESC;
|
||||||
DEBUG: generating subplan 25_1 for CTE cte: WITH local_cte AS (SELECT users_table_local.user_id, users_table_local."time", users_table_local.value_1, users_table_local.value_2, users_table_local.value_3, users_table_local.value_4 FROM subquery_and_ctes.users_table_local), dist_cte AS (SELECT events_table.user_id FROM subquery_and_ctes.events_table) SELECT dist_cte.user_id FROM (local_cte JOIN dist_cte ON ((dist_cte.user_id OPERATOR(pg_catalog.=) local_cte.user_id)))
|
DEBUG: generating subplan 25_1 for CTE cte: WITH local_cte AS (SELECT users_table_local.user_id, users_table_local."time", users_table_local.value_1, users_table_local.value_2, users_table_local.value_3, users_table_local.value_4 FROM subquery_and_ctes.users_table_local), dist_cte AS (SELECT events_table.user_id FROM subquery_and_ctes.events_table) SELECT dist_cte.user_id FROM (local_cte JOIN dist_cte ON ((dist_cte.user_id OPERATOR(pg_catalog.=) local_cte.user_id)))
|
||||||
|
@ -234,12 +234,12 @@ SELECT
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT users_table.user_id
|
DISTINCT users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.user_id AND
|
users_table.user_id = events_table.user_id AND
|
||||||
event_type IN (1,2,3,4)
|
event_type IN (1,2,3,4)
|
||||||
) SELECT * FROM cte ORDER BY 1 DESC
|
) SELECT * FROM cte ORDER BY 1 DESC
|
||||||
) as foo
|
) as foo
|
||||||
|
@ -263,25 +263,24 @@ SELECT
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT users_table.user_id
|
DISTINCT users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.user_id AND
|
users_table.user_id = events_table.user_id AND
|
||||||
event_type IN (1,2,3,4)
|
event_type IN (1,2,3,4)
|
||||||
) SELECT * FROM cte ORDER BY 1 DESC
|
) SELECT * FROM cte ORDER BY 1 DESC
|
||||||
) as foo,
|
) as foo,
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT users_table.user_id
|
DISTINCT users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.user_id AND
|
users_table.user_id = events_table.user_id AND
|
||||||
event_type IN (1,2,3,4)
|
event_type IN (1,2,3,4)
|
||||||
|
) as bar
|
||||||
) as bar
|
|
||||||
WHERE foo.user_id = bar.user_id
|
WHERE foo.user_id = bar.user_id
|
||||||
ORDER BY 1 DESC;
|
ORDER BY 1 DESC;
|
||||||
DEBUG: generating subplan 31_1 for CTE cte: SELECT DISTINCT users_table.user_id FROM subquery_and_ctes.users_table, subquery_and_ctes.events_table WHERE ((users_table.user_id OPERATOR(pg_catalog.=) events_table.user_id) AND (events_table.event_type OPERATOR(pg_catalog.=) ANY (ARRAY[1, 2, 3, 4])))
|
DEBUG: generating subplan 31_1 for CTE cte: SELECT DISTINCT users_table.user_id FROM subquery_and_ctes.users_table, subquery_and_ctes.events_table WHERE ((users_table.user_id OPERATOR(pg_catalog.=) events_table.user_id) AND (events_table.event_type OPERATOR(pg_catalog.=) ANY (ARRAY[1, 2, 3, 4])))
|
||||||
|
@ -303,38 +302,37 @@ SELECT
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT users_table.user_id
|
DISTINCT users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.user_id AND
|
users_table.user_id = events_table.user_id AND
|
||||||
event_type IN (1,2,3,4)
|
event_type IN (1,2,3,4)
|
||||||
) SELECT * FROM cte ORDER BY 1 DESC
|
) SELECT * FROM cte ORDER BY 1 DESC
|
||||||
) as foo,
|
) as foo,
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
users_table.user_id, some_events.event_type
|
users_table.user_id, some_events.event_type
|
||||||
FROM
|
FROM
|
||||||
users_table,
|
users_table,
|
||||||
(
|
(
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
SELECT
|
SELECT
|
||||||
event_type, users_table.user_id
|
event_type, users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.user_id AND
|
users_table.user_id = events_table.user_id AND
|
||||||
value_1 IN (1,2)
|
value_1 IN (1,2)
|
||||||
) SELECT * FROM cte ORDER BY 1 DESC
|
) SELECT * FROM cte ORDER BY 1 DESC
|
||||||
) as some_events
|
) as some_events
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = some_events.user_id AND
|
users_table.user_id = some_events.user_id AND
|
||||||
event_type IN (1,2,3,4)
|
event_type IN (1,2,3,4)
|
||||||
ORDER BY 2,1
|
ORDER BY 2,1
|
||||||
LIMIT 2
|
LIMIT 2
|
||||||
|
) as bar
|
||||||
) as bar
|
|
||||||
WHERE foo.user_id = bar.user_id
|
WHERE foo.user_id = bar.user_id
|
||||||
ORDER BY 1 DESC LIMIT 5;
|
ORDER BY 1 DESC LIMIT 5;
|
||||||
DEBUG: generating subplan 33_1 for CTE cte: SELECT DISTINCT users_table.user_id FROM subquery_and_ctes.users_table, subquery_and_ctes.events_table WHERE ((users_table.user_id OPERATOR(pg_catalog.=) events_table.user_id) AND (events_table.event_type OPERATOR(pg_catalog.=) ANY (ARRAY[1, 2, 3, 4])))
|
DEBUG: generating subplan 33_1 for CTE cte: SELECT DISTINCT users_table.user_id FROM subquery_and_ctes.users_table, subquery_and_ctes.events_table WHERE ((users_table.user_id OPERATOR(pg_catalog.=) events_table.user_id) AND (events_table.event_type OPERATOR(pg_catalog.=) ANY (ARRAY[1, 2, 3, 4])))
|
||||||
|
@ -347,10 +345,10 @@ DEBUG: Plan 33 query after replacing subqueries and CTEs: SELECT DISTINCT bar.u
|
||||||
1
|
1
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- CTEs on the different parts of the query is replaced
|
-- CTEs on the different parts of the query is replaced
|
||||||
-- and subquery foo is also replaced since it contains
|
-- and subquery foo is also replaced since it contains
|
||||||
-- DISTINCT on a non-partition key
|
-- DISTINCT on a non-partition key
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
(
|
(
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
WITH local_cte AS (
|
WITH local_cte AS (
|
||||||
|
@ -363,16 +361,16 @@ SELECT * FROM
|
||||||
)
|
)
|
||||||
SELECT DISTINCT cte.user_id
|
SELECT DISTINCT cte.user_id
|
||||||
FROM users_table, cte
|
FROM users_table, cte
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = cte.user_id AND
|
users_table.user_id = cte.user_id AND
|
||||||
users_table.user_id IN
|
users_table.user_id IN
|
||||||
(WITH cte_in_where AS (SELECT DISTINCT value_2 FROM users_table WHERE value_1 >= 1 AND value_1 <= 20 ORDER BY 1 LIMIT 5) SELECT * FROM cte_in_where)
|
(WITH cte_in_where AS (SELECT DISTINCT value_2 FROM users_table WHERE value_1 >= 1 AND value_1 <= 20 ORDER BY 1 LIMIT 5) SELECT * FROM cte_in_where)
|
||||||
ORDER BY 1 DESC
|
ORDER BY 1 DESC
|
||||||
) as foo,
|
) as foo,
|
||||||
events_table
|
events_table
|
||||||
WHERE
|
WHERE
|
||||||
foo.user_id = events_table.value_2
|
foo.user_id = events_table.value_2
|
||||||
ORDER BY 3 DESC, 2 DESC, 1 DESC
|
ORDER BY 3 DESC, 2 DESC, 1 DESC
|
||||||
LIMIT 5;
|
LIMIT 5;
|
||||||
DEBUG: generating subplan 37_1 for CTE cte: WITH local_cte AS (SELECT users_table_local.user_id, users_table_local."time", users_table_local.value_1, users_table_local.value_2, users_table_local.value_3, users_table_local.value_4 FROM subquery_and_ctes.users_table_local), dist_cte AS (SELECT events_table.user_id FROM subquery_and_ctes.events_table) SELECT dist_cte.user_id FROM (local_cte JOIN dist_cte ON ((dist_cte.user_id OPERATOR(pg_catalog.=) local_cte.user_id)))
|
DEBUG: generating subplan 37_1 for CTE cte: WITH local_cte AS (SELECT users_table_local.user_id, users_table_local."time", users_table_local.value_1, users_table_local.value_2, users_table_local.value_3, users_table_local.value_4 FROM subquery_and_ctes.users_table_local), dist_cte AS (SELECT events_table.user_id FROM subquery_and_ctes.events_table) SELECT dist_cte.user_id FROM (local_cte JOIN dist_cte ON ((dist_cte.user_id OPERATOR(pg_catalog.=) local_cte.user_id)))
|
||||||
DEBUG: generating subplan 38_1 for CTE local_cte: SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM subquery_and_ctes.users_table_local
|
DEBUG: generating subplan 38_1 for CTE local_cte: SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM subquery_and_ctes.users_table_local
|
||||||
|
@ -398,30 +396,30 @@ WITH cte AS (
|
||||||
SELECT * FROM users_table_local
|
SELECT * FROM users_table_local
|
||||||
),
|
),
|
||||||
dist_cte AS (
|
dist_cte AS (
|
||||||
SELECT
|
SELECT
|
||||||
user_id
|
user_id
|
||||||
FROM
|
FROM
|
||||||
events_table,
|
events_table,
|
||||||
(SELECT DISTINCT value_2 FROM users_table OFFSET 0) as foo
|
(SELECT DISTINCT value_2 FROM users_table OFFSET 0) as foo
|
||||||
WHERE
|
WHERE
|
||||||
events_table.user_id = foo.value_2 AND
|
events_table.user_id = foo.value_2 AND
|
||||||
events_table.user_id IN (SELECT DISTINCT value_1 FROM users_table ORDER BY 1 LIMIT 3)
|
events_table.user_id IN (SELECT DISTINCT value_1 FROM users_table ORDER BY 1 LIMIT 3)
|
||||||
)
|
)
|
||||||
SELECT dist_cte.user_id FROM local_cte JOIN dist_cte ON dist_cte.user_id=local_cte.user_id
|
SELECT dist_cte.user_id FROM local_cte JOIN dist_cte ON dist_cte.user_id=local_cte.user_id
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
count(*)
|
count(*)
|
||||||
FROM
|
FROM
|
||||||
cte,
|
cte,
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT users_table.user_id
|
DISTINCT users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.user_id AND
|
users_table.user_id = events_table.user_id AND
|
||||||
event_type IN (1,2,3,4)
|
event_type IN (1,2,3,4)
|
||||||
ORDER BY 1 DESC LIMIT 5
|
ORDER BY 1 DESC LIMIT 5
|
||||||
) as foo
|
) as foo
|
||||||
WHERE foo.user_id = cte.user_id;
|
WHERE foo.user_id = cte.user_id;
|
||||||
DEBUG: generating subplan 42_1 for CTE cte: WITH local_cte AS (SELECT users_table_local.user_id, users_table_local."time", users_table_local.value_1, users_table_local.value_2, users_table_local.value_3, users_table_local.value_4 FROM subquery_and_ctes.users_table_local), dist_cte AS (SELECT events_table.user_id FROM subquery_and_ctes.events_table, (SELECT DISTINCT users_table.value_2 FROM subquery_and_ctes.users_table OFFSET 0) foo WHERE ((events_table.user_id OPERATOR(pg_catalog.=) foo.value_2) AND (events_table.user_id OPERATOR(pg_catalog.=) ANY (SELECT DISTINCT users_table.value_1 FROM subquery_and_ctes.users_table ORDER BY users_table.value_1 LIMIT 3)))) SELECT dist_cte.user_id FROM (local_cte JOIN dist_cte ON ((dist_cte.user_id OPERATOR(pg_catalog.=) local_cte.user_id)))
|
DEBUG: generating subplan 42_1 for CTE cte: WITH local_cte AS (SELECT users_table_local.user_id, users_table_local."time", users_table_local.value_1, users_table_local.value_2, users_table_local.value_3, users_table_local.value_4 FROM subquery_and_ctes.users_table_local), dist_cte AS (SELECT events_table.user_id FROM subquery_and_ctes.events_table, (SELECT DISTINCT users_table.value_2 FROM subquery_and_ctes.users_table OFFSET 0) foo WHERE ((events_table.user_id OPERATOR(pg_catalog.=) foo.value_2) AND (events_table.user_id OPERATOR(pg_catalog.=) ANY (SELECT DISTINCT users_table.value_1 FROM subquery_and_ctes.users_table ORDER BY users_table.value_1 LIMIT 3)))) SELECT dist_cte.user_id FROM (local_cte JOIN dist_cte ON ((dist_cte.user_id OPERATOR(pg_catalog.=) local_cte.user_id)))
|
||||||
DEBUG: generating subplan 43_1 for CTE local_cte: SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM subquery_and_ctes.users_table_local
|
DEBUG: generating subplan 43_1 for CTE local_cte: SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM subquery_and_ctes.users_table_local
|
||||||
|
@ -440,41 +438,41 @@ DEBUG: Plan 42 query after replacing subqueries and CTEs: SELECT count(*) AS co
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- the same query, but this time the CTEs also live inside a subquery
|
-- the same query, but this time the CTEs also live inside a subquery
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
WITH local_cte AS (
|
WITH local_cte AS (
|
||||||
SELECT * FROM users_table_local
|
SELECT * FROM users_table_local
|
||||||
),
|
),
|
||||||
dist_cte AS (
|
dist_cte AS (
|
||||||
SELECT
|
SELECT
|
||||||
user_id
|
user_id
|
||||||
FROM
|
FROM
|
||||||
events_table,
|
events_table,
|
||||||
(SELECT DISTINCT value_2 FROM users_table OFFSET 0) as foo
|
(SELECT DISTINCT value_2 FROM users_table OFFSET 0) as foo
|
||||||
WHERE
|
WHERE
|
||||||
events_table.user_id = foo.value_2 AND
|
events_table.user_id = foo.value_2 AND
|
||||||
events_table.user_id IN (SELECT DISTINCT value_1 FROM users_table ORDER BY 1 LIMIT 3)
|
events_table.user_id IN (SELECT DISTINCT value_1 FROM users_table ORDER BY 1 LIMIT 3)
|
||||||
)
|
)
|
||||||
SELECT dist_cte.user_id FROM local_cte JOIN dist_cte ON dist_cte.user_id=local_cte.user_id
|
SELECT dist_cte.user_id FROM local_cte JOIN dist_cte ON dist_cte.user_id=local_cte.user_id
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
count(*) as cnt
|
count(*) as cnt
|
||||||
FROM
|
FROM
|
||||||
cte,
|
cte,
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT users_table.user_id
|
DISTINCT users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.user_id AND
|
users_table.user_id = events_table.user_id AND
|
||||||
event_type IN (1,2,3,4)
|
event_type IN (1,2,3,4)
|
||||||
ORDER BY 1 DESC LIMIT 5
|
ORDER BY 1 DESC LIMIT 5
|
||||||
) as foo
|
) as foo
|
||||||
WHERE foo.user_id = cte.user_id
|
WHERE foo.user_id = cte.user_id
|
||||||
) as foo, users_table WHERE foo.cnt > users_table.value_2
|
) as foo, users_table WHERE foo.cnt > users_table.value_2
|
||||||
ORDER BY 3 DESC, 1 DESC, 2 DESC, 4 DESC
|
ORDER BY 3 DESC, 1 DESC, 2 DESC, 4 DESC
|
||||||
LIMIT 5;
|
LIMIT 5;
|
||||||
DEBUG: generating subplan 48_1 for CTE cte: WITH local_cte AS (SELECT users_table_local.user_id, users_table_local."time", users_table_local.value_1, users_table_local.value_2, users_table_local.value_3, users_table_local.value_4 FROM subquery_and_ctes.users_table_local), dist_cte AS (SELECT events_table.user_id FROM subquery_and_ctes.events_table, (SELECT DISTINCT users_table.value_2 FROM subquery_and_ctes.users_table OFFSET 0) foo WHERE ((events_table.user_id OPERATOR(pg_catalog.=) foo.value_2) AND (events_table.user_id OPERATOR(pg_catalog.=) ANY (SELECT DISTINCT users_table.value_1 FROM subquery_and_ctes.users_table ORDER BY users_table.value_1 LIMIT 3)))) SELECT dist_cte.user_id FROM (local_cte JOIN dist_cte ON ((dist_cte.user_id OPERATOR(pg_catalog.=) local_cte.user_id)))
|
DEBUG: generating subplan 48_1 for CTE cte: WITH local_cte AS (SELECT users_table_local.user_id, users_table_local."time", users_table_local.value_1, users_table_local.value_2, users_table_local.value_3, users_table_local.value_4 FROM subquery_and_ctes.users_table_local), dist_cte AS (SELECT events_table.user_id FROM subquery_and_ctes.events_table, (SELECT DISTINCT users_table.value_2 FROM subquery_and_ctes.users_table OFFSET 0) foo WHERE ((events_table.user_id OPERATOR(pg_catalog.=) foo.value_2) AND (events_table.user_id OPERATOR(pg_catalog.=) ANY (SELECT DISTINCT users_table.value_1 FROM subquery_and_ctes.users_table ORDER BY users_table.value_1 LIMIT 3)))) SELECT dist_cte.user_id FROM (local_cte JOIN dist_cte ON ((dist_cte.user_id OPERATOR(pg_catalog.=) local_cte.user_id)))
|
||||||
|
@ -505,25 +503,24 @@ SELECT
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
WITH RECURSIVE cte AS (
|
WITH RECURSIVE cte AS (
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT users_table.user_id
|
DISTINCT users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.user_id AND
|
users_table.user_id = events_table.user_id AND
|
||||||
event_type IN (1,2,3,4)
|
event_type IN (1,2,3,4)
|
||||||
) SELECT * FROM cte ORDER BY 1 DESC
|
) SELECT * FROM cte ORDER BY 1 DESC
|
||||||
) as foo,
|
) as foo,
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT users_table.user_id
|
DISTINCT users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.user_id AND
|
users_table.user_id = events_table.user_id AND
|
||||||
event_type IN (1,2,3,4)
|
event_type IN (1,2,3,4)
|
||||||
|
) as bar
|
||||||
) as bar
|
|
||||||
WHERE foo.user_id = bar.user_id
|
WHERE foo.user_id = bar.user_id
|
||||||
ORDER BY 1 DESC;
|
ORDER BY 1 DESC;
|
||||||
ERROR: recursive CTEs are not supported in distributed queries
|
ERROR: recursive CTEs are not supported in distributed queries
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
-- test recursive planning functionality with complex target entries
|
-- test recursive planning functionality with complex target entries
|
||||||
-- and some utilities
|
-- and some utilities
|
||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
CREATE SCHEMA subquery_complex;
|
CREATE SCHEMA subquery_complex;
|
||||||
|
@ -11,7 +11,7 @@ SELECT
|
||||||
FROM
|
FROM
|
||||||
events_table
|
events_table
|
||||||
WHERE
|
WHERE
|
||||||
user_id IN (SELECT user_id FROM users_table GROUP BY user_id ORDER BY count(*) DESC LIMIT 20)
|
user_id IN (SELECT user_id FROM users_table GROUP BY user_id ORDER BY count(*) DESC LIMIT 20)
|
||||||
GROUP BY
|
GROUP BY
|
||||||
event_type
|
event_type
|
||||||
ORDER BY 1 DESC, 2 DESC
|
ORDER BY 1 DESC, 2 DESC
|
||||||
|
@ -63,8 +63,8 @@ FROM
|
||||||
SELECT count(distinct value_2) as cnt_2 FROM users_table ORDER BY 1 DESC LIMIT 4
|
SELECT count(distinct value_2) as cnt_2 FROM users_table ORDER BY 1 DESC LIMIT 4
|
||||||
) as baz,
|
) as baz,
|
||||||
(
|
(
|
||||||
SELECT user_id, sum(distinct value_2) as sum FROM users_table GROUP BY user_id ORDER BY 1 DESC LIMIT 4
|
SELECT user_id, sum(distinct value_2) as sum FROM users_table GROUP BY user_id ORDER BY 1 DESC LIMIT 4
|
||||||
) as bat, events_table
|
) as bat, events_table
|
||||||
WHERE foo.avg != bar.cnt_1 AND baz.cnt_2 = events_table.event_type
|
WHERE foo.avg != bar.cnt_1 AND baz.cnt_2 = events_table.event_type
|
||||||
ORDER BY 1 DESC;
|
ORDER BY 1 DESC;
|
||||||
DEBUG: push down of limit count: 3
|
DEBUG: push down of limit count: 3
|
||||||
|
@ -85,29 +85,29 @@ SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
min(user_id) * 2, max(user_id) / 2, sum(user_id), count(user_id)::float, avg(user_id)::bigint
|
min(user_id) * 2, max(user_id) / 2, sum(user_id), count(user_id)::float, avg(user_id)::bigint
|
||||||
FROM
|
FROM
|
||||||
users_table
|
users_table
|
||||||
ORDER BY 1 DESC
|
ORDER BY 1 DESC
|
||||||
LIMIT 3
|
LIMIT 3
|
||||||
) as foo,
|
) as foo,
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
min(value_3) * 2, max(value_3) / 2, sum(value_3), count(value_3), avg(value_3)
|
min(value_3) * 2, max(value_3) / 2, sum(value_3), count(value_3), avg(value_3)
|
||||||
FROM
|
FROM
|
||||||
users_table
|
users_table
|
||||||
ORDER BY 1 DESC
|
ORDER BY 1 DESC
|
||||||
LIMIT 3
|
LIMIT 3
|
||||||
) as bar,
|
) as bar,
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
min(time), max(time), count(time),
|
min(time), max(time), count(time),
|
||||||
count(*) FILTER (WHERE user_id = 3) as cnt_with_filter,
|
count(*) FILTER (WHERE user_id = 3) as cnt_with_filter,
|
||||||
count(*) FILTER (WHERE user_id::text LIKE '%3%') as cnt_with_filter_2
|
count(*) FILTER (WHERE user_id::text LIKE '%3%') as cnt_with_filter_2
|
||||||
FROM
|
FROM
|
||||||
users_table
|
users_table
|
||||||
ORDER BY 1 DESC
|
ORDER BY 1 DESC
|
||||||
LIMIT 3
|
LIMIT 3
|
||||||
) as baz
|
) as baz
|
||||||
ORDER BY 1 DESC;
|
ORDER BY 1 DESC;
|
||||||
|
@ -135,11 +135,11 @@ FROM
|
||||||
SELECT sum(user_id * (5.0 / (value_1 + value_2 + 0.1)) * value_3) as cnt_1 FROM users_table ORDER BY 1 DESC LIMIT 3
|
SELECT sum(user_id * (5.0 / (value_1 + value_2 + 0.1)) * value_3) as cnt_1 FROM users_table ORDER BY 1 DESC LIMIT 3
|
||||||
) as bar,
|
) as bar,
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
avg(case
|
avg(case
|
||||||
when user_id > 4
|
when user_id > 4
|
||||||
then value_1
|
then value_1
|
||||||
end) as cnt_2,
|
end) as cnt_2,
|
||||||
avg(case
|
avg(case
|
||||||
when user_id > 500
|
when user_id > 500
|
||||||
then value_1
|
then value_1
|
||||||
|
@ -152,16 +152,16 @@ FROM
|
||||||
end) as sum_1,
|
end) as sum_1,
|
||||||
extract(year FROM max(time)) as l_year,
|
extract(year FROM max(time)) as l_year,
|
||||||
strpos(max(user_id)::text, '1') as pos
|
strpos(max(user_id)::text, '1') as pos
|
||||||
FROM
|
FROM
|
||||||
users_table
|
users_table
|
||||||
ORDER BY
|
ORDER BY
|
||||||
1 DESC
|
1 DESC
|
||||||
LIMIT 4
|
LIMIT 4
|
||||||
) as baz,
|
) as baz,
|
||||||
(
|
(
|
||||||
SELECT COALESCE(value_3, 20) AS count_pay FROM users_table ORDER BY 1 OFFSET 20 LIMIT 5
|
SELECT COALESCE(value_3, 20) AS count_pay FROM users_table ORDER BY 1 OFFSET 20 LIMIT 5
|
||||||
) as tar,
|
) as tar,
|
||||||
events_table
|
events_table
|
||||||
WHERE foo.avg != bar.cnt_1 AND baz.cnt_2 != events_table.event_type
|
WHERE foo.avg != bar.cnt_1 AND baz.cnt_2 != events_table.event_type
|
||||||
ORDER BY 1 DESC;
|
ORDER BY 1 DESC;
|
||||||
DEBUG: push down of limit count: 3
|
DEBUG: push down of limit count: 3
|
||||||
|
@ -245,7 +245,7 @@ FROM (
|
||||||
sum(value_1) > 10
|
sum(value_1) > 10
|
||||||
ORDER BY (sum(value_3) - avg(value_1) - COALESCE(array_upper(ARRAY[max(user_id)],1) * 5,0)) DESC
|
ORDER BY (sum(value_3) - avg(value_1) - COALESCE(array_upper(ARRAY[max(user_id)],1) * 5,0)) DESC
|
||||||
LIMIT 3
|
LIMIT 3
|
||||||
) as c
|
) as c
|
||||||
WHERE b.value_2 != a.user_id
|
WHERE b.value_2 != a.user_id
|
||||||
ORDER BY 3 DESC, 2 DESC, 1 DESC
|
ORDER BY 3 DESC, 2 DESC, 1 DESC
|
||||||
LIMIT 5;
|
LIMIT 5;
|
||||||
|
@ -267,20 +267,20 @@ DEBUG: Plan 21 query after replacing subqueries and CTEs: SELECT a.user_id, b.v
|
||||||
SELECT
|
SELECT
|
||||||
bar.user_id
|
bar.user_id
|
||||||
FROM
|
FROM
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT users_table.user_id
|
DISTINCT users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.user_id AND
|
users_table.user_id = events_table.user_id AND
|
||||||
event_type IN (1,2,3,4)
|
event_type IN (1,2,3,4)
|
||||||
ORDER BY 1 DESC LIMIT 5
|
ORDER BY 1 DESC LIMIT 5
|
||||||
) as foo,
|
) as foo,
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT users_table.user_id
|
DISTINCT users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.user_id AND false AND
|
users_table.user_id = events_table.user_id AND false AND
|
||||||
event_type IN (1,2,3,4)
|
event_type IN (1,2,3,4)
|
||||||
ORDER BY 1 DESC LIMIT 5
|
ORDER BY 1 DESC LIMIT 5
|
||||||
|
@ -296,7 +296,7 @@ DEBUG: Plan 25 query after replacing subqueries and CTEs: SELECT bar.user_id FR
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
-- window functions tests, both is recursively planned
|
-- window functions tests, both is recursively planned
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
user_id, time, rnk
|
user_id, time, rnk
|
||||||
|
@ -325,7 +325,7 @@ SELECT * FROM
|
||||||
*, rank() OVER my_win as rnk
|
*, rank() OVER my_win as rnk
|
||||||
FROM
|
FROM
|
||||||
events_table
|
events_table
|
||||||
WHERE
|
WHERE
|
||||||
user_id = 3
|
user_id = 3
|
||||||
WINDOW my_win AS (PARTITION BY event_type ORDER BY time DESC)
|
WINDOW my_win AS (PARTITION BY event_type ORDER BY time DESC)
|
||||||
) as foo
|
) as foo
|
||||||
|
@ -343,14 +343,13 @@ DEBUG: Plan 28 query after replacing subqueries and CTEs: SELECT foo.user_id, f
|
||||||
|
|
||||||
-- cursor test
|
-- cursor test
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
DECLARE recursive_subquery CURSOR FOR
|
||||||
DECLARE recursive_subquery CURSOR FOR
|
|
||||||
SELECT
|
SELECT
|
||||||
event_type, count(distinct value_2)
|
event_type, count(distinct value_2)
|
||||||
FROM
|
FROM
|
||||||
events_table
|
events_table
|
||||||
WHERE
|
WHERE
|
||||||
user_id IN (SELECT user_id FROM users_table GROUP BY user_id ORDER BY count(*) DESC LIMIT 20)
|
user_id IN (SELECT user_id FROM users_table GROUP BY user_id ORDER BY count(*) DESC LIMIT 20)
|
||||||
GROUP BY
|
GROUP BY
|
||||||
event_type
|
event_type
|
||||||
ORDER BY 1 DESC, 2 DESC
|
ORDER BY 1 DESC, 2 DESC
|
||||||
|
@ -384,14 +383,13 @@ DEBUG: Plan 31 query after replacing subqueries and CTEs: SELECT event_type, co
|
||||||
COMMIT;
|
COMMIT;
|
||||||
-- cursor test with FETCH ALL
|
-- cursor test with FETCH ALL
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
DECLARE recursive_subquery CURSOR FOR
|
||||||
DECLARE recursive_subquery CURSOR FOR
|
|
||||||
SELECT
|
SELECT
|
||||||
event_type, count(distinct value_2)
|
event_type, count(distinct value_2)
|
||||||
FROM
|
FROM
|
||||||
events_table
|
events_table
|
||||||
WHERE
|
WHERE
|
||||||
user_id IN (SELECT user_id FROM users_table GROUP BY user_id ORDER BY count(*) DESC LIMIT 20)
|
user_id IN (SELECT user_id FROM users_table GROUP BY user_id ORDER BY count(*) DESC LIMIT 20)
|
||||||
GROUP BY
|
GROUP BY
|
||||||
event_type
|
event_type
|
||||||
ORDER BY 1 DESC, 2 DESC
|
ORDER BY 1 DESC, 2 DESC
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
CREATE SCHEMA subquery_in_where;
|
CREATE SCHEMA subquery_in_where;
|
||||||
SET search_path TO subquery_in_where, public;
|
SET search_path TO subquery_in_where, public;
|
||||||
SET client_min_messages TO DEBUG1;
|
SET client_min_messages TO DEBUG1;
|
||||||
--CTEs can be used as a recurring tuple with subqueries in WHERE
|
--CTEs can be used as a recurring tuple with subqueries in WHERE
|
||||||
WITH event_id
|
WITH event_id
|
||||||
AS (SELECT user_id AS events_user_id,
|
AS (SELECT user_id AS events_user_id,
|
||||||
time AS events_time,
|
time AS events_time,
|
||||||
event_type
|
event_type
|
||||||
FROM events_table)
|
FROM events_table)
|
||||||
SELECT Count(*)
|
SELECT Count(*)
|
||||||
FROM event_id
|
FROM event_id
|
||||||
WHERE events_user_id IN (SELECT user_id
|
WHERE events_user_id IN (SELECT user_id
|
||||||
FROM users_table);
|
FROM users_table);
|
||||||
|
@ -22,27 +22,27 @@ DEBUG: Plan 1 query after replacing subqueries and CTEs: SELECT count(*) AS cou
|
||||||
101
|
101
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
--Correlated subqueries can not be used in WHERE clause
|
--Correlated subqueries can not be used in WHERE clause
|
||||||
WITH event_id
|
WITH event_id
|
||||||
AS (SELECT user_id AS events_user_id,
|
AS (SELECT user_id AS events_user_id,
|
||||||
time AS events_time,
|
time AS events_time,
|
||||||
event_type
|
event_type
|
||||||
FROM events_table)
|
FROM events_table)
|
||||||
SELECT Count(*)
|
SELECT Count(*)
|
||||||
FROM event_id
|
FROM event_id
|
||||||
WHERE events_user_id IN (SELECT user_id
|
WHERE events_user_id IN (SELECT user_id
|
||||||
FROM users_table
|
FROM users_table
|
||||||
WHERE users_table.time = events_time);
|
WHERE users_table.time = events_time);
|
||||||
DEBUG: generating subplan 4_1 for CTE event_id: SELECT user_id AS events_user_id, "time" AS events_time, event_type FROM public.events_table
|
DEBUG: generating subplan 4_1 for CTE event_id: SELECT user_id AS events_user_id, "time" AS events_time, event_type FROM public.events_table
|
||||||
DEBUG: Plan 4 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM (SELECT intermediate_result.events_user_id, intermediate_result.events_time, intermediate_result.event_type FROM read_intermediate_result('4_1'::text, 'binary'::citus_copy_format) intermediate_result(events_user_id integer, events_time timestamp without time zone, event_type integer)) event_id WHERE (events_user_id OPERATOR(pg_catalog.=) ANY (SELECT users_table.user_id FROM public.users_table WHERE (users_table."time" OPERATOR(pg_catalog.=) event_id.events_time)))
|
DEBUG: Plan 4 query after replacing subqueries and CTEs: SELECT count(*) AS count FROM (SELECT intermediate_result.events_user_id, intermediate_result.events_time, intermediate_result.event_type FROM read_intermediate_result('4_1'::text, 'binary'::citus_copy_format) intermediate_result(events_user_id integer, events_time timestamp without time zone, event_type integer)) event_id WHERE (events_user_id OPERATOR(pg_catalog.=) ANY (SELECT users_table.user_id FROM public.users_table WHERE (users_table."time" OPERATOR(pg_catalog.=) event_id.events_time)))
|
||||||
ERROR: cannot pushdown the subquery
|
ERROR: cannot pushdown the subquery
|
||||||
DETAIL: Complex subqueries and CTEs are not allowed in the FROM clause when the query has subqueries in the WHERE clause and it references a column from another query
|
DETAIL: Complex subqueries and CTEs are not allowed in the FROM clause when the query has subqueries in the WHERE clause and it references a column from another query
|
||||||
-- Recurring tuples as empty join tree
|
-- Recurring tuples as empty join tree
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM (SELECT 1 AS id, 2 AS value_1, 3 AS value_3
|
FROM (SELECT 1 AS id, 2 AS value_1, 3 AS value_3
|
||||||
UNION ALL SELECT 2 as id, 3 as value_1, 4 as value_3) AS tt1
|
UNION ALL SELECT 2 as id, 3 as value_1, 4 as value_3) AS tt1
|
||||||
WHERE id IN (SELECT user_id
|
WHERE id IN (SELECT user_id
|
||||||
FROM events_table);
|
FROM events_table);
|
||||||
DEBUG: generating subplan 6_1 for subquery SELECT 1 AS id, 2 AS value_1, 3 AS value_3 UNION ALL SELECT 2 AS id, 3 AS value_1, 4 AS value_3
|
DEBUG: generating subplan 6_1 for subquery SELECT 1 AS id, 2 AS value_1, 3 AS value_3 UNION ALL SELECT 2 AS id, 3 AS value_1, 4 AS value_3
|
||||||
DEBUG: generating subplan 6_2 for subquery SELECT user_id FROM public.events_table
|
DEBUG: generating subplan 6_2 for subquery SELECT user_id FROM public.events_table
|
||||||
DEBUG: Plan 6 query after replacing subqueries and CTEs: SELECT id, value_1, value_3 FROM (SELECT intermediate_result.id, intermediate_result.value_1, intermediate_result.value_3 FROM read_intermediate_result('6_1'::text, 'binary'::citus_copy_format) intermediate_result(id integer, value_1 integer, value_3 integer)) tt1 WHERE (id OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.user_id FROM read_intermediate_result('6_2'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer)))
|
DEBUG: Plan 6 query after replacing subqueries and CTEs: SELECT id, value_1, value_3 FROM (SELECT intermediate_result.id, intermediate_result.value_1, intermediate_result.value_3 FROM read_intermediate_result('6_1'::text, 'binary'::citus_copy_format) intermediate_result(id integer, value_1 integer, value_3 integer)) tt1 WHERE (id OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.user_id FROM read_intermediate_result('6_2'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer)))
|
||||||
|
@ -55,12 +55,12 @@ DEBUG: Plan 6 query after replacing subqueries and CTEs: SELECT id, value_1, va
|
||||||
-- Recurring tuples in from clause as CTE and SET operation in WHERE clause
|
-- Recurring tuples in from clause as CTE and SET operation in WHERE clause
|
||||||
SELECT Count(*)
|
SELECT Count(*)
|
||||||
FROM (WITH event_id AS
|
FROM (WITH event_id AS
|
||||||
(SELECT user_id AS events_user_id, time AS events_time, event_type
|
(SELECT user_id AS events_user_id, time AS events_time, event_type
|
||||||
FROM events_table)
|
FROM events_table)
|
||||||
SELECT events_user_id, events_time, event_type
|
SELECT events_user_id, events_time, event_type
|
||||||
FROM event_id
|
FROM event_id
|
||||||
ORDER BY 1,2,3
|
ORDER BY 1,2,3
|
||||||
LIMIT 10) AS sub_table
|
LIMIT 10) AS sub_table
|
||||||
WHERE events_user_id IN (
|
WHERE events_user_id IN (
|
||||||
(SELECT user_id
|
(SELECT user_id
|
||||||
FROM users_table
|
FROM users_table
|
||||||
|
@ -218,7 +218,7 @@ FROM
|
||||||
user_id as events_user_id, time as events_time, event_type
|
user_id as events_user_id, time as events_time, event_type
|
||||||
FROM
|
FROM
|
||||||
events_table
|
events_table
|
||||||
ORDER BY
|
ORDER BY
|
||||||
1,2,3
|
1,2,3
|
||||||
LIMIT
|
LIMIT
|
||||||
10
|
10
|
||||||
|
@ -628,7 +628,6 @@ DEBUG: Plan 65 query after replacing subqueries and CTEs: SELECT generate_serie
|
||||||
3
|
3
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
|
|
||||||
-- Local tables also planned recursively, so using it as part of the FROM clause
|
-- Local tables also planned recursively, so using it as part of the FROM clause
|
||||||
-- make the clause recurring
|
-- make the clause recurring
|
||||||
CREATE TABLE local_table(id int, value_1 int);
|
CREATE TABLE local_table(id int, value_1 int);
|
||||||
|
@ -656,7 +655,6 @@ DEBUG: Plan 67 query after replacing subqueries and CTEs: SELECT id, value_1 FR
|
||||||
2 | 2
|
2 | 2
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
|
|
||||||
-- Use local table in WHERE clause
|
-- Use local table in WHERE clause
|
||||||
SELECT
|
SELECT
|
||||||
COUNT(*)
|
COUNT(*)
|
||||||
|
@ -667,7 +665,7 @@ FROM
|
||||||
users_table
|
users_table
|
||||||
ORDER BY
|
ORDER BY
|
||||||
user_id
|
user_id
|
||||||
LIMIT
|
LIMIT
|
||||||
10) as sub_table
|
10) as sub_table
|
||||||
WHERE
|
WHERE
|
||||||
user_id
|
user_id
|
||||||
|
|
|
@ -6,7 +6,6 @@ SET search_path TO subquery_and_partitioning, public;
|
||||||
CREATE TABLE users_table_local AS SELECT * FROM users_table;
|
CREATE TABLE users_table_local AS SELECT * FROM users_table;
|
||||||
CREATE TABLE events_table_local AS SELECT * FROM events_table;
|
CREATE TABLE events_table_local AS SELECT * FROM events_table;
|
||||||
CREATE TABLE partitioning_test(id int, value_1 int, time date) PARTITION BY RANGE (time);
|
CREATE TABLE partitioning_test(id int, value_1 int, time date) PARTITION BY RANGE (time);
|
||||||
|
|
||||||
-- create its partitions
|
-- create its partitions
|
||||||
CREATE TABLE partitioning_test_2017 PARTITION OF partitioning_test FOR VALUES FROM ('2017-01-01') TO ('2018-01-01');
|
CREATE TABLE partitioning_test_2017 PARTITION OF partitioning_test FOR VALUES FROM ('2017-01-01') TO ('2018-01-01');
|
||||||
CREATE TABLE partitioning_test_2010 PARTITION OF partitioning_test FOR VALUES FROM ('2010-01-01') TO ('2011-01-01');
|
CREATE TABLE partitioning_test_2010 PARTITION OF partitioning_test FOR VALUES FROM ('2010-01-01') TO ('2011-01-01');
|
||||||
|
@ -30,9 +29,9 @@ SET client_min_messages TO DEBUG1;
|
||||||
SELECT
|
SELECT
|
||||||
id
|
id
|
||||||
FROM
|
FROM
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT partitioning_test.id
|
DISTINCT partitioning_test.id
|
||||||
FROM
|
FROM
|
||||||
partitioning_test
|
partitioning_test
|
||||||
LIMIT 5
|
LIMIT 5
|
||||||
) as foo
|
) as foo
|
||||||
|
@ -52,15 +51,15 @@ DEBUG: Plan 3 query after replacing subqueries and CTEs: SELECT id FROM (SELECT
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT partitioning_test.id
|
DISTINCT partitioning_test.id
|
||||||
FROM
|
FROM
|
||||||
partitioning_test
|
partitioning_test
|
||||||
LIMIT 5
|
LIMIT 5
|
||||||
) as foo,
|
) as foo,
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT partitioning_test.time
|
DISTINCT partitioning_test.time
|
||||||
FROM
|
FROM
|
||||||
partitioning_test
|
partitioning_test
|
||||||
LIMIT 5
|
LIMIT 5
|
||||||
) as bar
|
) as bar
|
||||||
|
@ -80,17 +79,17 @@ DEBUG: Plan 5 query after replacing subqueries and CTEs: SELECT foo.id, bar."ti
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT partitioning_test.time
|
DISTINCT partitioning_test.time
|
||||||
FROM
|
FROM
|
||||||
partitioning_test
|
partitioning_test
|
||||||
ORDER BY 1 DESC
|
ORDER BY 1 DESC
|
||||||
LIMIT 5
|
LIMIT 5
|
||||||
) as foo,
|
) as foo,
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT partitioning_test.id
|
DISTINCT partitioning_test.id
|
||||||
FROM
|
FROM
|
||||||
partitioning_test
|
partitioning_test
|
||||||
) as bar
|
) as bar
|
||||||
WHERE date_part('day', foo.time) = bar.id
|
WHERE date_part('day', foo.time) = bar.id
|
||||||
|
@ -109,19 +108,19 @@ DEBUG: push down of limit count: 3
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT partitioning_test.time
|
DISTINCT partitioning_test.time
|
||||||
FROM
|
FROM
|
||||||
partitioning_test
|
partitioning_test
|
||||||
ORDER BY 1 DESC
|
ORDER BY 1 DESC
|
||||||
LIMIT 5
|
LIMIT 5
|
||||||
) as foo,
|
) as foo,
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT partitioning_test.id
|
DISTINCT partitioning_test.id
|
||||||
FROM
|
FROM
|
||||||
partitioning_test
|
partitioning_test
|
||||||
) as bar,
|
) as bar,
|
||||||
partitioning_test
|
partitioning_test
|
||||||
WHERE date_part('day', foo.time) = bar.id AND partitioning_test.id = bar.id
|
WHERE date_part('day', foo.time) = bar.id AND partitioning_test.id = bar.id
|
||||||
ORDER BY 2 DESC, 1 DESC
|
ORDER BY 2 DESC, 1 DESC
|
||||||
|
@ -138,7 +137,7 @@ DEBUG: push down of limit count: 3
|
||||||
-- subquery in WHERE clause
|
-- subquery in WHERE clause
|
||||||
SELECT DISTINCT id
|
SELECT DISTINCT id
|
||||||
FROM partitioning_test
|
FROM partitioning_test
|
||||||
WHERE
|
WHERE
|
||||||
id IN (SELECT DISTINCT date_part('day', time) FROM partitioning_test);
|
id IN (SELECT DISTINCT date_part('day', time) FROM partitioning_test);
|
||||||
DEBUG: generating subplan 12_1 for subquery SELECT DISTINCT date_part('day'::text, "time") AS date_part FROM subquery_and_partitioning.partitioning_test
|
DEBUG: generating subplan 12_1 for subquery SELECT DISTINCT date_part('day'::text, "time") AS date_part FROM subquery_and_partitioning.partitioning_test
|
||||||
DEBUG: Plan 12 query after replacing subqueries and CTEs: SELECT DISTINCT id FROM subquery_and_partitioning.partitioning_test WHERE ((id)::double precision OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.date_part FROM read_intermediate_result('12_1'::text, 'binary'::citus_copy_format) intermediate_result(date_part double precision)))
|
DEBUG: Plan 12 query after replacing subqueries and CTEs: SELECT DISTINCT id FROM subquery_and_partitioning.partitioning_test WHERE ((id)::double precision OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.date_part FROM read_intermediate_result('12_1'::text, 'binary'::citus_copy_format) intermediate_result(date_part double precision)))
|
||||||
|
@ -149,16 +148,16 @@ DEBUG: Plan 12 query after replacing subqueries and CTEs: SELECT DISTINCT id FR
|
||||||
|
|
||||||
-- repartition subquery
|
-- repartition subquery
|
||||||
SET citus.enable_repartition_joins to ON;
|
SET citus.enable_repartition_joins to ON;
|
||||||
SELECT
|
SELECT
|
||||||
count(*)
|
count(*)
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT DISTINCT p1.value_1 FROM partitioning_test as p1, partitioning_test as p2 WHERE p1.id = p2.value_1
|
SELECT DISTINCT p1.value_1 FROM partitioning_test as p1, partitioning_test as p2 WHERE p1.id = p2.value_1
|
||||||
) as foo,
|
) as foo,
|
||||||
(
|
(
|
||||||
SELECT user_id FROM users_table
|
SELECT user_id FROM users_table
|
||||||
) as bar
|
) as bar
|
||||||
WHERE foo.value_1 = bar.user_id;
|
WHERE foo.value_1 = bar.user_id;
|
||||||
DEBUG: cannot use adaptive executor with repartition jobs
|
DEBUG: cannot use adaptive executor with repartition jobs
|
||||||
HINT: Since you enabled citus.enable_repartition_joins Citus chose to use task-tracker.
|
HINT: Since you enabled citus.enable_repartition_joins Citus chose to use task-tracker.
|
||||||
DEBUG: generating subplan 14_1 for subquery SELECT DISTINCT p1.value_1 FROM subquery_and_partitioning.partitioning_test p1, subquery_and_partitioning.partitioning_test p2 WHERE (p1.id OPERATOR(pg_catalog.=) p2.value_1)
|
DEBUG: generating subplan 14_1 for subquery SELECT DISTINCT p1.value_1 FROM subquery_and_partitioning.partitioning_test p1, subquery_and_partitioning.partitioning_test p2 WHERE (p1.id OPERATOR(pg_catalog.=) p2.value_1)
|
||||||
|
@ -170,40 +169,40 @@ DEBUG: Plan 14 query after replacing subqueries and CTEs: SELECT count(*) AS co
|
||||||
|
|
||||||
SET citus.enable_repartition_joins to OFF;
|
SET citus.enable_repartition_joins to OFF;
|
||||||
-- subquery, cte, view and non-partitioned tables
|
-- subquery, cte, view and non-partitioned tables
|
||||||
CREATE VIEW subquery_and_ctes AS
|
CREATE VIEW subquery_and_ctes AS
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
WITH local_cte AS (
|
WITH local_cte AS (
|
||||||
SELECT * FROM users_table_local
|
SELECT * FROM users_table_local
|
||||||
),
|
),
|
||||||
dist_cte AS (
|
dist_cte AS (
|
||||||
SELECT
|
SELECT
|
||||||
user_id
|
user_id
|
||||||
FROM
|
FROM
|
||||||
events_table,
|
events_table,
|
||||||
(SELECT DISTINCT value_1 FROM partitioning_test OFFSET 0) as foo
|
(SELECT DISTINCT value_1 FROM partitioning_test OFFSET 0) as foo
|
||||||
WHERE
|
WHERE
|
||||||
events_table.user_id = foo.value_1 AND
|
events_table.user_id = foo.value_1 AND
|
||||||
events_table.user_id IN (SELECT DISTINCT value_1 FROM users_table ORDER BY 1 LIMIT 3)
|
events_table.user_id IN (SELECT DISTINCT value_1 FROM users_table ORDER BY 1 LIMIT 3)
|
||||||
)
|
)
|
||||||
SELECT dist_cte.user_id FROM local_cte join dist_cte on dist_cte.user_id=local_cte.user_id
|
SELECT dist_cte.user_id FROM local_cte join dist_cte on dist_cte.user_id=local_cte.user_id
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
count(*) as cnt
|
count(*) as cnt
|
||||||
FROM
|
FROM
|
||||||
cte,
|
cte,
|
||||||
(SELECT
|
(SELECT
|
||||||
DISTINCT events_table.user_id
|
DISTINCT events_table.user_id
|
||||||
FROM
|
FROM
|
||||||
partitioning_test, events_table
|
partitioning_test, events_table
|
||||||
WHERE
|
WHERE
|
||||||
events_table.user_id = partitioning_test.id AND
|
events_table.user_id = partitioning_test.id AND
|
||||||
event_type IN (1,2,3,4)
|
event_type IN (1,2,3,4)
|
||||||
ORDER BY 1 DESC LIMIT 5
|
ORDER BY 1 DESC LIMIT 5
|
||||||
) as foo
|
) as foo
|
||||||
WHERE foo.user_id = cte.user_id
|
WHERE foo.user_id = cte.user_id
|
||||||
) as foo, users_table WHERE foo.cnt > users_table.value_2;
|
) as foo, users_table WHERE foo.cnt > users_table.value_2;
|
||||||
SELECT * FROM subquery_and_ctes
|
SELECT * FROM subquery_and_ctes
|
||||||
|
@ -235,27 +234,27 @@ DEBUG: push down of limit count: 5
|
||||||
SELECT count(*)
|
SELECT count(*)
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT avg(min) FROM
|
SELECT avg(min) FROM
|
||||||
(
|
(
|
||||||
SELECT min(partitioning_test.value_1) FROM
|
SELECT min(partitioning_test.value_1) FROM
|
||||||
(
|
(
|
||||||
SELECT avg(event_type) as avg_ev_type FROM
|
SELECT avg(event_type) as avg_ev_type FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
max(value_1) as mx_val_1
|
max(value_1) as mx_val_1
|
||||||
FROM (
|
FROM (
|
||||||
SELECT
|
SELECT
|
||||||
avg(event_type) as avg
|
avg(event_type) as avg
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
cnt
|
cnt
|
||||||
FROM
|
FROM
|
||||||
(SELECT count(*) as cnt, value_1 FROM partitioning_test GROUP BY value_1) as level_1, users_table
|
(SELECT count(*) as cnt, value_1 FROM partitioning_test GROUP BY value_1) as level_1, users_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = level_1.cnt
|
users_table.user_id = level_1.cnt
|
||||||
) as level_2, events_table
|
) as level_2, events_table
|
||||||
WHERE events_table.user_id = level_2.cnt
|
WHERE events_table.user_id = level_2.cnt
|
||||||
GROUP BY level_2.cnt
|
GROUP BY level_2.cnt
|
||||||
) as level_3, users_table
|
) as level_3, users_table
|
||||||
WHERE user_id = level_3.avg
|
WHERE user_id = level_3.avg
|
||||||
|
@ -264,9 +263,9 @@ FROM
|
||||||
WHERE level_4.mx_val_1 = events_table.user_id
|
WHERE level_4.mx_val_1 = events_table.user_id
|
||||||
GROUP BY level_4.mx_val_1
|
GROUP BY level_4.mx_val_1
|
||||||
) as level_5, partitioning_test
|
) as level_5, partitioning_test
|
||||||
WHERE
|
WHERE
|
||||||
level_5.avg_ev_type = partitioning_test.id
|
level_5.avg_ev_type = partitioning_test.id
|
||||||
GROUP BY
|
GROUP BY
|
||||||
level_5.avg_ev_type
|
level_5.avg_ev_type
|
||||||
) as level_6, users_table WHERE users_table.user_id = level_6.min
|
) as level_6, users_table WHERE users_table.user_id = level_6.min
|
||||||
GROUP BY users_table.value_1
|
GROUP BY users_table.value_1
|
||||||
|
|
|
@ -29,7 +29,7 @@ SET client_min_messages TO DEBUG1;
|
||||||
WITH ids_to_delete AS (
|
WITH ids_to_delete AS (
|
||||||
SELECT tenant_id FROM distributed_table WHERE dept = 1
|
SELECT tenant_id FROM distributed_table WHERE dept = 1
|
||||||
)
|
)
|
||||||
DELETE FROM reference_table WHERE id IN (SELECT tenant_id FROM ids_to_delete);
|
DELETE FROM reference_table WHERE id IN (SELECT tenant_id FROM ids_to_delete);
|
||||||
DEBUG: generating subplan 4_1 for CTE ids_to_delete: SELECT tenant_id FROM with_dml.distributed_table WHERE (dept OPERATOR(pg_catalog.=) 1)
|
DEBUG: generating subplan 4_1 for CTE ids_to_delete: SELECT tenant_id FROM with_dml.distributed_table WHERE (dept OPERATOR(pg_catalog.=) 1)
|
||||||
DEBUG: Plan 4 query after replacing subqueries and CTEs: DELETE FROM with_dml.reference_table WHERE (id OPERATOR(pg_catalog.=) ANY (SELECT ids_to_delete.tenant_id FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('4_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_to_delete))
|
DEBUG: Plan 4 query after replacing subqueries and CTEs: DELETE FROM with_dml.reference_table WHERE (id OPERATOR(pg_catalog.=) ANY (SELECT ids_to_delete.tenant_id FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('4_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_to_delete))
|
||||||
-- update the name of the users whose dept is 2
|
-- update the name of the users whose dept is 2
|
||||||
|
@ -40,11 +40,11 @@ UPDATE reference_table SET name = 'new_' || name WHERE id IN (SELECT tenant_id F
|
||||||
DEBUG: generating subplan 6_1 for CTE ids_to_update: SELECT tenant_id FROM with_dml.distributed_table WHERE (dept OPERATOR(pg_catalog.=) 2)
|
DEBUG: generating subplan 6_1 for CTE ids_to_update: SELECT tenant_id FROM with_dml.distributed_table WHERE (dept OPERATOR(pg_catalog.=) 2)
|
||||||
DEBUG: Plan 6 query after replacing subqueries and CTEs: UPDATE with_dml.reference_table SET name = ('new_'::text OPERATOR(pg_catalog.||) name) WHERE (id OPERATOR(pg_catalog.=) ANY (SELECT ids_to_update.tenant_id FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('6_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_to_update))
|
DEBUG: Plan 6 query after replacing subqueries and CTEs: UPDATE with_dml.reference_table SET name = ('new_'::text OPERATOR(pg_catalog.||) name) WHERE (id OPERATOR(pg_catalog.=) ANY (SELECT ids_to_update.tenant_id FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('6_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_to_update))
|
||||||
-- now the CTE is also modifying
|
-- now the CTE is also modifying
|
||||||
WITH ids_deleted_3 AS
|
WITH ids_deleted_3 AS
|
||||||
(
|
(
|
||||||
DELETE FROM distributed_table WHERE dept = 3 RETURNING tenant_id
|
DELETE FROM distributed_table WHERE dept = 3 RETURNING tenant_id
|
||||||
),
|
),
|
||||||
ids_deleted_4 AS
|
ids_deleted_4 AS
|
||||||
(
|
(
|
||||||
DELETE FROM distributed_table WHERE dept = 4 RETURNING tenant_id
|
DELETE FROM distributed_table WHERE dept = 4 RETURNING tenant_id
|
||||||
)
|
)
|
||||||
|
@ -54,15 +54,15 @@ DEBUG: generating subplan 8_2 for CTE ids_deleted_4: DELETE FROM with_dml.distr
|
||||||
DEBUG: generating subplan 8_3 for subquery SELECT ids_deleted_3.tenant_id FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('8_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_deleted_3 UNION SELECT ids_deleted_4.tenant_id FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('8_2'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_deleted_4
|
DEBUG: generating subplan 8_3 for subquery SELECT ids_deleted_3.tenant_id FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('8_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_deleted_3 UNION SELECT ids_deleted_4.tenant_id FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('8_2'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_deleted_4
|
||||||
DEBUG: Plan 8 query after replacing subqueries and CTEs: DELETE FROM with_dml.reference_table WHERE (id OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.tenant_id FROM read_intermediate_result('8_3'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)))
|
DEBUG: Plan 8 query after replacing subqueries and CTEs: DELETE FROM with_dml.reference_table WHERE (id OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.tenant_id FROM read_intermediate_result('8_3'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)))
|
||||||
-- now the final UPDATE command is pushdownable
|
-- now the final UPDATE command is pushdownable
|
||||||
WITH ids_to_delete AS
|
WITH ids_to_delete AS
|
||||||
(
|
(
|
||||||
SELECT tenant_id FROM distributed_table WHERE dept = 5
|
SELECT tenant_id FROM distributed_table WHERE dept = 5
|
||||||
)
|
)
|
||||||
UPDATE
|
UPDATE
|
||||||
distributed_table
|
distributed_table
|
||||||
SET
|
SET
|
||||||
dept = dept + 1
|
dept = dept + 1
|
||||||
FROM
|
FROM
|
||||||
ids_to_delete, (SELECT tenant_id FROM distributed_table WHERE tenant_id::int < 60) as some_tenants
|
ids_to_delete, (SELECT tenant_id FROM distributed_table WHERE tenant_id::int < 60) as some_tenants
|
||||||
WHERE
|
WHERE
|
||||||
some_tenants.tenant_id = ids_to_delete.tenant_id
|
some_tenants.tenant_id = ids_to_delete.tenant_id
|
||||||
|
@ -72,25 +72,25 @@ DEBUG: generating subplan 12_1 for CTE ids_to_delete: SELECT tenant_id FROM wit
|
||||||
DEBUG: Plan 12 query after replacing subqueries and CTEs: UPDATE with_dml.distributed_table SET dept = (distributed_table.dept OPERATOR(pg_catalog.+) 1) FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('12_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_to_delete, (SELECT distributed_table_1.tenant_id FROM with_dml.distributed_table distributed_table_1 WHERE ((distributed_table_1.tenant_id)::integer OPERATOR(pg_catalog.<) 60)) some_tenants WHERE ((some_tenants.tenant_id OPERATOR(pg_catalog.=) ids_to_delete.tenant_id) AND (distributed_table.tenant_id OPERATOR(pg_catalog.=) some_tenants.tenant_id) AND (EXISTS (SELECT ids_to_delete_1.tenant_id FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('12_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_to_delete_1)))
|
DEBUG: Plan 12 query after replacing subqueries and CTEs: UPDATE with_dml.distributed_table SET dept = (distributed_table.dept OPERATOR(pg_catalog.+) 1) FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('12_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_to_delete, (SELECT distributed_table_1.tenant_id FROM with_dml.distributed_table distributed_table_1 WHERE ((distributed_table_1.tenant_id)::integer OPERATOR(pg_catalog.<) 60)) some_tenants WHERE ((some_tenants.tenant_id OPERATOR(pg_catalog.=) ids_to_delete.tenant_id) AND (distributed_table.tenant_id OPERATOR(pg_catalog.=) some_tenants.tenant_id) AND (EXISTS (SELECT ids_to_delete_1.tenant_id FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('12_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_to_delete_1)))
|
||||||
-- this query errors out since we've some hard
|
-- this query errors out since we've some hard
|
||||||
-- errors in the INSERT ... SELECT pushdown
|
-- errors in the INSERT ... SELECT pushdown
|
||||||
-- which prevents to fallback to recursive planning
|
-- which prevents to fallback to recursive planning
|
||||||
WITH ids_to_upsert AS
|
WITH ids_to_upsert AS
|
||||||
(
|
(
|
||||||
SELECT tenant_id FROM distributed_table WHERE dept > 7
|
SELECT tenant_id FROM distributed_table WHERE dept > 7
|
||||||
)
|
)
|
||||||
INSERT INTO distributed_table
|
INSERT INTO distributed_table
|
||||||
SELECT distributed_table.tenant_id FROM ids_to_upsert, distributed_table
|
SELECT distributed_table.tenant_id FROM ids_to_upsert, distributed_table
|
||||||
WHERE distributed_table.tenant_id = ids_to_upsert.tenant_id
|
WHERE distributed_table.tenant_id = ids_to_upsert.tenant_id
|
||||||
ON CONFLICT (tenant_id) DO UPDATE SET dept = 8;
|
ON CONFLICT (tenant_id) DO UPDATE SET dept = 8;
|
||||||
ERROR: cannot perform distributed planning for the given modification
|
ERROR: cannot perform distributed planning for the given modification
|
||||||
DETAIL: Select query cannot be pushed down to the worker.
|
DETAIL: Select query cannot be pushed down to the worker.
|
||||||
-- the following query is very similar to the above one
|
-- the following query is very similar to the above one
|
||||||
-- but this time the query is pulled to coordinator since
|
-- but this time the query is pulled to coordinator since
|
||||||
-- we return before hitting any hard errors
|
-- we return before hitting any hard errors
|
||||||
WITH ids_to_insert AS
|
WITH ids_to_insert AS
|
||||||
(
|
(
|
||||||
SELECT (tenant_id::int * 100)::text as tenant_id FROM distributed_table WHERE dept > 7
|
SELECT (tenant_id::int * 100)::text as tenant_id FROM distributed_table WHERE dept > 7
|
||||||
)
|
)
|
||||||
INSERT INTO distributed_table
|
INSERT INTO distributed_table
|
||||||
SELECT DISTINCT ids_to_insert.tenant_id FROM ids_to_insert, distributed_table
|
SELECT DISTINCT ids_to_insert.tenant_id FROM ids_to_insert, distributed_table
|
||||||
WHERE distributed_table.tenant_id < ids_to_insert.tenant_id;
|
WHERE distributed_table.tenant_id < ids_to_insert.tenant_id;
|
||||||
DEBUG: cannot perform distributed INSERT INTO ... SELECT because the partition columns in the source table and subquery do not match
|
DEBUG: cannot perform distributed INSERT INTO ... SELECT because the partition columns in the source table and subquery do not match
|
||||||
|
@ -108,7 +108,7 @@ DEBUG: Plan 16 query after replacing subqueries and CTEs: SELECT tenant_id FROM
|
||||||
-- since COPY cannot be executed
|
-- since COPY cannot be executed
|
||||||
SET citus.force_max_query_parallelization TO on;
|
SET citus.force_max_query_parallelization TO on;
|
||||||
WITH copy_to_other_table AS (
|
WITH copy_to_other_table AS (
|
||||||
INSERT INTO distributed_table
|
INSERT INTO distributed_table
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM second_distributed_table
|
FROM second_distributed_table
|
||||||
WHERE dept = 3
|
WHERE dept = 3
|
||||||
|
@ -116,10 +116,10 @@ WITH copy_to_other_table AS (
|
||||||
RETURNING *
|
RETURNING *
|
||||||
),
|
),
|
||||||
main_table_deleted AS (
|
main_table_deleted AS (
|
||||||
DELETE
|
DELETE
|
||||||
FROM distributed_table
|
FROM distributed_table
|
||||||
WHERE dept < 10
|
WHERE dept < 10
|
||||||
AND NOT EXISTS (SELECT 1 FROM second_distributed_table
|
AND NOT EXISTS (SELECT 1 FROM second_distributed_table
|
||||||
WHERE second_distributed_table.dept = 1
|
WHERE second_distributed_table.dept = 1
|
||||||
AND second_distributed_table.tenant_id = distributed_table.tenant_id)
|
AND second_distributed_table.tenant_id = distributed_table.tenant_id)
|
||||||
RETURNING *
|
RETURNING *
|
||||||
|
@ -127,7 +127,7 @@ main_table_deleted AS (
|
||||||
INSERT INTO second_distributed_table
|
INSERT INTO second_distributed_table
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM main_table_deleted
|
FROM main_table_deleted
|
||||||
EXCEPT
|
EXCEPT
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM copy_to_other_table;
|
FROM copy_to_other_table;
|
||||||
DEBUG: distributed INSERT ... SELECT can only select from distributed tables
|
DEBUG: distributed INSERT ... SELECT can only select from distributed tables
|
||||||
|
@ -138,20 +138,19 @@ DEBUG: generating subplan 20_3 for subquery SELECT main_table_deleted.tenant_id
|
||||||
DEBUG: Plan 20 query after replacing subqueries and CTEs: SELECT tenant_id, dept FROM (SELECT intermediate_result.tenant_id, intermediate_result.dept FROM read_intermediate_result('20_3'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text, dept integer)) citus_insert_select_subquery
|
DEBUG: Plan 20 query after replacing subqueries and CTEs: SELECT tenant_id, dept FROM (SELECT intermediate_result.tenant_id, intermediate_result.dept FROM read_intermediate_result('20_3'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text, dept integer)) citus_insert_select_subquery
|
||||||
SET citus.force_max_query_parallelization TO off;
|
SET citus.force_max_query_parallelization TO off;
|
||||||
-- CTE inside the UPDATE statement
|
-- CTE inside the UPDATE statement
|
||||||
UPDATE
|
UPDATE
|
||||||
second_distributed_table
|
second_distributed_table
|
||||||
SET dept =
|
SET dept =
|
||||||
(WITH vals AS (
|
(WITH vals AS (
|
||||||
SELECT DISTINCT tenant_id::int FROM distributed_table
|
SELECT DISTINCT tenant_id::int FROM distributed_table
|
||||||
) select * from vals where tenant_id = 8 )
|
) select * from vals where tenant_id = 8 )
|
||||||
WHERE dept = 8;
|
WHERE dept = 8;
|
||||||
DEBUG: generating subplan 24_1 for CTE vals: SELECT DISTINCT (tenant_id)::integer AS tenant_id FROM with_dml.distributed_table
|
DEBUG: generating subplan 24_1 for CTE vals: SELECT DISTINCT (tenant_id)::integer AS tenant_id FROM with_dml.distributed_table
|
||||||
DEBUG: Plan 24 query after replacing subqueries and CTEs: UPDATE with_dml.second_distributed_table SET dept = (SELECT vals.tenant_id FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('24_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id integer)) vals WHERE (vals.tenant_id OPERATOR(pg_catalog.=) 8)) WHERE (dept OPERATOR(pg_catalog.=) 8)
|
DEBUG: Plan 24 query after replacing subqueries and CTEs: UPDATE with_dml.second_distributed_table SET dept = (SELECT vals.tenant_id FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('24_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id integer)) vals WHERE (vals.tenant_id OPERATOR(pg_catalog.=) 8)) WHERE (dept OPERATOR(pg_catalog.=) 8)
|
||||||
-- Subquery inside the UPDATE statement
|
-- Subquery inside the UPDATE statement
|
||||||
UPDATE
|
UPDATE
|
||||||
second_distributed_table
|
second_distributed_table
|
||||||
SET dept =
|
SET dept =
|
||||||
|
|
||||||
(SELECT DISTINCT tenant_id::int FROM distributed_table WHERE tenant_id = '9')
|
(SELECT DISTINCT tenant_id::int FROM distributed_table WHERE tenant_id = '9')
|
||||||
WHERE dept = 8;
|
WHERE dept = 8;
|
||||||
DEBUG: generating subplan 26_1 for subquery SELECT DISTINCT (tenant_id)::integer AS tenant_id FROM with_dml.distributed_table WHERE (tenant_id OPERATOR(pg_catalog.=) '9'::text)
|
DEBUG: generating subplan 26_1 for subquery SELECT DISTINCT (tenant_id)::integer AS tenant_id FROM with_dml.distributed_table WHERE (tenant_id OPERATOR(pg_catalog.=) '9'::text)
|
||||||
|
|
|
@ -10,9 +10,9 @@ SELECT create_reference_table('with_join.reference_table');
|
||||||
|
|
||||||
INSERT INTO reference_table VALUES (6), (7);
|
INSERT INTO reference_table VALUES (6), (7);
|
||||||
SET citus.enable_repartition_joins TO on;
|
SET citus.enable_repartition_joins TO on;
|
||||||
-- Two colocated CTE under a non-colocated join
|
-- Two colocated CTE under a non-colocated join
|
||||||
WITH colocated_1 AS (
|
WITH colocated_1 AS (
|
||||||
SELECT
|
SELECT
|
||||||
users_table.user_id, events_table.value_2
|
users_table.user_id, events_table.value_2
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
|
@ -20,14 +20,14 @@ WITH colocated_1 AS (
|
||||||
users_table.user_id = events_table.user_id AND event_type IN (1, 2, 3)
|
users_table.user_id = events_table.user_id AND event_type IN (1, 2, 3)
|
||||||
),
|
),
|
||||||
colocated_2 AS (
|
colocated_2 AS (
|
||||||
SELECT
|
SELECT
|
||||||
users_table.user_id, events_table.value_2
|
users_table.user_id, events_table.value_2
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.user_id AND event_type IN (4, 5, 6)
|
users_table.user_id = events_table.user_id AND event_type IN (4, 5, 6)
|
||||||
)
|
)
|
||||||
SELECT colocated_1.user_id, count(*)
|
SELECT colocated_1.user_id, count(*)
|
||||||
FROM
|
FROM
|
||||||
colocated_1, colocated_2
|
colocated_1, colocated_2
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -46,9 +46,9 @@ ORDER BY
|
||||||
6 | 6710
|
6 | 6710
|
||||||
(6 rows)
|
(6 rows)
|
||||||
|
|
||||||
-- Two non-colocated CTE under a co-located join
|
-- Two non-colocated CTE under a co-located join
|
||||||
WITH non_colocated_1 AS (
|
WITH non_colocated_1 AS (
|
||||||
SELECT
|
SELECT
|
||||||
users_table.user_id
|
users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
|
@ -56,14 +56,14 @@ WITH non_colocated_1 AS (
|
||||||
users_table.user_id = events_table.value_2 AND event_type IN (1, 2, 3)
|
users_table.user_id = events_table.value_2 AND event_type IN (1, 2, 3)
|
||||||
),
|
),
|
||||||
non_colocated_2 AS (
|
non_colocated_2 AS (
|
||||||
SELECT
|
SELECT
|
||||||
users_table.user_id
|
users_table.user_id
|
||||||
FROM
|
FROM
|
||||||
users_table, events_table
|
users_table, events_table
|
||||||
WHERE
|
WHERE
|
||||||
users_table.user_id = events_table.value_2 AND event_type IN (4, 5, 6)
|
users_table.user_id = events_table.value_2 AND event_type IN (4, 5, 6)
|
||||||
)
|
)
|
||||||
SELECT non_colocated_1.user_id, count(*)
|
SELECT non_colocated_1.user_id, count(*)
|
||||||
FROM
|
FROM
|
||||||
non_colocated_1, non_colocated_2
|
non_colocated_1, non_colocated_2
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -81,7 +81,6 @@ ORDER BY
|
||||||
1 | 6272
|
1 | 6272
|
||||||
(5 rows)
|
(5 rows)
|
||||||
|
|
||||||
|
|
||||||
-- Subqueries in WHERE and FROM are mixed
|
-- Subqueries in WHERE and FROM are mixed
|
||||||
-- In this query, only subquery in WHERE is not a colocated join
|
-- In this query, only subquery in WHERE is not a colocated join
|
||||||
-- but we're able to recursively plan that as well
|
-- but we're able to recursively plan that as well
|
||||||
|
@ -121,12 +120,12 @@ WITH users_events AS (
|
||||||
event_type
|
event_type
|
||||||
FROM
|
FROM
|
||||||
events_table
|
events_table
|
||||||
WHERE
|
WHERE
|
||||||
user_id < 100
|
user_id < 100
|
||||||
GROUP BY
|
GROUP BY
|
||||||
1
|
1
|
||||||
ORDER BY
|
ORDER BY
|
||||||
1
|
1
|
||||||
LIMIT 10
|
LIMIT 10
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -139,9 +138,9 @@ SELECT
|
||||||
DISTINCT uid
|
DISTINCT uid
|
||||||
FROM
|
FROM
|
||||||
users_events
|
users_events
|
||||||
ORDER BY
|
ORDER BY
|
||||||
1 DESC
|
1 DESC
|
||||||
LIMIT
|
LIMIT
|
||||||
5;
|
5;
|
||||||
uid
|
uid
|
||||||
-----
|
-----
|
||||||
|
@ -162,9 +161,9 @@ FROM
|
||||||
cte
|
cte
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
events_table ON cte.user_id = events_table.user_id
|
events_table ON cte.user_id = events_table.user_id
|
||||||
ORDER BY
|
ORDER BY
|
||||||
1,2,3
|
1,2,3
|
||||||
LIMIT
|
LIMIT
|
||||||
5;
|
5;
|
||||||
ERROR: cannot pushdown the subquery
|
ERROR: cannot pushdown the subquery
|
||||||
DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join
|
DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join
|
||||||
|
@ -178,9 +177,9 @@ FROM
|
||||||
cte
|
cte
|
||||||
RIGHT JOIN
|
RIGHT JOIN
|
||||||
events_table ON cte.user_id = events_table.user_id
|
events_table ON cte.user_id = events_table.user_id
|
||||||
ORDER BY
|
ORDER BY
|
||||||
1,2,3
|
1,2,3
|
||||||
LIMIT
|
LIMIT
|
||||||
5;
|
5;
|
||||||
user_id | time | event_type
|
user_id | time | event_type
|
||||||
---------+---------------------------------+------------
|
---------+---------------------------------+------------
|
||||||
|
@ -198,12 +197,12 @@ WITH cte AS (
|
||||||
SELECT
|
SELECT
|
||||||
cte.user_id, cte.time, events_table.event_type
|
cte.user_id, cte.time, events_table.event_type
|
||||||
FROM
|
FROM
|
||||||
events_table
|
events_table
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
cte ON cte.user_id = events_table.user_id
|
cte ON cte.user_id = events_table.user_id
|
||||||
ORDER BY
|
ORDER BY
|
||||||
1,2,3
|
1,2,3
|
||||||
LIMIT
|
LIMIT
|
||||||
5;
|
5;
|
||||||
user_id | time | event_type
|
user_id | time | event_type
|
||||||
---------+---------------------------------+------------
|
---------+---------------------------------+------------
|
||||||
|
@ -221,12 +220,12 @@ WITH cte AS (
|
||||||
SELECT
|
SELECT
|
||||||
cte.user_id, cte.time, events_table.event_type
|
cte.user_id, cte.time, events_table.event_type
|
||||||
FROM
|
FROM
|
||||||
events_table
|
events_table
|
||||||
RIGHT JOIN
|
RIGHT JOIN
|
||||||
cte ON cte.user_id = events_table.user_id
|
cte ON cte.user_id = events_table.user_id
|
||||||
ORDER BY
|
ORDER BY
|
||||||
1,2,3
|
1,2,3
|
||||||
LIMIT
|
LIMIT
|
||||||
5;
|
5;
|
||||||
ERROR: cannot pushdown the subquery
|
ERROR: cannot pushdown the subquery
|
||||||
DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join
|
DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join
|
||||||
|
@ -237,12 +236,12 @@ WITH cte AS (
|
||||||
SELECT
|
SELECT
|
||||||
cte.user_id, cte.time, events_table.event_type
|
cte.user_id, cte.time, events_table.event_type
|
||||||
FROM
|
FROM
|
||||||
events_table
|
events_table
|
||||||
FULL JOIN
|
FULL JOIN
|
||||||
cte ON cte.user_id = events_table.user_id
|
cte ON cte.user_id = events_table.user_id
|
||||||
ORDER BY
|
ORDER BY
|
||||||
1,2,3
|
1,2,3
|
||||||
LIMIT
|
LIMIT
|
||||||
5;
|
5;
|
||||||
ERROR: cannot pushdown the subquery
|
ERROR: cannot pushdown the subquery
|
||||||
DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join
|
DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join
|
||||||
|
|
|
@ -42,9 +42,9 @@ WITH users_events AS (
|
||||||
WHERE
|
WHERE
|
||||||
u_events.user_id = events_table.user_id
|
u_events.user_id = events_table.user_id
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
users_events
|
users_events
|
||||||
ORDER BY
|
ORDER BY
|
||||||
1, 2
|
1, 2
|
||||||
|
@ -92,17 +92,16 @@ WITH users_events AS (
|
||||||
GROUP BY
|
GROUP BY
|
||||||
users_table.user_id,
|
users_table.user_id,
|
||||||
events_table.event_type
|
events_table.event_type
|
||||||
|
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
uid, event_type, value_2, value_3
|
uid, event_type, value_2, value_3
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
user_id as uid
|
user_id as uid
|
||||||
FROM
|
FROM
|
||||||
users_events
|
users_events
|
||||||
) users
|
) users
|
||||||
join
|
join
|
||||||
events_table
|
events_table
|
||||||
|
@ -110,45 +109,45 @@ WITH users_events AS (
|
||||||
users.uid = events_table.event_type
|
users.uid = events_table.event_type
|
||||||
) a
|
) a
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
users_events
|
users_events
|
||||||
ORDER BY
|
ORDER BY
|
||||||
1, 3, 2, 4
|
1, 3, 2, 4
|
||||||
LIMIT 100
|
LIMIT 100
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
users_events
|
users_events
|
||||||
LIMIT 90
|
LIMIT 90
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
users_events
|
users_events
|
||||||
LIMIT 50
|
LIMIT 50
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
uid, event_type, value_2, sum(value_3) as sum_3
|
uid, event_type, value_2, sum(value_3) as sum_3
|
||||||
FROM
|
FROM
|
||||||
users_events
|
users_events
|
||||||
GROUP BY
|
GROUP BY
|
||||||
1, 2, 3
|
1, 2, 3
|
||||||
LIMIT 40
|
LIMIT 40
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
uid, event_type, sum(value_2) as sum_2, sum(sum_3) as sum_3
|
uid, event_type, sum(value_2) as sum_2, sum(sum_3) as sum_3
|
||||||
FROM
|
FROM
|
||||||
users_events
|
users_events
|
||||||
GROUP BY
|
GROUP BY
|
||||||
1, 2
|
1, 2
|
||||||
LIMIT 30
|
LIMIT 30
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
uid, avg(event_type), sum(sum_2), sum(sum_3)
|
uid, avg(event_type), sum(sum_2), sum(sum_3)
|
||||||
FROM
|
FROM
|
||||||
users_events
|
users_events
|
||||||
GROUP BY
|
GROUP BY
|
||||||
1;
|
1;
|
||||||
|
@ -210,7 +209,7 @@ WITH users_events AS (
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
users_events_2_3
|
users_events_2_3
|
||||||
UNION
|
UNION
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
|
@ -221,8 +220,8 @@ WITH users_events AS (
|
||||||
FROM
|
FROM
|
||||||
merged_users
|
merged_users
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
users_events
|
users_events
|
||||||
ORDER BY
|
ORDER BY
|
||||||
|
@ -305,14 +304,14 @@ WITH users_events AS (
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
users_events_2_3
|
users_events_2_3
|
||||||
UNION
|
UNION
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
users_events_4
|
users_events_4
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
users_events
|
users_events
|
||||||
ORDER BY
|
ORDER BY
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue