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

Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)
Valerii Kravchuk
 
A brief introduction to PostgreSQL
A brief introduction to PostgreSQLA brief introduction to PostgreSQL
A brief introduction to PostgreSQL
Vu Hung Nguyen
 
High availability for puppet - 2016
High availability for puppet - 2016High availability for puppet - 2016
High availability for puppet - 2016
Zack Smith
 
MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016Wagner Bianchi
 
Tracing and profiling my sql (percona live europe 2019) draft_1
Tracing and profiling my sql (percona live europe 2019) draft_1Tracing and profiling my sql (percona live europe 2019) draft_1
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]
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Ortus Solutions, Corp
 
Lock free programming- pro tips
Lock free programming- pro tipsLock free programming- pro tips
Lock free programming- pro tips
Jean-Philippe BEMPEL
 
MySQL Replication Troubleshooting for Oracle DBAs
MySQL Replication Troubleshooting for Oracle DBAsMySQL Replication Troubleshooting for Oracle DBAs
MySQL Replication Troubleshooting for Oracle DBAs
Sveta Smirnova
 
Do it Yourself Testing
Do it Yourself TestingDo it Yourself Testing
Do it Yourself Testing
Emily Stolfo
 
How go makes us faster (May 2015)
How go makes us faster (May 2015)How go makes us faster (May 2015)
How go makes us faster (May 2015)
Wilfried Schobeiri
 
FOSDEM 2015: gdb tips and tricks for MySQL DBAs
FOSDEM 2015: gdb tips and tricks for MySQL DBAsFOSDEM 2015: gdb tips and tricks for MySQL DBAs
FOSDEM 2015: gdb tips and tricks for MySQL DBAs
Valerii Kravchuk
 
Understanding MySQL Performance through Benchmarking
Understanding MySQL Performance through BenchmarkingUnderstanding MySQL Performance through Benchmarking
Understanding MySQL Performance through Benchmarking
Laine Campbell
 
PostgreSQL Monitoring using modern software stacks
PostgreSQL Monitoring using modern software stacksPostgreSQL Monitoring using modern software stacks
PostgreSQL Monitoring using modern software stacks
Showmax Engineering
 
LAS16-307: Benchmarking Schedutil in Android
LAS16-307: Benchmarking Schedutil in AndroidLAS16-307: Benchmarking Schedutil in Android
LAS16-307: Benchmarking Schedutil in Android
Linaro
 
Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013Jan Gehring
 
Lessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting ReplicationLessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting Replication
Sveta Smirnova
 
Webinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterWebinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterSeveralnines
 

What's hot (19)

Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)
 
A brief introduction to PostgreSQL
A brief introduction to PostgreSQLA brief introduction to PostgreSQL
A brief introduction to PostgreSQL
 
High availability for puppet - 2016
High availability for puppet - 2016High availability for puppet - 2016
High availability for puppet - 2016
 
MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016
 
Tracing and profiling my sql (percona live europe 2019) draft_1
Tracing and profiling my sql (percona live europe 2019) draft_1Tracing and profiling my sql (percona live europe 2019) draft_1
Tracing and profiling my sql (percona live europe 2019) draft_1
 
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
 
Lock free programming- pro tips
Lock free programming- pro tipsLock free programming- pro tips
Lock free programming- pro tips
 
MySQL Replication Troubleshooting for Oracle DBAs
MySQL Replication Troubleshooting for Oracle DBAsMySQL Replication Troubleshooting for Oracle DBAs
MySQL Replication Troubleshooting for Oracle DBAs
 
Do it Yourself Testing
Do it Yourself TestingDo it Yourself Testing
Do it Yourself Testing
 
How go makes us faster (May 2015)
How go makes us faster (May 2015)How go makes us faster (May 2015)
How go makes us faster (May 2015)
 
FOSDEM 2015: gdb tips and tricks for MySQL DBAs
FOSDEM 2015: gdb tips and tricks for MySQL DBAsFOSDEM 2015: gdb tips and tricks for MySQL DBAs
FOSDEM 2015: gdb tips and tricks for MySQL DBAs
 
Understanding MySQL Performance through Benchmarking
Understanding MySQL Performance through BenchmarkingUnderstanding MySQL Performance through Benchmarking
Understanding MySQL Performance through Benchmarking
 
PostgreSQL Monitoring using modern software stacks
PostgreSQL Monitoring using modern software stacksPostgreSQL Monitoring using modern software stacks
PostgreSQL Monitoring using modern software stacks
 
LAS16-307: Benchmarking Schedutil in Android
LAS16-307: Benchmarking Schedutil in AndroidLAS16-307: Benchmarking Schedutil in Android
LAS16-307: Benchmarking Schedutil in Android
 
Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013
 
Lessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting ReplicationLessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting Replication
 
Daniel Sloof: Magento on HHVM
Daniel Sloof: Magento on HHVMDaniel Sloof: Magento on HHVM
Daniel Sloof: Magento on HHVM
 
Webinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterWebinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera Cluster
 
Git+jenkins+rex presentation
Git+jenkins+rex presentationGit+jenkins+rex presentation
Git+jenkins+rex presentation
 

Similar to An evening with Postgresql

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

Similar to An evening with Postgresql (20)

PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json  postgre-sql vs. mongodbPGConf APAC 2018 - High performance json  postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
 
The Accidental DBA
The Accidental DBAThe Accidental DBA
The Accidental DBA
 
What’s New In PostgreSQL 9.3
What’s New In PostgreSQL 9.3What’s New In PostgreSQL 9.3
What’s New In PostgreSQL 9.3
 
Utopia Kindgoms scaling case: From 4 to 50K users
Utopia Kindgoms scaling case: From 4 to 50K usersUtopia Kindgoms scaling case: From 4 to 50K users
Utopia Kindgoms scaling case: From 4 to 50K users
 
Utopia Kingdoms scaling case. From 4 users to 50.000+
Utopia Kingdoms scaling case. From 4 users to 50.000+Utopia Kingdoms scaling case. From 4 users to 50.000+
Utopia Kingdoms scaling case. From 4 users to 50.000+
 
Load testing in Zonky with Gatling
Load testing in Zonky with GatlingLoad testing in Zonky with Gatling
Load testing in Zonky with Gatling
 
Eko10 workshop - OPEN SOURCE DATABASE MONITORING
Eko10 workshop - OPEN SOURCE DATABASE MONITORINGEko10 workshop - OPEN SOURCE DATABASE MONITORING
Eko10 workshop - OPEN SOURCE DATABASE MONITORING
 
Useful PostgreSQL Extensions
Useful PostgreSQL ExtensionsUseful PostgreSQL Extensions
Useful PostgreSQL Extensions
 
Eko10 Workshop Opensource Database Auditing
Eko10  Workshop Opensource Database AuditingEko10  Workshop Opensource Database Auditing
Eko10 Workshop Opensource Database Auditing
 
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High load
 
MySQL Time Machine by replicating into HBase - Slides from Percona Live Amste...
MySQL Time Machine by replicating into HBase - Slides from Percona Live Amste...MySQL Time Machine by replicating into HBase - Slides from Percona Live Amste...
MySQL Time Machine by replicating into HBase - Slides from Percona Live Amste...
 
Journey through high performance django application
Journey through high performance django applicationJourney through high performance django application
Journey through high performance django application
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)
 
Elephant Roads: PostgreSQL Patches and Variants
Elephant Roads: PostgreSQL Patches and VariantsElephant Roads: PostgreSQL Patches and Variants
Elephant Roads: PostgreSQL Patches and Variants
 
Elephant Roads: a tour of Postgres forks
Elephant Roads: a tour of Postgres forksElephant Roads: a tour of Postgres forks
Elephant Roads: a tour of Postgres forks
 
Introduction to Postrges-XC
Introduction to Postrges-XCIntroduction to Postrges-XC
Introduction to Postrges-XC
 
An Introduction to Postgresql
An Introduction to PostgresqlAn Introduction to Postgresql
An Introduction to Postgresql
 
Elephants in the Cloud
Elephants in the CloudElephants in the Cloud
Elephants in the Cloud
 
Ledingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @LendingkartLedingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @Lendingkart
 

More from Joshua Drake

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

More from Joshua Drake (13)

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

Recently uploaded

Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
2023240532
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
jerlynmaetalle
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
jerlynmaetalle
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
dwreak4tg
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
74nqk8xf
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTESAdjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
Subhajit Sahu
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
ewymefz
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
balafet
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
g4dpvqap0
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
Subhajit Sahu
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
javier ramirez
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
axoqas
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
v3tuleee
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
haila53
 

Recently uploaded (20)

Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
Quantitative Data AnalysisReliability Analysis (Cronbach Alpha) Common Method...
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTESAdjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
 

An evening with Postgresql

  • 1. An Evening with PostgreSQL Command Prompt, Inc.
  • 2. Who Am I ● @linuxhiker ● +JoshuaDrakeLinuxHiker ● jd@commandprompt.com ● 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?