SlideShare a Scribd company logo
An Evening with PostgreSQL 
Command Prompt, Inc.
Who Am I 
● @linuxhiker 
● +JoshuaDrakeLinuxHiker 
● jd@commandprompt.com 
● Lead Consultant – Command Prompt, Inc. 
● Director – Software in the Public Interest 
● President – United States PostgreSQL
Rated: Pg-13 
● I do this for fun. This is not my day job. 
● East Coast from the West Coast 
● Your ego is not my concern 
● To to take offense is to not be comfortable in oneself. 
● Hopefully you laugh and learn
Help control license costs 
If you are selling licenses to software, you are 
not helping control license costs.
Proactive SLA 
● Remote DBA / Sysadmin 
● Proactive Response 
● 4 Hours of DBA (minimum) 
● SLA / 24x7 / 365 
● No Emergency/After Hours rates 
● Flat, discounted rate 
From 1350.00/mo
What are we talking about 
● What is PostgreSQL? 
● Community Structure 
● Comparison to other databases 
● Awesome PostgreSQL stuff + 9.4 features 
● WTH were they thinking! 
● Guaranteed not to be in order
What is PostgreSQL? 
● The oldest of the open source databases (derived from 
University Ingres 1974) 
● The most advanced Open Source (possibly of closed 
too) database 
● A full ACID compliant, relational, object-relational, 
document, modern, scalable database.
Community Structure 
● Everyone Welcome 
● Meritocracy 
● INTL: Postgresql.org 
● Japan: Postgresql.jp 
● EU: Postgresql.eu 
● US: Postgresql.us 
● Smaller ones (Brazil, France, Italy)
Comparison to other databases 
● Licensing 
● Community 
● No single point of failure 
● Feature parity with all databases, more 
advanced than some 
● Best of both worlds, relational or document
Licensing 
BSD not GPL 
● Important for commercial providers
Community 
● Large 
● Vibrant 
● Active 
● All walks of life 
● Driven by the ecosystem, not a company
No single point of failure 
● Can not be bought 
● Can not go out of business 
● Can not be co-opted 
● Many known and qualified support/services 
companies (CMD, PgExperts, OmniTI, 
BullInfoSys, Consistent State, 2nd Quadrant)
Feature Parity 
● We have reached a point of... oh PostgreSQL 
● Like MSSQL, Oracle, Sybase, just another SQL 
database but with neat stuff 
● No longer a fringe product (thanks to Oracle)
Standard Features 
● SQL Compliance 
● Partitioning 
● Replication 
● Tablespaces 
● ACID
AWESOME Stuff 
BEGIN; 
ALTER TABLE foo ADD COLUMN bar text; 
d foo 
COMMIT/ROLLBACK; 
(Mysql can't do this)
Craziness 
BEGIN; 
CREATE TABLE foo (id serial, test text); 
CREATE TABLE bar (a foo); 
insert into bar values (row(1,'this is a test')); 
postgres=# select * from bar; 
a 
---------------------- 
(1,"this is a test") 
– Say what?
It gets better 
postgres=# select (a).id from bar; 
id 
---- 
1
Wooohaa! 
postgres=# select 
row_to_json(row((a).id),true) from bar; 
row_to_json 
------------- 
{"f1":1}
Enough of that, let's talk 9.4 
● JSONB 
● Logical Decoding (Including Logical 
Replication) 
● BDR 
● Wal Bouncer 
● Other 9.4 stuff
JSON 
● Added in 9.2 
● Input is validated 
● Stored as text representation 
– Slower on retrieval due to per row parse (per value?) 
● Preserves key order and duplicates 
● Mature support in 9.3 
– Better Functions 
– Operators 
● Advanced support in 9.4 
– Type building functions 
● About 15% storage overhead 
● Expression only indexes (WHERE foo)
When to use JSON 
● Document storage 
● Duplicate preservation 
● Key order preservation
JSONB 
● 9.4+ 
● Full JSON Implementation 
● Stored as binary (unlike JSON) 
● Works with all JSON operators 
● HSTORE-style query operators 
● No key order 
● No duplicate preservation 
● Faster access 
● GIN Indexing (and expression), for containment ops use json_path_ops 
● About 35% storage overhead 
● Much faster than JSON for retrieval (slower than HSTORE)
JSONB Features 
● Equality operator 
– SELECT '{“a”: 1, “b”: 2}'::jsonb = '{“b”:2, “a”:1}'::jsonb 
● Containment operator (Softserve) 
– SELECT '{“a”: 1, “b”: 2}'::jsonb @> {“b”:2}::jsonb 
● Existence 
– SELECT '{“a”: 1, “b”: 2}'::jsonb ? 'b'; 
● Nested operators (softserve works as well) 
– SELECT '{“a”: [1,2]}'::jsonb = '{“a”:[1,2]}'::jsonb 
● Existence (any) - ?| 
● Existence (all) - ?&
JSON/JSBON thanks 
Information retrieved from PDXPUG day in 
2014 via David Wheeler 
● http://vimeo.com/105491487
Logical Decoding 
PostgreSQL provides infrastructure to stream the modifications 
performed via SQL to external consumers. 
The format in which those changes are streamed is determined by 
the output plugin used. 
Every output plugin has access to each individual new row produced 
by INSERT and the new row version created by UPDATE. Availability 
of old row versions for UPDATE and DELETE depends on the 
configured REPLICA IDENTITY. 
It is also possible to write additional methods of consuming the 
output of a replication slot without modifying core code. 
(http://www.postgresql.org/docs/9.4/static/logicaldecoding.html)
What does Logical Decoding Mean? 
● You now have backend access to 
INSERT/UPDATE/DELETE mechanisms. 
● Is used to implement new features such as: 
– BDR: https://wiki.postgresql.org/wiki/BDR_User_Guide 
– Auditing 
– Walbouncer: 
http://www.cybertec.at/en/products/walbouncer-enterprise-grade- 
partial-replication/
BDR 
● Multi-Master without triggers! (Sorry Bucardo) 
● Uses LLSR (From Logical Decoding) 
● Supports distributed Sequences 
● Supports synchronisation functions 
● Supports conflict handlers 
● Highly performant 
● Eventually consistent 
● Up to 48 nodes
WalBouncer 
● Requires 9.4 
● Allows partial replication to remote replicas 
– Each replica can have a different data set 
● Filters based on WAL 
● Single master to many slave 
● Can be disconcerting to the novice 
● http://www.cybertec.at/postgresql_produkte/walbouncer/
Other 9.4 Stuff 
● GIN indexes now faster and smaller 
● pg_prewarm 
● ALTER SYSTEM 
● Concurrent materialized view refresh 
● Update Views with different columns
ALTER SYSTEM 
● Commands such as: 
– ALTER SYSTEM SET log_min_duration_statement 
= '5s'; 
Are now saved to postgresql.auto.conf which is 
always read last and saved between restarts.
Better updateable views 
CREATE TABLE products ( 
product_id SERIAL PRIMARY KEY, 
product_name TEXT NOT NULL, 
quantity INT, 
reserved INT DEFAULT 0); 
CREATE VIEW products_view AS 
SELECT product_id, 
product_name, 
quantity, 
(quantity - reserved) AS available 
FROM products 
WHERE quantity IS NOT NULL;
Views Continued 
postgres=# INSERT INTO products_view (product_name, quantity) VALUES 
('Budget laptop', 100), 
('Premium laptop', 10); 
INSERT 0 2 
postgres=# SELECT * FROM products; 
product_id | product_name | quantity | reserved 
------------+----------------+----------+---------- 
1 | Budget laptop | 100 | 0 
2 | Premium laptop | 10 | 0 
(2 rows)
Donate 
http://www.postgresql.org/about/donate
Questions? 
● Political 
● Community 
● Technical 
● Why the hell not?

More Related Content

PDF
Shaping Optimizer's Search Space
Gerger
 
PPTX
SQL Server In-Memory OLTP Case Studies
josdebruijn
 
PDF
High performance json- postgre sql vs. mongodb
Wei Shan Ang
 
PDF
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
Wei Shan Ang
 
PDF
Virtualizing Development
Adam Culp
 
PDF
Brief introduction to kselftest
SeongJae Park
 
PDF
PostgreSQL Write-Ahead Log (Heikki Linnakangas)
Ontico
 
PPTX
Streaming Replication Made Easy in v9.3
Sameer Kumar
 
Shaping Optimizer's Search Space
Gerger
 
SQL Server In-Memory OLTP Case Studies
josdebruijn
 
High performance json- postgre sql vs. mongodb
Wei Shan Ang
 
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
Wei Shan Ang
 
Virtualizing Development
Adam Culp
 
Brief introduction to kselftest
SeongJae Park
 
PostgreSQL Write-Ahead Log (Heikki Linnakangas)
Ontico
 
Streaming Replication Made Easy in v9.3
Sameer Kumar
 

What's hot (19)

PDF
Gdb basics for my sql db as (percona live europe 2019)
Valerii Kravchuk
 
PPT
A brief introduction to PostgreSQL
Vu Hung Nguyen
 
PPTX
High availability for puppet - 2016
Zack Smith
 
PDF
MySQL Multi-Source Replication for PL2016
Wagner Bianchi
 
PDF
Tracing and profiling my sql (percona live europe 2019) draft_1
Valerii Kravchuk
 
PDF
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Ortus Solutions, Corp
 
PDF
Lock free programming- pro tips
Jean-Philippe BEMPEL
 
PDF
MySQL Replication Troubleshooting for Oracle DBAs
Sveta Smirnova
 
PDF
Do it Yourself Testing
Emily Stolfo
 
PPTX
How go makes us faster (May 2015)
Wilfried Schobeiri
 
PDF
FOSDEM 2015: gdb tips and tricks for MySQL DBAs
Valerii Kravchuk
 
PPT
Understanding MySQL Performance through Benchmarking
Laine Campbell
 
PDF
PostgreSQL Monitoring using modern software stacks
Showmax Engineering
 
PDF
LAS16-307: Benchmarking Schedutil in Android
Linaro
 
ODP
Rex - Lightning Talk yapc.eu 2013
Jan Gehring
 
PDF
Lessons Learned: Troubleshooting Replication
Sveta Smirnova
 
PDF
Daniel Sloof: Magento on HHVM
Meet Magento Poland
 
PDF
Webinar Slides: Migrating to Galera Cluster
Severalnines
 
PDF
Git+jenkins+rex presentation
Dwi Sasongko Supriyadi
 
Gdb basics for my sql db as (percona live europe 2019)
Valerii Kravchuk
 
A brief introduction to PostgreSQL
Vu Hung Nguyen
 
High availability for puppet - 2016
Zack Smith
 
MySQL Multi-Source Replication for PL2016
Wagner Bianchi
 
Tracing and profiling my sql (percona live europe 2019) draft_1
Valerii Kravchuk
 
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Ortus Solutions, Corp
 
Lock free programming- pro tips
Jean-Philippe BEMPEL
 
MySQL Replication Troubleshooting for Oracle DBAs
Sveta Smirnova
 
Do it Yourself Testing
Emily Stolfo
 
How go makes us faster (May 2015)
Wilfried Schobeiri
 
FOSDEM 2015: gdb tips and tricks for MySQL DBAs
Valerii Kravchuk
 
Understanding MySQL Performance through Benchmarking
Laine Campbell
 
PostgreSQL Monitoring using modern software stacks
Showmax Engineering
 
LAS16-307: Benchmarking Schedutil in Android
Linaro
 
Rex - Lightning Talk yapc.eu 2013
Jan Gehring
 
Lessons Learned: Troubleshooting Replication
Sveta Smirnova
 
Daniel Sloof: Magento on HHVM
Meet Magento Poland
 
Webinar Slides: Migrating to Galera Cluster
Severalnines
 
Git+jenkins+rex presentation
Dwi Sasongko Supriyadi
 
Ad

Similar to An evening with Postgresql (20)

PDF
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC
 
PDF
The Accidental DBA
PostgreSQL Experts, Inc.
 
PDF
What’s New In PostgreSQL 9.3
Pavan Deolasee
 
PDF
Utopia Kindgoms scaling case: From 4 to 50K users
Jaime Buelta
 
PDF
Utopia Kingdoms scaling case. From 4 users to 50.000+
Python Ireland
 
PDF
Load testing in Zonky with Gatling
Petr Vlček
 
PPTX
Eko10 workshop - OPEN SOURCE DATABASE MONITORING
Pablo Garbossa
 
PDF
Useful PostgreSQL Extensions
EDB
 
PPTX
Eko10 Workshop Opensource Database Auditing
Juan Berner
 
PDF
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
Aleksander Alekseev
 
PDF
kranonit S06E01 Игорь Цинько: High load
Krivoy Rog IT Community
 
PDF
MySQL Time Machine by replicating into HBase - Slides from Percona Live Amste...
Boško Devetak
 
PPTX
Journey through high performance django application
bangaloredjangousergroup
 
ODP
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Per Henrik Lausten
 
PDF
Elephant Roads: PostgreSQL Patches and Variants
PostgreSQL Experts, Inc.
 
PDF
Elephant Roads: a tour of Postgres forks
Command Prompt., Inc
 
PDF
Introduction to Postrges-XC
Ashutosh Bapat
 
ODP
An Introduction to Postgresql
عباس بني اسدي مقدم
 
PDF
Elephants in the Cloud
Mike Fowler
 
PPTX
Ledingkart Meetup #2: Scaling Search @Lendingkart
Mukesh Singh
 
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC
 
The Accidental DBA
PostgreSQL Experts, Inc.
 
What’s New In PostgreSQL 9.3
Pavan Deolasee
 
Utopia Kindgoms scaling case: From 4 to 50K users
Jaime Buelta
 
Utopia Kingdoms scaling case. From 4 users to 50.000+
Python Ireland
 
Load testing in Zonky with Gatling
Petr Vlček
 
Eko10 workshop - OPEN SOURCE DATABASE MONITORING
Pablo Garbossa
 
Useful PostgreSQL Extensions
EDB
 
Eko10 Workshop Opensource Database Auditing
Juan Berner
 
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
Aleksander Alekseev
 
kranonit S06E01 Игорь Цинько: High load
Krivoy Rog IT Community
 
MySQL Time Machine by replicating into HBase - Slides from Percona Live Amste...
Boško Devetak
 
Journey through high performance django application
bangaloredjangousergroup
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Per Henrik Lausten
 
Elephant Roads: PostgreSQL Patches and Variants
PostgreSQL Experts, Inc.
 
Elephant Roads: a tour of Postgres forks
Command Prompt., Inc
 
Introduction to Postrges-XC
Ashutosh Bapat
 
An Introduction to Postgresql
عباس بني اسدي مقدم
 
Elephants in the Cloud
Mike Fowler
 
Ledingkart Meetup #2: Scaling Search @Lendingkart
Mukesh Singh
 
Ad

More from Joshua Drake (13)

PDF
Defining Your Goal: Starting Your Own Business
Joshua Drake
 
PDF
Defining Your Goal: Starting Your Own Business
Joshua Drake
 
PDF
Dumb Simple PostgreSQL Performance (NYCPUG)
Joshua Drake
 
ODP
East09 Keynote
Joshua Drake
 
ODP
Go Replicator
Joshua Drake
 
PDF
Pitr Made Easy
Joshua Drake
 
PDF
Introduction to PgBench
Joshua Drake
 
PDF
Developing A Procedural Language For Postgre Sql
Joshua Drake
 
PDF
PostgreSQL Conference: East 08
Joshua Drake
 
PDF
PostgreSQL Conference: West 08
Joshua Drake
 
PDF
What MySQL can learn from PostgreSQL
Joshua Drake
 
PDF
Northern Arizona State ACM talk (10/08)
Joshua Drake
 
ODP
Plproxy
Joshua Drake
 
Defining Your Goal: Starting Your Own Business
Joshua Drake
 
Defining Your Goal: Starting Your Own Business
Joshua Drake
 
Dumb Simple PostgreSQL Performance (NYCPUG)
Joshua Drake
 
East09 Keynote
Joshua Drake
 
Go Replicator
Joshua Drake
 
Pitr Made Easy
Joshua Drake
 
Introduction to PgBench
Joshua Drake
 
Developing A Procedural Language For Postgre Sql
Joshua Drake
 
PostgreSQL Conference: East 08
Joshua Drake
 
PostgreSQL Conference: West 08
Joshua Drake
 
What MySQL can learn from PostgreSQL
Joshua Drake
 
Northern Arizona State ACM talk (10/08)
Joshua Drake
 
Plproxy
Joshua Drake
 

Recently uploaded (20)

PDF
CH2-MODEL-SETUP-v2017.1-JC-APR27-2017.pdf
jcc00023con
 
PPTX
lecture 13 mind test academy it skills.pptx
ggesjmrasoolpark
 
PDF
Research about a FoodFolio app for personalized dietary tracking and health o...
AustinLiamAndres
 
PPTX
artificial intelligence deeplearning-200712115616.pptx
revathi148366
 
PPTX
Measurement of Afordability for Water Supply and Sanitation in Bangladesh .pptx
akmibrahimbd
 
PDF
A Systems Thinking Approach to Algorithmic Fairness.pdf
Epistamai
 
PPTX
Introduction to Data Analytics and Data Science
KavithaCIT
 
PPTX
Presentation1.pptxvhhh. H ycycyyccycycvvv
ItratBatool16
 
PPTX
Extract Transformation Load (3) (1).pptx
revathi148366
 
PDF
Key_Statistical_Techniques_in_Analytics_by_CA_Suvidha_Chaplot (1).pdf
CA Suvidha Chaplot
 
PPTX
Employee Salary Presentation.l based on data science collection of data
barridevakumari2004
 
PPTX
World-population.pptx fire bunberbpeople
umutunsalnsl4402
 
PDF
The_Future_of_Data_Analytics_by_CA_Suvidha_Chaplot_UPDATED.pdf
CA Suvidha Chaplot
 
PPTX
Probability systematic sampling methods.pptx
PrakashRajput19
 
PPTX
Data Security Breach: Immediate Action Plan
varmabhuvan266
 
PDF
345_IT infrastructure for business management.pdf
LEANHTRAN4
 
PPTX
Web_Engineering_Assignment_Clean.pptxfor college
HUSNAINAHMAD39
 
PDF
Key_Statistical_Techniques_in_Analytics_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Chad Readey - An Independent Thinker
Chad Readey
 
PPT
Grade 5 PPT_Science_Q2_W6_Methods of reproduction.ppt
AaronBaluyut
 
CH2-MODEL-SETUP-v2017.1-JC-APR27-2017.pdf
jcc00023con
 
lecture 13 mind test academy it skills.pptx
ggesjmrasoolpark
 
Research about a FoodFolio app for personalized dietary tracking and health o...
AustinLiamAndres
 
artificial intelligence deeplearning-200712115616.pptx
revathi148366
 
Measurement of Afordability for Water Supply and Sanitation in Bangladesh .pptx
akmibrahimbd
 
A Systems Thinking Approach to Algorithmic Fairness.pdf
Epistamai
 
Introduction to Data Analytics and Data Science
KavithaCIT
 
Presentation1.pptxvhhh. H ycycyyccycycvvv
ItratBatool16
 
Extract Transformation Load (3) (1).pptx
revathi148366
 
Key_Statistical_Techniques_in_Analytics_by_CA_Suvidha_Chaplot (1).pdf
CA Suvidha Chaplot
 
Employee Salary Presentation.l based on data science collection of data
barridevakumari2004
 
World-population.pptx fire bunberbpeople
umutunsalnsl4402
 
The_Future_of_Data_Analytics_by_CA_Suvidha_Chaplot_UPDATED.pdf
CA Suvidha Chaplot
 
Probability systematic sampling methods.pptx
PrakashRajput19
 
Data Security Breach: Immediate Action Plan
varmabhuvan266
 
345_IT infrastructure for business management.pdf
LEANHTRAN4
 
Web_Engineering_Assignment_Clean.pptxfor college
HUSNAINAHMAD39
 
Key_Statistical_Techniques_in_Analytics_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Chad Readey - An Independent Thinker
Chad Readey
 
Grade 5 PPT_Science_Q2_W6_Methods of reproduction.ppt
AaronBaluyut
 

An evening with Postgresql

  • 1. An Evening with PostgreSQL Command Prompt, Inc.
  • 2. Who Am I ● @linuxhiker ● +JoshuaDrakeLinuxHiker ● [email protected] ● Lead Consultant – Command Prompt, Inc. ● Director – Software in the Public Interest ● President – United States PostgreSQL
  • 3. Rated: Pg-13 ● I do this for fun. This is not my day job. ● East Coast from the West Coast ● Your ego is not my concern ● To to take offense is to not be comfortable in oneself. ● Hopefully you laugh and learn
  • 4. Help control license costs If you are selling licenses to software, you are not helping control license costs.
  • 5. Proactive SLA ● Remote DBA / Sysadmin ● Proactive Response ● 4 Hours of DBA (minimum) ● SLA / 24x7 / 365 ● No Emergency/After Hours rates ● Flat, discounted rate From 1350.00/mo
  • 6. What are we talking about ● What is PostgreSQL? ● Community Structure ● Comparison to other databases ● Awesome PostgreSQL stuff + 9.4 features ● WTH were they thinking! ● Guaranteed not to be in order
  • 7. What is PostgreSQL? ● The oldest of the open source databases (derived from University Ingres 1974) ● The most advanced Open Source (possibly of closed too) database ● A full ACID compliant, relational, object-relational, document, modern, scalable database.
  • 8. Community Structure ● Everyone Welcome ● Meritocracy ● INTL: Postgresql.org ● Japan: Postgresql.jp ● EU: Postgresql.eu ● US: Postgresql.us ● Smaller ones (Brazil, France, Italy)
  • 9. Comparison to other databases ● Licensing ● Community ● No single point of failure ● Feature parity with all databases, more advanced than some ● Best of both worlds, relational or document
  • 10. Licensing BSD not GPL ● Important for commercial providers
  • 11. Community ● Large ● Vibrant ● Active ● All walks of life ● Driven by the ecosystem, not a company
  • 12. No single point of failure ● Can not be bought ● Can not go out of business ● Can not be co-opted ● Many known and qualified support/services companies (CMD, PgExperts, OmniTI, BullInfoSys, Consistent State, 2nd Quadrant)
  • 13. Feature Parity ● We have reached a point of... oh PostgreSQL ● Like MSSQL, Oracle, Sybase, just another SQL database but with neat stuff ● No longer a fringe product (thanks to Oracle)
  • 14. Standard Features ● SQL Compliance ● Partitioning ● Replication ● Tablespaces ● ACID
  • 15. AWESOME Stuff BEGIN; ALTER TABLE foo ADD COLUMN bar text; d foo COMMIT/ROLLBACK; (Mysql can't do this)
  • 16. Craziness BEGIN; CREATE TABLE foo (id serial, test text); CREATE TABLE bar (a foo); insert into bar values (row(1,'this is a test')); postgres=# select * from bar; a ---------------------- (1,"this is a test") – Say what?
  • 17. It gets better postgres=# select (a).id from bar; id ---- 1
  • 18. Wooohaa! postgres=# select row_to_json(row((a).id),true) from bar; row_to_json ------------- {"f1":1}
  • 19. Enough of that, let's talk 9.4 ● JSONB ● Logical Decoding (Including Logical Replication) ● BDR ● Wal Bouncer ● Other 9.4 stuff
  • 20. JSON ● Added in 9.2 ● Input is validated ● Stored as text representation – Slower on retrieval due to per row parse (per value?) ● Preserves key order and duplicates ● Mature support in 9.3 – Better Functions – Operators ● Advanced support in 9.4 – Type building functions ● About 15% storage overhead ● Expression only indexes (WHERE foo)
  • 21. When to use JSON ● Document storage ● Duplicate preservation ● Key order preservation
  • 22. JSONB ● 9.4+ ● Full JSON Implementation ● Stored as binary (unlike JSON) ● Works with all JSON operators ● HSTORE-style query operators ● No key order ● No duplicate preservation ● Faster access ● GIN Indexing (and expression), for containment ops use json_path_ops ● About 35% storage overhead ● Much faster than JSON for retrieval (slower than HSTORE)
  • 23. JSONB Features ● Equality operator – SELECT '{“a”: 1, “b”: 2}'::jsonb = '{“b”:2, “a”:1}'::jsonb ● Containment operator (Softserve) – SELECT '{“a”: 1, “b”: 2}'::jsonb @> {“b”:2}::jsonb ● Existence – SELECT '{“a”: 1, “b”: 2}'::jsonb ? 'b'; ● Nested operators (softserve works as well) – SELECT '{“a”: [1,2]}'::jsonb = '{“a”:[1,2]}'::jsonb ● Existence (any) - ?| ● Existence (all) - ?&
  • 24. JSON/JSBON thanks Information retrieved from PDXPUG day in 2014 via David Wheeler ● http://vimeo.com/105491487
  • 25. Logical Decoding PostgreSQL provides infrastructure to stream the modifications performed via SQL to external consumers. The format in which those changes are streamed is determined by the output plugin used. Every output plugin has access to each individual new row produced by INSERT and the new row version created by UPDATE. Availability of old row versions for UPDATE and DELETE depends on the configured REPLICA IDENTITY. It is also possible to write additional methods of consuming the output of a replication slot without modifying core code. (http://www.postgresql.org/docs/9.4/static/logicaldecoding.html)
  • 26. What does Logical Decoding Mean? ● You now have backend access to INSERT/UPDATE/DELETE mechanisms. ● Is used to implement new features such as: – BDR: https://wiki.postgresql.org/wiki/BDR_User_Guide – Auditing – Walbouncer: http://www.cybertec.at/en/products/walbouncer-enterprise-grade- partial-replication/
  • 27. BDR ● Multi-Master without triggers! (Sorry Bucardo) ● Uses LLSR (From Logical Decoding) ● Supports distributed Sequences ● Supports synchronisation functions ● Supports conflict handlers ● Highly performant ● Eventually consistent ● Up to 48 nodes
  • 28. WalBouncer ● Requires 9.4 ● Allows partial replication to remote replicas – Each replica can have a different data set ● Filters based on WAL ● Single master to many slave ● Can be disconcerting to the novice ● http://www.cybertec.at/postgresql_produkte/walbouncer/
  • 29. Other 9.4 Stuff ● GIN indexes now faster and smaller ● pg_prewarm ● ALTER SYSTEM ● Concurrent materialized view refresh ● Update Views with different columns
  • 30. ALTER SYSTEM ● Commands such as: – ALTER SYSTEM SET log_min_duration_statement = '5s'; Are now saved to postgresql.auto.conf which is always read last and saved between restarts.
  • 31. Better updateable views CREATE TABLE products ( product_id SERIAL PRIMARY KEY, product_name TEXT NOT NULL, quantity INT, reserved INT DEFAULT 0); CREATE VIEW products_view AS SELECT product_id, product_name, quantity, (quantity - reserved) AS available FROM products WHERE quantity IS NOT NULL;
  • 32. Views Continued postgres=# INSERT INTO products_view (product_name, quantity) VALUES ('Budget laptop', 100), ('Premium laptop', 10); INSERT 0 2 postgres=# SELECT * FROM products; product_id | product_name | quantity | reserved ------------+----------------+----------+---------- 1 | Budget laptop | 100 | 0 2 | Premium laptop | 10 | 0 (2 rows)
  • 34. Questions? ● Political ● Community ● Technical ● Why the hell not?