|
|
|
@ -0,0 +1,736 @@
|
|
|
|
|
--
|
|
|
|
|
-- MULTI_INSERT_SELECT
|
|
|
|
|
--
|
|
|
|
|
ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 13300000;
|
|
|
|
|
ALTER SEQUENCE pg_catalog.pg_dist_jobid_seq RESTART 13300000;
|
|
|
|
|
CREATE TABLE raw_events_first (user_id int, time timestamp, value_1 int, value_2 int, value_3 float, value_4 bigint, UNIQUE(user_id, value_1));
|
|
|
|
|
SELECT master_create_distributed_table('raw_events_first', 'user_id', 'hash');
|
|
|
|
|
master_create_distributed_table
|
|
|
|
|
---------------------------------
|
|
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
|
|
SELECT master_create_worker_shards('raw_events_first', 4, 2);
|
|
|
|
|
master_create_worker_shards
|
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
|
|
CREATE TABLE raw_events_second (user_id int, time timestamp, value_1 int, value_2 int, value_3 float, value_4 bigint, UNIQUE(user_id, value_1));
|
|
|
|
|
SELECT master_create_distributed_table('raw_events_second', 'user_id', 'hash');
|
|
|
|
|
master_create_distributed_table
|
|
|
|
|
---------------------------------
|
|
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
|
|
SELECT master_create_worker_shards('raw_events_second', 4, 2);
|
|
|
|
|
master_create_worker_shards
|
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
|
|
CREATE TABLE agg_events (user_id int, value_1_agg int, value_2_agg int, value_3_agg float, value_4_agg bigint, agg_time timestamp, UNIQUE(user_id, value_1_agg));
|
|
|
|
|
SELECT master_create_distributed_table('agg_events', 'user_id', 'hash');
|
|
|
|
|
master_create_distributed_table
|
|
|
|
|
---------------------------------
|
|
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
|
|
SELECT master_create_worker_shards('agg_events', 4, 2);
|
|
|
|
|
master_create_worker_shards
|
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
|
|
-- make tables as co-located
|
|
|
|
|
UPDATE pg_dist_partition SET colocationid = 100000 WHERE logicalrelid IN ('raw_events_first', 'raw_events_second', 'agg_events');
|
|
|
|
|
INSERT INTO raw_events_first (user_id, time, value_1, value_2, value_3, value_4) VALUES
|
|
|
|
|
(1, now(), 10, 100, 1000.1, 10000);
|
|
|
|
|
INSERT INTO raw_events_first (user_id, time, value_1, value_2, value_3, value_4) VALUES
|
|
|
|
|
(2, now(), 20, 200, 2000.1, 20000);
|
|
|
|
|
INSERT INTO raw_events_first (user_id, time, value_1, value_2, value_3, value_4) VALUES
|
|
|
|
|
(3, now(), 30, 300, 3000.1, 30000);
|
|
|
|
|
INSERT INTO raw_events_first (user_id, time, value_1, value_2, value_3, value_4) VALUES
|
|
|
|
|
(4, now(), 40, 400, 4000.1, 40000);
|
|
|
|
|
INSERT INTO raw_events_first (user_id, time, value_1, value_2, value_3, value_4) VALUES
|
|
|
|
|
(5, now(), 50, 500, 5000.1, 50000);
|
|
|
|
|
INSERT INTO raw_events_first (user_id, time, value_1, value_2, value_3, value_4) VALUES
|
|
|
|
|
(6, now(), 60, 600, 6000.1, 60000);
|
|
|
|
|
SET client_min_messages TO DEBUG4;
|
|
|
|
|
DEBUG: CommitTransactionCommand
|
|
|
|
|
DEBUG: CommitTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
-- raw table to raw table
|
|
|
|
|
INSERT INTO raw_events_second SELECT * FROM raw_events_first;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300004 AS citus_table_alias (user_id, "time", value_1, value_2, value_3, value_4) SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.raw_events_first_13300000 raw_events_first
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300005 AS citus_table_alias (user_id, "time", value_1, value_2, value_3, value_4) SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.raw_events_first_13300001 raw_events_first
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300006 AS citus_table_alias (user_id, "time", value_1, value_2, value_3, value_4) SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.raw_events_first_13300002 raw_events_first
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300007 AS citus_table_alias (user_id, "time", value_1, value_2, value_3, value_4) SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.raw_events_first_13300003 raw_events_first
|
|
|
|
|
DEBUG: ProcessQuery
|
|
|
|
|
DEBUG: Plan is router executable
|
|
|
|
|
DEBUG: CommitTransactionCommand
|
|
|
|
|
DEBUG: CommitTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300007
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300007
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300005
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300005
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300006
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300006
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300004
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300004
|
|
|
|
|
-- see that our first multi shard INSERT...SELECT works expected
|
|
|
|
|
SET client_min_messages TO INFO;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: ProcessUtility
|
|
|
|
|
SELECT
|
|
|
|
|
raw_events_first.user_id
|
|
|
|
|
FROM
|
|
|
|
|
raw_events_first, raw_events_second
|
|
|
|
|
WHERE
|
|
|
|
|
raw_events_first.user_id = raw_events_second.user_id;
|
|
|
|
|
user_id
|
|
|
|
|
---------
|
|
|
|
|
1
|
|
|
|
|
5
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
|
|
6
|
|
|
|
|
2
|
|
|
|
|
(6 rows)
|
|
|
|
|
|
|
|
|
|
-- see that we get unique vialitons
|
|
|
|
|
INSERT INTO raw_events_second SELECT * FROM raw_events_first;
|
|
|
|
|
ERROR: duplicate key value violates unique constraint "raw_events_second_user_id_value_1_key_13300004"
|
|
|
|
|
DETAIL: Key (user_id, value_1)=(1, 10) already exists.
|
|
|
|
|
CONTEXT: while executing command on localhost:57638
|
|
|
|
|
-- add one more row
|
|
|
|
|
INSERT INTO raw_events_first (user_id, time) VALUES
|
|
|
|
|
(7, now());
|
|
|
|
|
-- try a single shard query
|
|
|
|
|
SET client_min_messages TO DEBUG4;
|
|
|
|
|
DEBUG: CommitTransactionCommand
|
|
|
|
|
DEBUG: CommitTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
INSERT INTO raw_events_second (user_id, time) SELECT user_id, time FROM raw_events_first WHERE user_id = 7;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: skipping the task
|
|
|
|
|
DETAIL: Insert query hits 2 placements, Select query hits 1 placements and only 1 of those placements match.
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300005 AS citus_table_alias (user_id, "time") SELECT user_id, "time" FROM public.raw_events_first_13300001 raw_events_first WHERE (user_id = 7)
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: skipping the task
|
|
|
|
|
DETAIL: Insert query hits 2 placements, Select query hits 1 placements and only 1 of those placements match.
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: skipping the task
|
|
|
|
|
DETAIL: Insert query hits 2 placements, Select query hits 1 placements and only 1 of those placements match.
|
|
|
|
|
DEBUG: ProcessQuery
|
|
|
|
|
DEBUG: Plan is router executable
|
|
|
|
|
DEBUG: CommitTransactionCommand
|
|
|
|
|
DEBUG: CommitTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
SET client_min_messages TO INFO;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: ProcessUtility
|
|
|
|
|
-- add one more row
|
|
|
|
|
INSERT INTO raw_events_first (user_id, time, value_1, value_2, value_3, value_4) VALUES
|
|
|
|
|
(8, now(), 80, 800, 8000, 80000);
|
|
|
|
|
-- reorder columns
|
|
|
|
|
SET client_min_messages TO DEBUG4;
|
|
|
|
|
DEBUG: CommitTransactionCommand
|
|
|
|
|
DEBUG: CommitTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
INSERT INTO raw_events_second (value_2, value_1, value_3, value_4, user_id, time)
|
|
|
|
|
SELECT
|
|
|
|
|
value_2, value_1, value_3, value_4, user_id, time
|
|
|
|
|
FROM
|
|
|
|
|
raw_events_first
|
|
|
|
|
WHERE
|
|
|
|
|
user_id = 8;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300004 AS citus_table_alias (user_id, "time", value_1, value_2, value_3, value_4) SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.raw_events_first_13300000 raw_events_first WHERE (user_id = 8)
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: skipping the task
|
|
|
|
|
DETAIL: Insert query hits 2 placements, Select query hits 1 placements and only 1 of those placements match.
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: skipping the task
|
|
|
|
|
DETAIL: Insert query hits 2 placements, Select query hits 1 placements and only 1 of those placements match.
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: skipping the task
|
|
|
|
|
DETAIL: Insert query hits 2 placements, Select query hits 1 placements and only 1 of those placements match.
|
|
|
|
|
DEBUG: ProcessQuery
|
|
|
|
|
DEBUG: Plan is router executable
|
|
|
|
|
DEBUG: CommitTransactionCommand
|
|
|
|
|
DEBUG: CommitTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
-- add one more row
|
|
|
|
|
SET client_min_messages TO INFO;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: ProcessUtility
|
|
|
|
|
INSERT INTO raw_events_first (user_id, time, value_1, value_2, value_3, value_4) VALUES
|
|
|
|
|
(9, now(), 90, 900, 9000, 90000);
|
|
|
|
|
-- show that RETURNING also works
|
|
|
|
|
SET client_min_messages TO DEBUG4;
|
|
|
|
|
DEBUG: CommitTransactionCommand
|
|
|
|
|
DEBUG: CommitTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
INSERT INTO raw_events_second (user_id, value_1, value_3)
|
|
|
|
|
SELECT
|
|
|
|
|
user_id, value_1, value_3
|
|
|
|
|
FROM
|
|
|
|
|
raw_events_first
|
|
|
|
|
WHERE
|
|
|
|
|
value_3 = 9000
|
|
|
|
|
RETURNING *;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
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 = (9000)::double precision) 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: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
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 = (9000)::double precision) 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: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300006 AS citus_table_alias (user_id, value_1, value_3) SELECT user_id, value_1, value_3 FROM public.raw_events_first_13300002 raw_events_first WHERE (value_3 = (9000)::double precision) 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: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300007 AS citus_table_alias (user_id, value_1, value_3) SELECT user_id, value_1, value_3 FROM public.raw_events_first_13300003 raw_events_first WHERE (value_3 = (9000)::double precision) 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: ProcessQuery
|
|
|
|
|
DEBUG: Plan is router executable
|
|
|
|
|
DEBUG: CommitTransactionCommand
|
|
|
|
|
DEBUG: CommitTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300007
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300007
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300005
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300005
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300006
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300006
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300004
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300004
|
|
|
|
|
user_id | time | value_1 | value_2 | value_3 | value_4
|
|
|
|
|
---------+------+---------+---------+---------+---------
|
|
|
|
|
9 | | 90 | | 9000 |
|
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
|
|
-- hits two shards
|
|
|
|
|
INSERT INTO raw_events_second (user_id, value_1, value_3)
|
|
|
|
|
SELECT
|
|
|
|
|
user_id, value_1, value_3
|
|
|
|
|
FROM
|
|
|
|
|
raw_events_first
|
|
|
|
|
WHERE
|
|
|
|
|
user_id = 9 OR user_id = 16
|
|
|
|
|
RETURNING *;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: skipping the task
|
|
|
|
|
DETAIL: Insert query hits 2 placements, Select query hits 1 placements and only 1 of those placements match.
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
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 = 9) OR (user_id = 16)) 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: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: skipping the task
|
|
|
|
|
DETAIL: Insert query hits 2 placements, Select query hits 1 placements and only 1 of those placements match.
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300007 AS citus_table_alias (user_id, value_1, value_3) SELECT user_id, value_1, value_3 FROM public.raw_events_first_13300003 raw_events_first WHERE ((user_id = 9) OR (user_id = 16)) 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: ProcessQuery
|
|
|
|
|
DEBUG: Plan is router executable
|
|
|
|
|
ERROR: duplicate key value violates unique constraint "raw_events_second_user_id_value_1_key_13300007"
|
|
|
|
|
DETAIL: Key (user_id, value_1)=(9, 90) already exists.
|
|
|
|
|
CONTEXT: while executing command on localhost:57637
|
|
|
|
|
-- now do some aggregations
|
|
|
|
|
INSERT INTO agg_events
|
|
|
|
|
SELECT
|
|
|
|
|
user_id, sum(value_1), avg(value_2), sum(value_3), count(value_4)
|
|
|
|
|
FROM
|
|
|
|
|
raw_events_first
|
|
|
|
|
GROUP BY
|
|
|
|
|
user_id;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 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_13300000 raw_events_first GROUP BY user_id
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 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_13300001 raw_events_first GROUP BY user_id
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 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_13300002 raw_events_first GROUP BY user_id
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
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 GROUP BY user_id
|
|
|
|
|
DEBUG: ProcessQuery
|
|
|
|
|
DEBUG: Plan is router executable
|
|
|
|
|
DEBUG: CommitTransactionCommand
|
|
|
|
|
DEBUG: CommitTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300008
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300008
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300011
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300011
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300009
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300009
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300010
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300010
|
|
|
|
|
-- group by column not exists on the SELECT target list
|
|
|
|
|
-- TODO: there is a bug on RETURNING
|
|
|
|
|
INSERT INTO agg_events (value_3_agg, value_4_agg, value_1_agg, user_id)
|
|
|
|
|
SELECT
|
|
|
|
|
sum(value_3), count(value_4), sum(value_1), user_id
|
|
|
|
|
FROM
|
|
|
|
|
raw_events_first
|
|
|
|
|
GROUP BY
|
|
|
|
|
value_2, user_id
|
|
|
|
|
RETURNING *;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS citus_table_alias (user_id, value_1_agg, value_3_agg, value_4_agg) SELECT user_id, sum(value_1) AS sum, sum(value_3) AS sum, count(value_4) AS count FROM public.raw_events_first_13300000 raw_events_first GROUP BY value_2, user_id RETURNING citus_table_alias.user_id, citus_table_alias.value_1_agg, citus_table_alias.value_2_agg, citus_table_alias.value_3_agg, citus_table_alias.value_4_agg, citus_table_alias.agg_time
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS citus_table_alias (user_id, value_1_agg, value_3_agg, value_4_agg) SELECT user_id, sum(value_1) AS sum, sum(value_3) AS sum, count(value_4) AS count FROM public.raw_events_first_13300001 raw_events_first GROUP BY value_2, user_id RETURNING citus_table_alias.user_id, citus_table_alias.value_1_agg, citus_table_alias.value_2_agg, citus_table_alias.value_3_agg, citus_table_alias.value_4_agg, citus_table_alias.agg_time
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id, value_1_agg, value_3_agg, value_4_agg) SELECT user_id, sum(value_1) AS sum, sum(value_3) AS sum, count(value_4) AS count FROM public.raw_events_first_13300002 raw_events_first GROUP BY value_2, user_id RETURNING citus_table_alias.user_id, citus_table_alias.value_1_agg, citus_table_alias.value_2_agg, citus_table_alias.value_3_agg, citus_table_alias.value_4_agg, citus_table_alias.agg_time
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id, value_1_agg, value_3_agg, value_4_agg) SELECT user_id, sum(value_1) AS sum, sum(value_3) AS sum, count(value_4) AS count FROM public.raw_events_first_13300003 raw_events_first GROUP BY value_2, user_id RETURNING citus_table_alias.user_id, citus_table_alias.value_1_agg, citus_table_alias.value_2_agg, citus_table_alias.value_3_agg, citus_table_alias.value_4_agg, citus_table_alias.agg_time
|
|
|
|
|
DEBUG: ProcessQuery
|
|
|
|
|
DEBUG: Plan is router executable
|
|
|
|
|
ERROR: duplicate key value violates unique constraint "agg_events_user_id_value_1_agg_key_13300008"
|
|
|
|
|
DETAIL: Key (user_id, value_1_agg)=(8, 80) already exists.
|
|
|
|
|
CONTEXT: while executing command on localhost:57638
|
|
|
|
|
-- some subquery tests
|
|
|
|
|
INSERT INTO agg_events
|
|
|
|
|
(value_1_agg,
|
|
|
|
|
user_id)
|
|
|
|
|
SELECT SUM(value_1),
|
|
|
|
|
id
|
|
|
|
|
FROM (SELECT raw_events_second.user_id AS id,
|
|
|
|
|
raw_events_second.value_1
|
|
|
|
|
FROM raw_events_first,
|
|
|
|
|
raw_events_second
|
|
|
|
|
WHERE raw_events_first.user_id = raw_events_second.user_id) AS foo
|
|
|
|
|
GROUP BY id;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300005
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300006
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300007
|
|
|
|
|
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 = raw_events_second.user_id)) foo GROUP BY id
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300004
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300006
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300007
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 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_13300001 raw_events_first, public.raw_events_second_13300005 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id)) foo GROUP BY id
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300004
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300005
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300007
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 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_13300002 raw_events_first, public.raw_events_second_13300006 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id)) foo GROUP BY id
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300004
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300005
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300006
|
|
|
|
|
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 = raw_events_second.user_id)) foo GROUP BY id
|
|
|
|
|
DEBUG: ProcessQuery
|
|
|
|
|
DEBUG: Plan is router executable
|
|
|
|
|
ERROR: duplicate key value violates unique constraint "agg_events_user_id_value_1_agg_key_13300008"
|
|
|
|
|
DETAIL: Key (user_id, value_1_agg)=(1, 10) already exists.
|
|
|
|
|
CONTEXT: while executing command on localhost:57638
|
|
|
|
|
-- subquery one more level depth
|
|
|
|
|
INSERT INTO agg_events
|
|
|
|
|
(value_4_agg,
|
|
|
|
|
value_1_agg,
|
|
|
|
|
user_id)
|
|
|
|
|
SELECT v4,
|
|
|
|
|
v1,
|
|
|
|
|
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 raw_events_first,
|
|
|
|
|
raw_events_second
|
|
|
|
|
WHERE raw_events_first.user_id = raw_events_second.user_id
|
|
|
|
|
GROUP BY raw_events_second.user_id) AS foo;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300005
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300006
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300007
|
|
|
|
|
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 = raw_events_second.user_id) GROUP BY raw_events_second.user_id) foo
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300004
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300006
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300007
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 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_13300001 raw_events_first, public.raw_events_second_13300005 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id) GROUP BY raw_events_second.user_id) foo
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300004
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300005
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300007
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 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_13300002 raw_events_first, public.raw_events_second_13300006 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id) GROUP BY raw_events_second.user_id) foo
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300004
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300005
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300006
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 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_13300003 raw_events_first, public.raw_events_second_13300007 raw_events_second WHERE (raw_events_first.user_id = raw_events_second.user_id) GROUP BY raw_events_second.user_id) foo
|
|
|
|
|
DEBUG: ProcessQuery
|
|
|
|
|
DEBUG: Plan is router executable
|
|
|
|
|
ERROR: duplicate key value violates unique constraint "agg_events_user_id_value_1_agg_key_13300008"
|
|
|
|
|
DETAIL: Key (user_id, value_1_agg)=(1, 10) already exists.
|
|
|
|
|
CONTEXT: while executing command on localhost:57638
|
|
|
|
|
-- some UPSERTS
|
|
|
|
|
INSERT INTO agg_events AS ae
|
|
|
|
|
(
|
|
|
|
|
user_id,
|
|
|
|
|
value_1_agg,
|
|
|
|
|
agg_time
|
|
|
|
|
)
|
|
|
|
|
SELECT user_id,
|
|
|
|
|
value_1,
|
|
|
|
|
time
|
|
|
|
|
FROM raw_events_first
|
|
|
|
|
ON conflict (user_id, value_1_agg)
|
|
|
|
|
DO UPDATE
|
|
|
|
|
SET agg_time = EXCLUDED.agg_time
|
|
|
|
|
WHERE ae.agg_time < EXCLUDED.agg_time;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
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 ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time < excluded.agg_time)
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
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 ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time < excluded.agg_time)
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS ae (user_id, value_1_agg, agg_time) SELECT user_id, value_1, "time" FROM public.raw_events_first_13300002 raw_events_first ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time < excluded.agg_time)
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
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 ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time < excluded.agg_time)
|
|
|
|
|
DEBUG: ProcessQuery
|
|
|
|
|
DEBUG: Plan is router executable
|
|
|
|
|
DEBUG: CommitTransactionCommand
|
|
|
|
|
DEBUG: CommitTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300008
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300008
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300011
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300011
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300009
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300009
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300010
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300010
|
|
|
|
|
-- upserts with returning
|
|
|
|
|
INSERT INTO agg_events AS ae
|
|
|
|
|
(
|
|
|
|
|
user_id,
|
|
|
|
|
value_1_agg,
|
|
|
|
|
agg_time
|
|
|
|
|
)
|
|
|
|
|
SELECT user_id,
|
|
|
|
|
value_1,
|
|
|
|
|
time
|
|
|
|
|
FROM raw_events_first
|
|
|
|
|
ON conflict (user_id, value_1_agg)
|
|
|
|
|
DO UPDATE
|
|
|
|
|
SET agg_time = EXCLUDED.agg_time
|
|
|
|
|
WHERE ae.agg_time < EXCLUDED.agg_time
|
|
|
|
|
RETURNING user_id, value_1_agg;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
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 ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time < excluded.agg_time) RETURNING ae.user_id, ae.value_1_agg
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
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 ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time < excluded.agg_time) RETURNING ae.user_id, ae.value_1_agg
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS ae (user_id, value_1_agg, agg_time) SELECT user_id, value_1, "time" FROM public.raw_events_first_13300002 raw_events_first ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time < excluded.agg_time) RETURNING ae.user_id, ae.value_1_agg
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
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 ON CONFLICT(user_id, value_1_agg) DO UPDATE SET agg_time = excluded.agg_time WHERE (ae.agg_time < excluded.agg_time) RETURNING ae.user_id, ae.value_1_agg
|
|
|
|
|
DEBUG: ProcessQuery
|
|
|
|
|
DEBUG: Plan is router executable
|
|
|
|
|
DEBUG: CommitTransactionCommand
|
|
|
|
|
DEBUG: CommitTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300008
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300008
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300011
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300011
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300009
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300009
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300010
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300010
|
|
|
|
|
user_id | value_1_agg
|
|
|
|
|
---------+-------------
|
|
|
|
|
7 |
|
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
|
|
-- TODO:: add hll and date_trunc
|
|
|
|
|
INSERT INTO agg_events (user_id, value_1_agg)
|
|
|
|
|
SELECT
|
|
|
|
|
user_id, sum(value_1 + value_2)
|
|
|
|
|
FROM
|
|
|
|
|
raw_events_first GROUP BY user_id;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS citus_table_alias (user_id, value_1_agg) SELECT user_id, sum((value_1 + value_2)) AS sum FROM public.raw_events_first_13300000 raw_events_first GROUP BY user_id
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS citus_table_alias (user_id, value_1_agg) SELECT user_id, sum((value_1 + value_2)) AS sum FROM public.raw_events_first_13300001 raw_events_first GROUP BY user_id
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id, value_1_agg) SELECT user_id, sum((value_1 + value_2)) AS sum FROM public.raw_events_first_13300002 raw_events_first GROUP BY user_id
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id, value_1_agg) SELECT user_id, sum((value_1 + value_2)) AS sum FROM public.raw_events_first_13300003 raw_events_first GROUP BY user_id
|
|
|
|
|
DEBUG: ProcessQuery
|
|
|
|
|
DEBUG: Plan is router executable
|
|
|
|
|
DEBUG: CommitTransactionCommand
|
|
|
|
|
DEBUG: CommitTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300008
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300008
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300011
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300011
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300009
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300009
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300010
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300010
|
|
|
|
|
-- FILTER CLAUSE
|
|
|
|
|
INSERT INTO agg_events (user_id, value_1_agg)
|
|
|
|
|
SELECT
|
|
|
|
|
user_id, sum(value_1 + value_2) FILTER (where value_3 = 15)
|
|
|
|
|
FROM
|
|
|
|
|
raw_events_first GROUP BY user_id;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS citus_table_alias (user_id, value_1_agg) SELECT user_id, sum((value_1 + value_2)) FILTER (WHERE (value_3 = (15)::double precision)) AS sum FROM public.raw_events_first_13300000 raw_events_first GROUP BY user_id
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS citus_table_alias (user_id, value_1_agg) SELECT user_id, sum((value_1 + value_2)) FILTER (WHERE (value_3 = (15)::double precision)) AS sum FROM public.raw_events_first_13300001 raw_events_first GROUP BY user_id
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id, value_1_agg) SELECT user_id, sum((value_1 + value_2)) FILTER (WHERE (value_3 = (15)::double precision)) AS sum FROM public.raw_events_first_13300002 raw_events_first GROUP BY user_id
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300000
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id, value_1_agg) SELECT user_id, sum((value_1 + value_2)) FILTER (WHERE (value_3 = (15)::double precision)) AS sum FROM public.raw_events_first_13300003 raw_events_first GROUP BY user_id
|
|
|
|
|
DEBUG: ProcessQuery
|
|
|
|
|
DEBUG: Plan is router executable
|
|
|
|
|
DEBUG: CommitTransactionCommand
|
|
|
|
|
DEBUG: CommitTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300008
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300008
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300011
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300011
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300009
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300009
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300010
|
|
|
|
|
DEBUG: sent COMMIT over connection 13300010
|
|
|
|
|
-- TODO: UUIDs
|
|
|
|
|
-- unsupported JOIN
|
|
|
|
|
INSERT INTO agg_events
|
|
|
|
|
(value_4_agg,
|
|
|
|
|
value_1_agg,
|
|
|
|
|
user_id)
|
|
|
|
|
SELECT v4,
|
|
|
|
|
v1,
|
|
|
|
|
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 raw_events_first,
|
|
|
|
|
raw_events_second
|
|
|
|
|
WHERE raw_events_first.user_id != raw_events_second.user_id
|
|
|
|
|
GROUP BY raw_events_second.user_id) AS foo;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300001
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300002
|
|
|
|
|
DEBUG: predicate pruning for shardId 13300003
|
|
|
|
|
ERROR: cannot perform distributed planning for the given modification
|
|
|
|
|
DETAIL: Select query cannot be pushed down to the worker.
|
|
|
|
|
-- INSERT partition column does not match with SELECT partition column
|
|
|
|
|
INSERT INTO agg_events
|
|
|
|
|
(value_4_agg,
|
|
|
|
|
value_1_agg,
|
|
|
|
|
user_id)
|
|
|
|
|
SELECT v4,
|
|
|
|
|
v1,
|
|
|
|
|
id
|
|
|
|
|
FROM (SELECT SUM(raw_events_second.value_4) AS v4,
|
|
|
|
|
SUM(raw_events_first.value_1) AS v1,
|
|
|
|
|
raw_events_second.value_3 AS id
|
|
|
|
|
FROM raw_events_first,
|
|
|
|
|
raw_events_second
|
|
|
|
|
WHERE raw_events_first.user_id = raw_events_second.user_id
|
|
|
|
|
GROUP BY raw_events_second.value_3) AS foo;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
ERROR: SELECT query should return bare partition column on the same ordinal position with INSERT query's partition column
|
|
|
|
|
-- error cases
|
|
|
|
|
-- no part column at all
|
|
|
|
|
INSERT INTO raw_events_second (value_1) SELECT value_1 FROM raw_events_first;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
ERROR: SELECT query should return bare partition column on the same ordinal position with INSERT query's partition column
|
|
|
|
|
INSERT INTO raw_events_second (value_1) SELECT user_id FROM raw_events_first;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
ERROR: SELECT query should return bare partition column on the same ordinal position with INSERT query's partition column
|
|
|
|
|
INSERT INTO raw_events_second (user_id) SELECT value_1 FROM raw_events_first;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
ERROR: SELECT query should return bare partition column on the same ordinal position with INSERT query's partition column
|
|
|
|
|
INSERT INTO raw_events_second (user_id) SELECT user_id * 2 FROM raw_events_first;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
ERROR: SELECT query should return bare partition column on the same ordinal position with INSERT query's partition column
|
|
|
|
|
INSERT INTO raw_events_second (user_id) SELECT user_id::bigint FROM raw_events_first;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
ERROR: SELECT query should return bare partition column on the same ordinal position with INSERT query's partition column
|
|
|
|
|
INSERT INTO agg_events (value_3_agg, value_4_agg, value_1_agg, value_2_agg, user_id) SELECT sum(value_3), count(value_4), user_id, sum(value_1), avg(value_2) FROM raw_events_first GROUP BY user_id;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
ERROR: SELECT query should return bare partition column on the same ordinal position with INSERT query's partition column
|
|
|
|
|
INSERT INTO agg_events (value_3_agg, value_4_agg, value_1_agg, value_2_agg, user_id) SELECT sum(value_3), count(value_4), user_id, sum(value_1), value_2 FROM raw_events_first GROUP BY user_id, value_2;
|
|
|
|
|
DEBUG: StartTransactionCommand
|
|
|
|
|
DEBUG: StartTransaction
|
|
|
|
|
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
|
|
|
|
|
ERROR: SELECT query should return bare partition column on the same ordinal position with INSERT query's partition column
|