This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SET citus.replication_model to statement ; | |
| set citus.shard_replication_factor TO 2; | |
| CREATE SCHEMA sc1; | |
| CREATE TABLE sc1.test (a int); | |
| SELECT create_distributed_table('sc1.test', 'a'); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE OR REPLACE PROCEDURE public.top_function() LANGUAGE PLPGSQL AS $procedure$ | |
| begin | |
| call second_function_that_fails(); | |
| EXCEPTION | |
| when others then | |
| RAISE NOTICE 'Top function exception handling'; | |
| call third_function_that_fails(); | |
| end; $procedure$; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| create or replace procedure top_function() | |
| language plpgsql | |
| as | |
| $$ | |
| begin | |
| RAISE NOTICE 'Top function is called'; | |
| call second_function(); | |
| EXCEPTION |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - many filters | |
| - Partitioned table | |
| - Prepared statements | |
| - weird data types | |
| - https://gist.github.com/onderkalaci/bf242c70aa0045496fd43d4949987034#file-unconventional_types-sql-L2 | |
| - Reference table | |
| - modify: update local FROM local Dist | |
| - weird target lists |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Create or replace function get_random_escape_char() returns char as | |
| $$ | |
| declare | |
| i integer:=(random() * 100)::int % 8; | |
| begin | |
| if i = 0 then | |
| return '\t'; | |
| elseif i = 1 then | |
| return '\n'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE users_table (user_id int, time timestamp, value_1 int, value_2 int, value_3 float, value_4 bigint); | |
| SELECT create_distributed_table('users_table', 'user_id'); | |
| INSERT INTO users_table | |
| SELECT i, | |
| now(), | |
| i, | |
| i, | |
| i, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE collections_list ( | |
| key bigint, | |
| ts timestamptz, | |
| collection_id integer, | |
| value numeric | |
| ) PARTITION BY LIST (collection_id ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT format('begin;create table foo_%1s(id serial primary key, data1 int, data2 text, data3 json); SELECT create_distributed_table(''foo_%1s'',''id'');commit;', g.i, g.i) FROM generate_series(1, 10) g(i) | |
| \gexec | |
| select ' select count(*) from users_table ' || string_Agg('INNER | |
| JOIN users_table u'|| x::text || ' USING (user_id)',' ') from | |
| generate_Series(1,25)x; | |
| \gexec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pg_config | |
| BINDIR = /Users/onderkalaci/Documents/citus_code/pgenv/pgsql-13.0/bin | |
| DOCDIR = /Users/onderkalaci/Documents/citus_code/pgenv/pgsql-13.0/share/doc | |
| HTMLDIR = /Users/onderkalaci/Documents/citus_code/pgenv/pgsql-13.0/share/doc | |
| INCLUDEDIR = /Users/onderkalaci/Documents/citus_code/pgenv/pgsql-13.0/include | |
| PKGINCLUDEDIR = /Users/onderkalaci/Documents/citus_code/pgenv/pgsql-13.0/include | |
| INCLUDEDIR-SERVER = /Users/onderkalaci/Documents/citus_code/pgenv/pgsql-13.0/include/server | |
| LIBDIR = /Users/onderkalaci/Documents/citus_code/pgenv/pgsql-13.0/lib | |
| PKGLIBDIR = /Users/onderkalaci/Documents/citus_code/pgenv/pgsql-13.0/lib | |
| LOCALEDIR = /Users/onderkalaci/Documents/citus_code/pgenv/pgsql-13.0/share/locale |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- find the PID of the process that is blocked, you can use pg_stat_activity or anything else | |
| -- we'll use PID in the next steps | |
| -- assume that we find it as 6939 | |
| -- the PID we have is running on docker | |
| -- now, find the corresponding PID of the process on the VM | |
| for i in $(ps -ef | grep `docker inspect --format '{{.State.Pid}}' PostgreSQLCitus` | awk '{print $2}') ; do grep NSpid: /proc/$i/status ; done | grep 6939 | |
| NSpid: 26857 6939 |