Skip to content

Instantly share code, notes, and snippets.

@fj
Created October 5, 2017 17:52
Show Gist options
  • Save fj/c2dd12080078cd87a776dbc951288203 to your computer and use it in GitHub Desktop.
Save fj/c2dd12080078cd87a776dbc951288203 to your computer and use it in GitHub Desktop.
-- full-text search in JSON/JSONB columns
CREATE INDEX transactions_fts ON transactions
USING gin (( to_tsvector('english', transactions) ))
-- parallelism now supported or improved in:
-- * bitmap heap scans
-- * merge joins
-- * btree index scans
-- partitioning
CREATE TABLE integers (x INTEGER) PARTITION BY RANGE (x);
CREATE TABLE naturals PARTITION OF integers FOR VALUES FROM (0) TO (UNBOUNDED);
INSERT INTO integers VALUES (-500), (-123), (0), (123), (456);
SELECT * FROM naturals;
-- x
-- ----
-- 0
-- 123
-- 456
-- logical replication
-- on cluster one
CREATE PUBLICATION channel FOR TABLE jobs;
-- on cluster two
CREATE SUBSCRIPTION worker CONNECTION 'port=5432 dbname=worker_db' PUBLICATION channel;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment