Skip to content

Instantly share code, notes, and snippets.

@onderkalaci
Last active August 10, 2021 08:59
Show Gist options
  • Select an option

  • Save onderkalaci/7cc7ad098a0fc29cd8fc60217631df78 to your computer and use it in GitHub Desktop.

Select an option

Save onderkalaci/7cc7ad098a0fc29cd8fc60217631df78 to your computer and use it in GitHub Desktop.
CREATE TABLE collections_list (
key bigint,
ts timestamptz,
collection_id integer,
value numeric
) PARTITION BY LIST (collection_id );
CREATE TABLE collections_list_0
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 0 );
CREATE TABLE collections_list_1
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 1 );
CREATE TABLE collections_list_2
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 2 );
CREATE TABLE collections_list_3
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 3 );
CREATE TABLE collections_list_4
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 4 );
CREATE TABLE collections_list_5
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 5 );
CREATE TABLE collections_list_6
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 6 );
CREATE TABLE collections_list_7
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 7 );
CREATE TABLE collections_list_8
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 8 );
CREATE TABLE collections_list_9
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 9 );
CREATE TABLE collections_list_10
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 10 );
CREATE TABLE collections_list_11
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 11 );
CREATE TABLE collections_list_12
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 12 );
CREATE TABLE collections_list_13
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 13 );
CREATE TABLE collections_list_14
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 14 );
CREATE TABLE collections_list_15
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 15 );
CREATE TABLE collections_list_16
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 16 );
CREATE TABLE collections_list_17
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 17 );
CREATE TABLE collections_list_18
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 18 );
CREATE TABLE collections_list_19
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 19 );
CREATE TABLE collections_list_20
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 20 );
CREATE TABLE collections_list_21
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 21 );
CREATE TABLE collections_list_22
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 22 );
CREATE TABLE collections_list_23
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 23 );
CREATE TABLE collections_list_24
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 24 );
CREATE TABLE collections_list_25
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 25 );
CREATE TABLE collections_list_26
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 26 );
CREATE TABLE collections_list_27
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 27 );
CREATE TABLE collections_list_28
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 28 );
CREATE TABLE collections_list_29
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 29 );
CREATE TABLE collections_list_30
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 30 );
CREATE TABLE collections_list_31
PARTITION OF collections_list (key, ts, collection_id, value)
FOR VALUES IN ( 31 );
-- optional for Citus
SELECT create_distributed_table('collections_list', 'key');
INSERT INTO collections_list SELECT i, '2011-01-01', i % 32, i FROM generate_Series(0, 200000000)i ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment