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

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
 

Similar to An evening with Postgresql (20)

ODP
Introduction to PostgreSQL
Jim Mlodgenski
 
PDF
NoSQL on ACID - Meet Unstructured Postgres
EDB
 
PDF
Beyond Postgres: Interesting Projects, Tools and forks
Sameer Kumar
 
PDF
What’s New In PostgreSQL 9.3
Pavan Deolasee
 
PDF
PostgreSQL Prologue
Md. Golam Hossain
 
PPTX
Postgresql
NexThoughts Technologies
 
PDF
Pg 95 new capabilities
Jamey Hanson
 
KEY
PostgreSQL
Reuven Lerner
 
PDF
Don't panic! - Postgres introduction
Federico Campoli
 
PDF
No sql way_in_pg
Vibhor Kumar
 
PPTX
PostgreSQL - Object Relational Database
Mubashar Iqbal
 
PPT
Object Relational Database Management System
Amar Myana
 
PDF
Bn 1016 demo postgre sql-online-training
conline training
 
PPTX
PostgreSQL- An Introduction
Smita Prasad
 
PDF
PostgreSQL - Case Study
S.Shayan Daneshvar
 
PDF
PostgreSQL 9.0 & The Future
Aaron Thul
 
PPTX
PostgreSQL Terminology
Showmax Engineering
 
PDF
Migrating to postgresql
botsplash.com
 
PDF
GSoC2014 - PGDay Ijui/RS Presentation October, 2016
FabrĂ­zio Mello
 
PDF
NoSQL Now: Postgres - The NoSQL Cake You Can Eat
DATAVERSITY
 
Introduction to PostgreSQL
Jim Mlodgenski
 
NoSQL on ACID - Meet Unstructured Postgres
EDB
 
Beyond Postgres: Interesting Projects, Tools and forks
Sameer Kumar
 
What’s New In PostgreSQL 9.3
Pavan Deolasee
 
PostgreSQL Prologue
Md. Golam Hossain
 
Pg 95 new capabilities
Jamey Hanson
 
PostgreSQL
Reuven Lerner
 
Don't panic! - Postgres introduction
Federico Campoli
 
No sql way_in_pg
Vibhor Kumar
 
PostgreSQL - Object Relational Database
Mubashar Iqbal
 
Object Relational Database Management System
Amar Myana
 
Bn 1016 demo postgre sql-online-training
conline training
 
PostgreSQL- An Introduction
Smita Prasad
 
PostgreSQL - Case Study
S.Shayan Daneshvar
 
PostgreSQL 9.0 & The Future
Aaron Thul
 
PostgreSQL Terminology
Showmax Engineering
 
Migrating to postgresql
botsplash.com
 
GSoC2014 - PGDay Ijui/RS Presentation October, 2016
FabrĂ­zio Mello
 
NoSQL Now: Postgres - The NoSQL Cake You Can Eat
DATAVERSITY
 
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
 
Ad

Recently uploaded (20)

PPTX
apidays Singapore 2025 - Generative AI Landscape Building a Modern Data Strat...
apidays
 
PPTX
apidays Helsinki & North 2025 - Running a Successful API Program: Best Practi...
apidays
 
PPT
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
PDF
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
PDF
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
PPTX
Listify-Intelligent-Voice-to-Catalog-Agent.pptx
nareshkottees
 
PPTX
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
PDF
Research Methodology Overview Introduction
ayeshagul29594
 
PDF
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
PPTX
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
PPTX
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
PDF
apidays Helsinki & North 2025 - Monetizing AI APIs: The New API Economy, Alla...
apidays
 
PDF
Development and validation of the Japanese version of the Organizational Matt...
Yoga Tokuyoshi
 
PPT
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
PDF
apidays Singapore 2025 - How APIs can make - or break - trust in your AI by S...
apidays
 
PDF
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
apidays
 
PDF
Simplifying Document Processing with Docling for AI Applications.pdf
Tamanna36
 
PDF
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
PPTX
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
PDF
Avatar for apidays apidays PRO June 07, 2025 0 5 apidays Helsinki & North 2...
apidays
 
apidays Singapore 2025 - Generative AI Landscape Building a Modern Data Strat...
apidays
 
apidays Helsinki & North 2025 - Running a Successful API Program: Best Practi...
apidays
 
Growth of Public Expendituuure_55423.ppt
NavyaDeora
 
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
Listify-Intelligent-Voice-to-Catalog-Agent.pptx
nareshkottees
 
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
Research Methodology Overview Introduction
ayeshagul29594
 
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
apidays Helsinki & North 2025 - Monetizing AI APIs: The New API Economy, Alla...
apidays
 
Development and validation of the Japanese version of the Organizational Matt...
Yoga Tokuyoshi
 
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
apidays Singapore 2025 - How APIs can make - or break - trust in your AI by S...
apidays
 
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
apidays
 
Simplifying Document Processing with Docling for AI Applications.pdf
Tamanna36
 
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
Avatar for apidays apidays PRO June 07, 2025 0 5 apidays Helsinki & North 2...
apidays
 

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?