SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Downloaden Sie, um offline zu lesen
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?

Weitere ähnliche Inhalte

Was ist angesagt?

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 PostgreSQLVu Hung Nguyen
 
High availability for puppet - 2016
High availability for puppet - 2016High availability for puppet - 2016
High availability for puppet - 2016Zack 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_1Valerii 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
 
MySQL Replication Troubleshooting for Oracle DBAs
MySQL Replication Troubleshooting for Oracle DBAsMySQL Replication Troubleshooting for Oracle DBAs
MySQL Replication Troubleshooting for Oracle DBAsSveta Smirnova
 
Do it Yourself Testing
Do it Yourself TestingDo it Yourself Testing
Do it Yourself TestingEmily 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 DBAsValerii Kravchuk
 
Understanding MySQL Performance through Benchmarking
Understanding MySQL Performance through BenchmarkingUnderstanding MySQL Performance through Benchmarking
Understanding MySQL Performance through BenchmarkingLaine Campbell
 
PostgreSQL Monitoring using modern software stacks
PostgreSQL Monitoring using modern software stacksPostgreSQL Monitoring using modern software stacks
PostgreSQL Monitoring using modern software stacksShowmax Engineering
 
LAS16-307: Benchmarking Schedutil in Android
LAS16-307: Benchmarking Schedutil in AndroidLAS16-307: Benchmarking Schedutil in Android
LAS16-307: Benchmarking Schedutil in AndroidLinaro
 
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 ReplicationSveta Smirnova
 
Webinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterWebinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterSeveralnines
 

Was ist angesagt? (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
 

Ähnlich wie 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. mongodbPGConf 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.3Pavan Deolasee
 
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
 
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 usersJaime Buelta
 
Load testing in Zonky with Gatling
Load testing in Zonky with GatlingLoad testing in Zonky with Gatling
Load testing in Zonky with GatlingPetr Vlček
 
Eko10 workshop - OPEN SOURCE DATABASE MONITORING
Eko10 workshop - OPEN SOURCE DATABASE MONITORINGEko10 workshop - OPEN SOURCE DATABASE MONITORING
Eko10 workshop - OPEN SOURCE DATABASE MONITORINGPablo Garbossa
 
Useful PostgreSQL Extensions
Useful PostgreSQL ExtensionsUseful PostgreSQL Extensions
Useful PostgreSQL ExtensionsEDB
 
Eko10 Workshop Opensource Database Auditing
Eko10  Workshop Opensource Database AuditingEko10  Workshop Opensource Database Auditing
Eko10 Workshop Opensource Database AuditingJuan 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 applicationbangaloredjangousergroup
 
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 forksCommand Prompt., Inc
 
Introduction to Postrges-XC
Introduction to Postrges-XCIntroduction to Postrges-XC
Introduction to Postrges-XCAshutosh Bapat
 
Elephants in the Cloud
Elephants in the CloudElephants in the Cloud
Elephants in the CloudMike Fowler
 
Ledingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @LendingkartLedingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @LendingkartMukesh Singh
 

Ähnlich wie 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 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+
 
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
 
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
 

Mehr von 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 BusinessJoshua 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 BusinessJoshua Drake
 
Dumb Simple PostgreSQL Performance (NYCPUG)
Dumb Simple PostgreSQL Performance (NYCPUG)Dumb Simple PostgreSQL Performance (NYCPUG)
Dumb Simple PostgreSQL Performance (NYCPUG)Joshua Drake
 
Introduction to PgBench
Introduction to PgBenchIntroduction to PgBench
Introduction to PgBenchJoshua 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 SqlJoshua Drake
 
PostgreSQL Conference: East 08
PostgreSQL Conference: East 08PostgreSQL Conference: East 08
PostgreSQL Conference: East 08Joshua Drake
 
PostgreSQL Conference: West 08
PostgreSQL Conference: West 08PostgreSQL Conference: West 08
PostgreSQL Conference: West 08Joshua Drake
 
What MySQL can learn from PostgreSQL
What MySQL can learn from PostgreSQLWhat MySQL can learn from PostgreSQL
What MySQL can learn from PostgreSQLJoshua 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
 

Mehr von 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
 

Kürzlich hochgeladen

Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Seán Kennedy
 
Heart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectHeart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectBoston Institute of Analytics
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesConf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesTimothy Spann
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queensdataanalyticsqueen03
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDRafezzaman
 
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...ssuserf63bd7
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Boston Institute of Analytics
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改yuu sss
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024thyngster
 
Business Analytics using Microsoft Excel
Business Analytics using Microsoft ExcelBusiness Analytics using Microsoft Excel
Business Analytics using Microsoft Excelysmaelreyes
 
Real-Time AI Streaming - AI Max Princeton
Real-Time AI  Streaming - AI Max PrincetonReal-Time AI  Streaming - AI Max Princeton
Real-Time AI Streaming - AI Max PrincetonTimothy Spann
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...Amil Baba Dawood bangali
 
Advanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsAdvanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsVICTOR MAESTRE RAMIREZ
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanMYRABACSAFRA2
 
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Thomas Poetter
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfBoston Institute of Analytics
 

Kürzlich hochgeladen (20)

Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...
 
Heart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectHeart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis Project
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesConf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queens
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
 
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
 
Business Analytics using Microsoft Excel
Business Analytics using Microsoft ExcelBusiness Analytics using Microsoft Excel
Business Analytics using Microsoft Excel
 
Real-Time AI Streaming - AI Max Princeton
Real-Time AI  Streaming - AI Max PrincetonReal-Time AI  Streaming - AI Max Princeton
Real-Time AI Streaming - AI Max Princeton
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
 
Advanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsAdvanced Machine Learning for Business Professionals
Advanced Machine Learning for Business Professionals
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population Mean
 
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.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?