SlideShare a Scribd company logo
A Postgres-XC
Distributed Key-Value Store
Mason Sharp
April 15, 2013
CC License: Attribution-NonCommercial-ShareAlike
Who Am I?
Mason Sharp
●
Original architect of Stado / GridSQL
●
One of original architects of Postgres-XC
●
Former architect at EnterpriseDB
●
Co-organizer of NYC PostgreSQL User Group
●
Co-founder and CTO of
Agenda
●
Why use a key-value store?
●
PostgreSQL features
●
XML
●
hstore
●
JSON
●
Postgres-XC Overview
●
Measurements: MongoDB versus Postgres-XC
Agenda
●
Why use a key-value store?
●
PostgreSQL features
●
XML
●
hstore
●
JSON
●
Postgres-XC Overview
●
Measurements: MongoDB versus Postgres-XC
Why Use a Key-Value Store?
●
Document oriented vs. row oriented
●
Unstructured data
●
Semi-structured data
●
Self-describing / schema-less
●
Uses Tags
●
Dynamic attributes for different objects
●
Dwight Merriman, CEO 10gen (paraphrasing):
●
“Some customers use MongoDB just for the schema-
less features. They don't need the scalability and
run on one single server” (!)
●
“Easier for developers” (...)
Why Use a Key-Value Store? (2)
●
Key-value makes for an easy distributed store
●
Multiple servers
●
In-memory
●
No complicated schema changes
●
But PostgreSQL's ALTER TABLE exclusive locks
may be brief
●
Need to be “web-scale”
●
Perception that it scales better
●
What if it no longer fits in memory?
●
A series of unfortunate anecdotes
PostgreSQL
Document Store Capabilities
XML
●
--with-libxml at build time
●
Native data type
●
CREATE TABLE foo (myid int, data xml)
●
Validation
INSERT INTO foo VALUES (2, '<aaa');
ERROR: invalid XML content
Detail: line 1: Couldn't find end of Start Tag
aaa line 1
●
Xpath
●
Mapping & Export functions
hstore
●
Contrib module
●
CREATE EXTENSION hstore
●
Key/value pairs
●
Data type
hstore
CREATE TABLE foo (myid int, hdata hstore);
INSERT INTO foo VALUES (10,
'"name"=>"fred", "department"=>"IT"');
hstore
SELECT hdata->'name' FROM foo WHERE id = 10;
?column?
----------
fred
(1 row)
# Extract all department values where it is an attribute
SELECT hdata->'department'
FROM foo
WHERE hdata ? 'department';
Hstore Manipulation
●
Concatenate
'a=>b, c=>d'::hstore || 'c=>x, d=>q'::hstore
"a"=>"b", "c"=>"x", "d"=>"q"
●
Delete element
delete('a=>1,b=>2','b')
"a"=>"1"
hstore
# Get a list of unique keys
SELECT DISTINCT (each(hdata)).key
FROM foo
hstore - Indexes
●
Btree index only helps with '='
●
Gin and gist indexes will help with operators
●
@> left operand contains right
●
? contains key
●
?& contains all keys in array
●
?| contains at least one key in array
●
Can create index on custom function
●
Extract a particular key value
JSON
●
JavaScript Object Notation
●
PostgreSQL 9.2 basic support
●
array_to_json
●
row_to_json
Note: Postgres-XC 1.0.2 based on PostgreSQL
9.1, will be based on 9.2 soon
JSON – looking ahead to
PostgreSQL 9.3
●
PostgreSQL 9.3
●
json_agg
●
hstore_to_json
●
hstore_to_json_loose
●
… and much more
http://www.postgresql.org/docs/devel/static/
functions-json.html
Composite Type
CREATE TYPE address AS (
street TEXT,
city TEXT,
state TEXT,
zip CHAR(10));
CREATE TABLE customer (
full_name TEXT,
mail_address address);
row_to_json
test1=# select row_to_json(customer) from
customer;
{"full_name":"Joe Lee",
"mail_address": {
"street":"100 Broad Street",
"city":"Red Bank",
"state":"NJ",
"zip":"07701 "}
}
19
●
PostgreSQL-based database cluster
Same API to Apps as PostgreSQL
• Same drivers
●
Symmetric Multi-headed Cluster
No master, no slave
• Not just PostgreSQL replication.
• Application can read/write to any coordinator server
Consistent database view to all the transactions
• Complete ACID property to all the transactions in the cluster
●
Scales both for Write and Read
Sep 20, 2012 Postgres-XC 20
Sep 20, 2012 Postgres-XC 21
Postgres-XC Cluster
Coordinator
Data Node
PG-XC Server
Coordinator
Data Node
Coordinator
Data Node
Coordinator
Data Node
・・・・・
Communication amongPG-XC servers
Add PG-XC servers as
needed
Global Transaction
Manager
Application can connect to any server to have the same database view and service.
GTM
PG-XC Server PG-XC Server PG-XC Server
Coordinator Overview
●
Based on PostgreSQL
●
Accepts connections from clients
●
Parses and plans requests
●
Interacts with Global Transaction Manager
●
Uses pooler for Data Node connections
●
Sends down XIDs and snapshots to Data Nodes
●
Collects results and returns to client
●
Uses two phase commit if necessary
22
Data Node Overview
●
Based on PostgreSQL
●
Where user created data is actually stored
●
Coordinators (not clients) connects to Data
Nodes
●
Accepts XID and snapshots from Coordinator
●
The rest is fairly similar to vanilla PostgreSQL
23
Sep 20, 2012 Postgres-XC 24
Global Transaction Manager
Cluster nodesGTM
XID
Snapshot
Timestamp
Sequence values
GTM Overview
●
Issues Transaction IDs (XIDs)
●
Issues Snapshots
●
Issues Timestamps
●
Issues Sequences
●
Based on PostgreSQL procarray code
●
Multi-threaded
25
GTM Proxy
●
Runs on other nodes
●
Groups requests together
●
Reduces number of connections to GTM
●
Reduces traffic to GTM
26
Sep 20, 2012 Postgres-XC 27
Summary
● Coordinator
● Visible to apps
● SQL analysis, planning, execution
● Connection pooling
● Datanode (or simply “NODE”)
● Actual database store
● Local SQL execution
● GTM (Global Transaction Manager)
● Provides consistent database view to transactions
– GXID (Global Transaction ID)
– Snapshot (List of active transactions)
– Other global values such as SEQUENCE
● GTM Proxy, integrates server-local transaction requirement for performance
Postgres-XC core, based upon
vanilla PostgreSQL
Share same binary
May want to colocate
Different binaries
MongoDB vs Postgres-XC
Performance Comparison
●
Three data nodes (16GB RAM each)
●
Postgres-XC also used a coordinator
●
Adds latency
●
Out-of-the-box default configuration
●
No replicas
Insert Comparison – single thread
●
0 – 1M Rows
●
MongoDB: 7m 06s
●
Postgres-XC: 131m 1s
●
Postgres-XC COPY: 43s
●
10M – 20M Rows
●
MongoDB: 64m 48
●
Postgres-XC: 354m 56s
GTM in XC adds a lot of latency hurting
single-threaded performance
Read Comparison
(shorter is better)
1 2 3 4 5 6 7 8 9 10
0
0.5
1
1.5
2
2.5
MongoDB
Postgres-XC
Rows (millions)
Time(seconds)
Update Comparison – single thread
50 GB, single thread
●
1000 Updates by partitioned key
●
MongoDB: 43s
●
Postgres-XC: 1m 6s
●
1000 Updates by indexed non-partitioned key
●
MongoDB: 7m 55s
●
Postgres-XC: 1m 54s
Non-partitioned index-based faster in XC
Update Concurrency on Key
Possible Future Tests
●
Insert,Select concurrency test (important)
●
Mixed workload
●
Measure in-memory and not in-memory
●
Impact of replicas for availability
●
MongoDB replicas
●
Postgres-XC streaming replication
●
Have seen about 15% perf drop for two sync slaves
●
MongoDB Write-Concern durability settings (try
journaled)
●
Hstore
Other PostgreSQL Results?
●
Christophe Pettus:
wiki.postgresql.org/images/b/b4/Pg-as-nosql-
pgday-fosdem-2013.pdf
●
Single laptop-based tests, but interesting
●
Summary
●
PostgreSQL has schema-less functionality built-
in and can act as a key-value store
●
Postgres-XC can scale this out horizontally to
multiple servers
●
MongoDB performs much better for low
concurrency for inserts
●
In XC, use COPY or multiple threads to populate
●
Postgres-XC performs better for non-partitioned
indexed access
●
Postgres-XC can perform about the same to
MongoDB for reads
Summary (2)
If Postgres-XC generally performs similarly to
MongoDB, why not use XC and
●
Stick with ACID
●
Feel secure with PostgreSQL maturity
●
Leverage PostgreSQL features and community
Thank You
Mason Sharp
mason@stormdb.com
@mason_db
Content Attribution
●
Postgres-XC Development Group
●
Koichi Suzuki
●
Michael Paquier
●
Ashutosh Bapat
●
Pavan Deolasee
●
Christophe Pettus
●
Mason Sharp
●
...

More Related Content

What's hot (20)

PDF
Migrating to postgresql
botsplash.com
 
ODP
Sdc challenges-2012
Gluster.org
 
ODP
Tiering barcelona
Gluster.org
 
PDF
Gluster d2
Gluster.org
 
PDF
Storage as a Service with Gluster
Vijay Bellur
 
PDF
SQL, NoSQL, NewSQL? What's a developer to do?
Chris Richardson
 
PDF
Red Hat Gluster Storage - Direction, Roadmap and Use-Cases
Red_Hat_Storage
 
ODP
Lisa 2015-gluster fs-introduction
Gluster.org
 
PDF
Ceph Block Devices: A Deep Dive
joshdurgin
 
PDF
Red Hat Storage - Introduction to GlusterFS
GlusterFS
 
ODP
YDAL Barcelona
Gluster.org
 
PDF
M|18 How to use MyRocks with MariaDB Server
MariaDB plc
 
PDF
Gluster.community.day.2013
Udo Seidel
 
PPTX
Gluster Storage
Raz Tamir
 
PDF
Pgxc scalability pg_open2012
Ashutosh Bapat
 
PDF
Disperse xlator ramon_datalab
Gluster.org
 
PDF
Gluster overview & future directions vault 2015
Vijay Bellur
 
PDF
GlusterFS And Big Data
Lalatendu Mohanty
 
PDF
MySQL Cluster (NDB) - Best Practices Percona Live 2017
Severalnines
 
PDF
Gluster.next feb-2016
Vijay Bellur
 
Migrating to postgresql
botsplash.com
 
Sdc challenges-2012
Gluster.org
 
Tiering barcelona
Gluster.org
 
Gluster d2
Gluster.org
 
Storage as a Service with Gluster
Vijay Bellur
 
SQL, NoSQL, NewSQL? What's a developer to do?
Chris Richardson
 
Red Hat Gluster Storage - Direction, Roadmap and Use-Cases
Red_Hat_Storage
 
Lisa 2015-gluster fs-introduction
Gluster.org
 
Ceph Block Devices: A Deep Dive
joshdurgin
 
Red Hat Storage - Introduction to GlusterFS
GlusterFS
 
YDAL Barcelona
Gluster.org
 
M|18 How to use MyRocks with MariaDB Server
MariaDB plc
 
Gluster.community.day.2013
Udo Seidel
 
Gluster Storage
Raz Tamir
 
Pgxc scalability pg_open2012
Ashutosh Bapat
 
Disperse xlator ramon_datalab
Gluster.org
 
Gluster overview & future directions vault 2015
Vijay Bellur
 
GlusterFS And Big Data
Lalatendu Mohanty
 
MySQL Cluster (NDB) - Best Practices Percona Live 2017
Severalnines
 
Gluster.next feb-2016
Vijay Bellur
 

Viewers also liked (8)

PDF
Postgres-XC: Symmetric PostgreSQL Cluster
Pavan Deolasee
 
PDF
Flexible Indexing with Postgres
EDB
 
PDF
How the Postgres Query Optimizer Works
EDB
 
PDF
Distributed Postgres
Stas Kelvich
 
PDF
Multimaster
Stas Kelvich
 
PPT
Aerospike: Key Value Data Access
Aerospike, Inc.
 
PDF
Lightbend Lagom: Microservices Just Right
mircodotta
 
Postgres-XC: Symmetric PostgreSQL Cluster
Pavan Deolasee
 
Flexible Indexing with Postgres
EDB
 
How the Postgres Query Optimizer Works
EDB
 
Distributed Postgres
Stas Kelvich
 
Multimaster
Stas Kelvich
 
Aerospike: Key Value Data Access
Aerospike, Inc.
 
Lightbend Lagom: Microservices Just Right
mircodotta
 
Ad

Similar to Postgres-XC as a Key Value Store Compared To MongoDB (20)

PDF
Postgrtesql as a NoSQL Document Store - The JSON/JSONB data type
Jumping Bean
 
PDF
There is Javascript in my SQL
PGConf APAC
 
PDF
Lean and mean MongoDB
Oleg Podsechin
 
PDF
Grails 101
David Jacobs
 
PDF
Using MongoDB and Python
Mike Bright
 
PDF
2016 feb-23 pyugre-py_mongo
Michael Bright
 
PDF
NoSQL solutions
Felix Crisan
 
PDF
Building RESTtful services in MEAN
Madhukara Phatak
 
PDF
Intro Couchdb
selvamanisampath
 
ODP
An Introduction to Postgresql
عباس بني اسدي مقدم
 
PDF
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC
 
PDF
MongoDB and Web Scrapping with the Gyes Platform
MongoDB
 
PDF
No sql bigdata and postgresql
Zaid Shabbir
 
PDF
kranonit S06E01 Игорь Цинько: High load
Krivoy Rog IT Community
 
PDF
An evening with Postgresql
Joshua Drake
 
PDF
Mongo DB schema design patterns
joergreichert
 
PDF
Solr Power FTW: Powering NoSQL the World Over
Alex Pinkin
 
PDF
Introduction to new high performance storage engines in mongodb 3.0
Henrik Ingo
 
PPTX
Understanding and tuning WiredTiger, the new high performance database engine...
Ontico
 
PDF
Benchx: An XQuery benchmarking web application
Andy Bunce
 
Postgrtesql as a NoSQL Document Store - The JSON/JSONB data type
Jumping Bean
 
There is Javascript in my SQL
PGConf APAC
 
Lean and mean MongoDB
Oleg Podsechin
 
Grails 101
David Jacobs
 
Using MongoDB and Python
Mike Bright
 
2016 feb-23 pyugre-py_mongo
Michael Bright
 
NoSQL solutions
Felix Crisan
 
Building RESTtful services in MEAN
Madhukara Phatak
 
Intro Couchdb
selvamanisampath
 
An Introduction to Postgresql
عباس بني اسدي مقدم
 
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC
 
MongoDB and Web Scrapping with the Gyes Platform
MongoDB
 
No sql bigdata and postgresql
Zaid Shabbir
 
kranonit S06E01 Игорь Цинько: High load
Krivoy Rog IT Community
 
An evening with Postgresql
Joshua Drake
 
Mongo DB schema design patterns
joergreichert
 
Solr Power FTW: Powering NoSQL the World Over
Alex Pinkin
 
Introduction to new high performance storage engines in mongodb 3.0
Henrik Ingo
 
Understanding and tuning WiredTiger, the new high performance database engine...
Ontico
 
Benchx: An XQuery benchmarking web application
Andy Bunce
 
Ad

Recently uploaded (20)

PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Biography of Daniel Podor.pdf
Daniel Podor
 
July Patch Tuesday
Ivanti
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 

Postgres-XC as a Key Value Store Compared To MongoDB

  • 1. A Postgres-XC Distributed Key-Value Store Mason Sharp April 15, 2013 CC License: Attribution-NonCommercial-ShareAlike
  • 2. Who Am I? Mason Sharp ● Original architect of Stado / GridSQL ● One of original architects of Postgres-XC ● Former architect at EnterpriseDB ● Co-organizer of NYC PostgreSQL User Group ● Co-founder and CTO of
  • 3. Agenda ● Why use a key-value store? ● PostgreSQL features ● XML ● hstore ● JSON ● Postgres-XC Overview ● Measurements: MongoDB versus Postgres-XC
  • 4. Agenda ● Why use a key-value store? ● PostgreSQL features ● XML ● hstore ● JSON ● Postgres-XC Overview ● Measurements: MongoDB versus Postgres-XC
  • 5. Why Use a Key-Value Store? ● Document oriented vs. row oriented ● Unstructured data ● Semi-structured data ● Self-describing / schema-less ● Uses Tags ● Dynamic attributes for different objects ● Dwight Merriman, CEO 10gen (paraphrasing): ● “Some customers use MongoDB just for the schema- less features. They don't need the scalability and run on one single server” (!) ● “Easier for developers” (...)
  • 6. Why Use a Key-Value Store? (2) ● Key-value makes for an easy distributed store ● Multiple servers ● In-memory ● No complicated schema changes ● But PostgreSQL's ALTER TABLE exclusive locks may be brief ● Need to be “web-scale” ● Perception that it scales better ● What if it no longer fits in memory? ● A series of unfortunate anecdotes
  • 8. XML ● --with-libxml at build time ● Native data type ● CREATE TABLE foo (myid int, data xml) ● Validation INSERT INTO foo VALUES (2, '<aaa'); ERROR: invalid XML content Detail: line 1: Couldn't find end of Start Tag aaa line 1 ● Xpath ● Mapping & Export functions
  • 9. hstore ● Contrib module ● CREATE EXTENSION hstore ● Key/value pairs ● Data type
  • 10. hstore CREATE TABLE foo (myid int, hdata hstore); INSERT INTO foo VALUES (10, '"name"=>"fred", "department"=>"IT"');
  • 11. hstore SELECT hdata->'name' FROM foo WHERE id = 10; ?column? ---------- fred (1 row) # Extract all department values where it is an attribute SELECT hdata->'department' FROM foo WHERE hdata ? 'department';
  • 12. Hstore Manipulation ● Concatenate 'a=>b, c=>d'::hstore || 'c=>x, d=>q'::hstore "a"=>"b", "c"=>"x", "d"=>"q" ● Delete element delete('a=>1,b=>2','b') "a"=>"1"
  • 13. hstore # Get a list of unique keys SELECT DISTINCT (each(hdata)).key FROM foo
  • 14. hstore - Indexes ● Btree index only helps with '=' ● Gin and gist indexes will help with operators ● @> left operand contains right ● ? contains key ● ?& contains all keys in array ● ?| contains at least one key in array ● Can create index on custom function ● Extract a particular key value
  • 15. JSON ● JavaScript Object Notation ● PostgreSQL 9.2 basic support ● array_to_json ● row_to_json Note: Postgres-XC 1.0.2 based on PostgreSQL 9.1, will be based on 9.2 soon
  • 16. JSON – looking ahead to PostgreSQL 9.3 ● PostgreSQL 9.3 ● json_agg ● hstore_to_json ● hstore_to_json_loose ● … and much more http://www.postgresql.org/docs/devel/static/ functions-json.html
  • 17. Composite Type CREATE TYPE address AS ( street TEXT, city TEXT, state TEXT, zip CHAR(10)); CREATE TABLE customer ( full_name TEXT, mail_address address);
  • 18. row_to_json test1=# select row_to_json(customer) from customer; {"full_name":"Joe Lee", "mail_address": { "street":"100 Broad Street", "city":"Red Bank", "state":"NJ", "zip":"07701 "} }
  • 19. 19 ● PostgreSQL-based database cluster Same API to Apps as PostgreSQL • Same drivers ● Symmetric Multi-headed Cluster No master, no slave • Not just PostgreSQL replication. • Application can read/write to any coordinator server Consistent database view to all the transactions • Complete ACID property to all the transactions in the cluster ● Scales both for Write and Read
  • 20. Sep 20, 2012 Postgres-XC 20
  • 21. Sep 20, 2012 Postgres-XC 21 Postgres-XC Cluster Coordinator Data Node PG-XC Server Coordinator Data Node Coordinator Data Node Coordinator Data Node ・・・・・ Communication amongPG-XC servers Add PG-XC servers as needed Global Transaction Manager Application can connect to any server to have the same database view and service. GTM PG-XC Server PG-XC Server PG-XC Server
  • 22. Coordinator Overview ● Based on PostgreSQL ● Accepts connections from clients ● Parses and plans requests ● Interacts with Global Transaction Manager ● Uses pooler for Data Node connections ● Sends down XIDs and snapshots to Data Nodes ● Collects results and returns to client ● Uses two phase commit if necessary 22
  • 23. Data Node Overview ● Based on PostgreSQL ● Where user created data is actually stored ● Coordinators (not clients) connects to Data Nodes ● Accepts XID and snapshots from Coordinator ● The rest is fairly similar to vanilla PostgreSQL 23
  • 24. Sep 20, 2012 Postgres-XC 24 Global Transaction Manager Cluster nodesGTM XID Snapshot Timestamp Sequence values
  • 25. GTM Overview ● Issues Transaction IDs (XIDs) ● Issues Snapshots ● Issues Timestamps ● Issues Sequences ● Based on PostgreSQL procarray code ● Multi-threaded 25
  • 26. GTM Proxy ● Runs on other nodes ● Groups requests together ● Reduces number of connections to GTM ● Reduces traffic to GTM 26
  • 27. Sep 20, 2012 Postgres-XC 27 Summary ● Coordinator ● Visible to apps ● SQL analysis, planning, execution ● Connection pooling ● Datanode (or simply “NODE”) ● Actual database store ● Local SQL execution ● GTM (Global Transaction Manager) ● Provides consistent database view to transactions – GXID (Global Transaction ID) – Snapshot (List of active transactions) – Other global values such as SEQUENCE ● GTM Proxy, integrates server-local transaction requirement for performance Postgres-XC core, based upon vanilla PostgreSQL Share same binary May want to colocate Different binaries
  • 28. MongoDB vs Postgres-XC Performance Comparison ● Three data nodes (16GB RAM each) ● Postgres-XC also used a coordinator ● Adds latency ● Out-of-the-box default configuration ● No replicas
  • 29. Insert Comparison – single thread ● 0 – 1M Rows ● MongoDB: 7m 06s ● Postgres-XC: 131m 1s ● Postgres-XC COPY: 43s ● 10M – 20M Rows ● MongoDB: 64m 48 ● Postgres-XC: 354m 56s GTM in XC adds a lot of latency hurting single-threaded performance
  • 30. Read Comparison (shorter is better) 1 2 3 4 5 6 7 8 9 10 0 0.5 1 1.5 2 2.5 MongoDB Postgres-XC Rows (millions) Time(seconds)
  • 31. Update Comparison – single thread 50 GB, single thread ● 1000 Updates by partitioned key ● MongoDB: 43s ● Postgres-XC: 1m 6s ● 1000 Updates by indexed non-partitioned key ● MongoDB: 7m 55s ● Postgres-XC: 1m 54s Non-partitioned index-based faster in XC
  • 33. Possible Future Tests ● Insert,Select concurrency test (important) ● Mixed workload ● Measure in-memory and not in-memory ● Impact of replicas for availability ● MongoDB replicas ● Postgres-XC streaming replication ● Have seen about 15% perf drop for two sync slaves ● MongoDB Write-Concern durability settings (try journaled) ● Hstore
  • 34. Other PostgreSQL Results? ● Christophe Pettus: wiki.postgresql.org/images/b/b4/Pg-as-nosql- pgday-fosdem-2013.pdf ● Single laptop-based tests, but interesting ●
  • 35. Summary ● PostgreSQL has schema-less functionality built- in and can act as a key-value store ● Postgres-XC can scale this out horizontally to multiple servers ● MongoDB performs much better for low concurrency for inserts ● In XC, use COPY or multiple threads to populate ● Postgres-XC performs better for non-partitioned indexed access ● Postgres-XC can perform about the same to MongoDB for reads
  • 36. Summary (2) If Postgres-XC generally performs similarly to MongoDB, why not use XC and ● Stick with ACID ● Feel secure with PostgreSQL maturity ● Leverage PostgreSQL features and community
  • 38. Content Attribution ● Postgres-XC Development Group ● Koichi Suzuki ● Michael Paquier ● Ashutosh Bapat ● Pavan Deolasee ● Christophe Pettus ● Mason Sharp ● ...