SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
© 2014 EnterpriseDB Corporation. All rights reserved. 1
NoSQL on ACID - Meet Unstructured
Postgres
Marc Linster – SVP, Products and Services
© 2014 EnterpriseDB Corporation. All rights reserved. 2
•  Why NoSQL: Use Cases and Business Drivers
•  Postgres’ response: JSON and HSTORE
−  Examples
−  More Examples
−  Even More Examples
•  Performance Evaluation
•  No SQL Only or Not Only SQL?
•  Next Steps
Objectives
© 2014 EnterpriseDB Corporation. All rights reserved. 3
•  Where did NoSQL come from?
−  Where all cool tech stuff comes from – Internet companies
•  Why did they make NoSQL?
−  To support huge data volumes and evolving demands for ways
to work with new data types
•  What does NoSQL accomplish?
−  Enables you to work with new data types: email, mobile
interactions, machine data, social connections
−  Enables you to work in new ways: incremental development
and continuous release
•  Why did they have to build something new?
−  There were limitations to most relational databases
Let’s Ask Ourselves, Why NoSQL?
© 2014 EnterpriseDB Corporation. All rights reserved. 4
NoSQL: Real-world Applications
•  Emergency Management System
−  High variability among data sources required high schema
flexibility
•  Massively Open Online Course
−  Massive read scalability, content integration, low latency
•  Patient Data and Prescription Records
−  Efficient write scalability
•  Social Marketing Analytics
−  Map reduce analytical approaches
Source: Gartner, A Tour of NoSQL in 8 Use Cases,
by Nick Heudecker and Merv Adrian, February 28, 2014
© 2014 EnterpriseDB Corporation. All rights reserved. 5
•  Traditional relational databases
−  Don’t offer enough flexibility
−  Every change in the table requires DBA support
−  Data models evolve over time
−  Incremental iterative development does not allow for upfront
design and extensive data normalization
−  New data types (documents, key value pairs, graphs) are not
available
•  Many projects are
−  Developer driven
−  Use cases and data access patterns emerge as the application
matures
Why not use SQL?
© 2014 EnterpriseDB Corporation. All rights reserved. 6
•  HSTORE
−  Key-value pair
−  Simple, fast and easy
−  Postgres v 8.2 – pre-dates many NoSQL-only solutions
−  Ideal for flat data structures that are sparsely populated
•  JSON
−  Hierarchical document model
−  Introduced in Postgres 9.2, perfected in 9.3
•  JSONB
−  Binary version of JSON
−  Faster, more operators and even more robust
−  Postgres 9.4
Postgres’ Response
© 2014 EnterpriseDB Corporation. All rights reserved. 7
•  Supported since 2006, the HStore
contrib module enables storing key/
value pairs within a single column
•  Allows you to create a schema-less,
ACID compliant data store within
Postgres
Postgres: Key-value Store
•  Combines flexibility with ACID compliance
•  Create single HStore column and
include, for each row, only those keys
which pertain to the record
•  Add attributes to a table and query
without advance planning
© 2014 EnterpriseDB Corporation. All rights reserved. 8
•  Create a table with HSTORE field
CREATE TABLE hstore_data (data HSTORE);!
•  Insert a record into hstore_data
INSERT INTO hstore_data (data) VALUES (’!
! !"cost"=>"500", !
! !"product"=>"iphone", !
! !"provider"=>"apple"');!
•  Select data from hstore_data
SELECT data FROM hstore_data ;
------------------------------------------!
"cost"=>"500”,"product"=>"iphone”,"provider"=>"Apple"!
(1 row) !
HSTORE Examples
© 2014 EnterpriseDB Corporation. All rights reserved. 9
•  Convert HSTORE data to JSON
SELECT hstore_to_json(data) FROM hstore_data ;!
hstore_to_json !
------------------------------------------------
{"cost": "500", "product": "iphone", "provider":
"Apple"}!
SELECT hstore_to_json(data)->>'cost' as price !
FROM hstore_data ;!
price !
-------!
500!
HSTORE Examples
© 2014 EnterpriseDB Corporation. All rights reserved. 10
•  JSON is the most popular
data-interchange format on the web
•  Supported by virtually every
programming language
•  New supporting technologies
continue to expand JSON’s utility
−  PL/V8 JavaScript extension
−  PL/Coffee V8 extension
−  Node.js
•  Postgres has a native JSON data type (v9.2) and a
JSON parser and a variety of JSON functions (v9.3)
•  Postgres will have a JSONB data type with binary
storage and indexing (coming – v9.4)
Postgres: Document Store
© 2014 EnterpriseDB Corporation. All rights reserved. 11
•  Creating a table with a JSONB field
CREATE TABLE json_data (data JSONB);!
•  Simple JSON data element:
{"name": "Apple Phone", "type": "phone", "brand":
"ACME", "price": 200, "available": true,
"warranty_years": 1}!
•  Inserting this data element into the table json_data
INSERT INTO json_data (data) VALUES !
!(’ { !"name": "Apple Phone", !
! !"type": "phone", !
! !"brand": "ACME", !
! !"price": 200, !
! !"available": true, !
! !"warranty_years": 1 ! !!
!} ')!
JSON Examples
© 2014 EnterpriseDB Corporation. All rights reserved. 12
•  JSON data element with nesting:
{“full name”: “John Joseph Carl Salinger”,!
“names”: !
![!
!{"type": "firstname", “value”: ”John”},!
!{“type”: “middlename”, “value”: “Joseph”},!
!{“type”: “middlename”, “value”: “Carl”},!
!{“type”: “lastname”, “value”: “Salinger”} !!
!]!
}!
JSON Examples
© 2014 EnterpriseDB Corporation. All rights reserved. 13
SELECT DISTINCT !
!data->>'name' as products !
FROM json_data;

!
products !
------------------------------!
Cable TV Basic Service Package!
AC3 Case Black!
Phone Service Basic Plan!
AC3 Phone!
AC3 Case Green!
Phone Service Family Plan!
AC3 Case Red!
AC7 Phone!
A simple query for JSON data
This query does not
return JSON data – it
returns text values
associated with the
key ‘name’
© 2014 EnterpriseDB Corporation. All rights reserved. 14
SELECT data FROM json_data;!
data !
------------------------------------------!
{"name": "Apple Phone", "type": "phone",
"brand": "ACME", "price": 200,
"available": true, "warranty_years": 1}!
A query that returns JSON data
This query returns the JSON data in its
original format
© 2014 EnterpriseDB Corporation. All rights reserved. 15
•  BSON – stands for
‘Binary JSON’
•  BSON != JSONB
−  BSON cannot represent an integer or
floating-point number with more than
64 bits of precision.
−  JSONB can represent arbitrary JSON values.
•  Caveat Emptor!
−  This limitation will not be obvious during early
stages of a project!
JSONB and BSON
© 2014 EnterpriseDB Corporation. All rights reserved. 16
•  JSON is naturally
integrated with ANSI SQL
in Postgres
•  JSON and SQL queries
use the same language, the
same planner, and the same ACID compliant
transaction framework
•  JSON and HSTORE are elegant and easy to use
extensions of the underlying object-relational model
JSON and ANSI SQL - PB&J for the DBA
© 2014 EnterpriseDB Corporation. All rights reserved. 17
SELECT DISTINCT
product_type,
data->>'brand' as Brand,
data->>'available' as Availability
FROM json_data
JOIN products
ON (products.product_type=json_data.data->>'name')
WHERE json_data.data->>'available'=true;
product_type | brand | availability
---------------------------+-----------+--------------
AC3 Phone | ACME | true
JSON and ANSI SQL Example
ANSI SQL
JSON
No need for programmatic logic to combine SQL and
NoSQL in the application – Postgres does it all
© 2014 EnterpriseDB Corporation. All rights reserved. 18
Bridging between SQL and JSON
Simple ANSI SQL Table Definition
CREATE TABLE products (id integer, product_name text );!
Select query returning standard data set
SELECT * FROM products;

!
id | product_name !
----+--------------!
1 | iPhone!
2 | Samsung!
3 | Nokia!
Select query returning the same result as a JSON data set
SELECT ROW_TO_JSON(products) FROM products;
{"id":1,"product_name":"iPhone"}
{"id":2,"product_name":"Samsung"}
{"id":3,"product_name":"Nokia”}
© 2014 EnterpriseDB Corporation. All rights reserved. 19
•  Goal
−  Help our customers understand when to chose Postgres and
when to chose a specialty solution
−  Help us understand where the NoSQL limits of Postgres are
•  Setup
−  Compare Postgres 9.4 to Mongo 2.6
−  Single instance setup on AWS M3.2XLARGE (32GB)
•  Test Focus
−  Data ingestion (bulk and individual)
−  Data retrieval
JSON Performance Evaluation
Load Generator
Postgres 9.4
MongoDB 2.6
© 2014 EnterpriseDB Corporation. All rights reserved. 20
Performance Evaluation
Generate 10 Million
JSON Documents
Load into MongoDB 2.6
(IMPORT)
Load into
Postgres 9.4
(COPY)
10 Million individual
INSERT commands
10 Million individual
INSERT commands
Multiple SELECT
statements
Multiple SELECT
statements
T1
T2
T3
© 2014 EnterpriseDB Corporation. All rights reserved. 21
Performance Evaluations - Results
MongoDB 2.6	
   Postgres 9.4	
  
Data load (s)	
   2,624 	
   1,193 	
  
Inserts (s)	
   16,491 	
   5,637 	
  
Selects (s)	
   187 	
   67 	
  
DB Size (GB)	
   20.05 	
   14.89 	
  
© 2014 EnterpriseDB Corporation. All rights reserved. 22
•  Initial tests confirm that Postgres’ can handle many
NoSQL workloads
•  EDB is making the test scripts publically available
•  EDB encourages community participation to
better define where Postgres should be used
and where specialty solutions are appropriate
•  Download the source at
https://github.com/EnterpriseDB/pg_nosql_benchmark
•  Join us to discuss the findings at
http://bit.ly/EDB-NoSQL-Postgres-Benchmark
Performance Evaluations – Next Steps
© 2014 EnterpriseDB Corporation. All rights reserved. 23
•  Postgres has many NoSQL features without the
drawbacks:
−  Schema-less data types, with sophisticated indexing support
−  Schema changes with rapid additional and removal of columns
−  Durable by default, but controllable per-table or per-transaction
•  Postgres was originally architected to be an object-
relational database
−  Extensible (e.g. PostGIS extension for geospatial)
−  Supports objects and classes in the schemas and query
language
−  Supports custom data types and methods
• 
Postgres: The Best of Both Worlds
© 2014 EnterpriseDB Corporation. All rights reserved. 24
•  Structures and standards emerge!
•  Data has references (products link to catalogues;
products have bills of material; components appear in
multiple products; storage locations link to ISO country
tables)
•  When the database has duplicate data entries, then the
application has to manage updates in multiple places –
what happens when there is no ACID transactional
model?
“No SQL Only” or “Not Only SQL”?
© 2014 EnterpriseDB Corporation. All rights reserved. 25
•  Postgres is Not Only SQL (NoSQL is No SQL)
•  Fully ACID compliant
•  Proven track record
•  Fully capable of handling the variety, velocity and
volume requirements of most applications
•  Tackle NoSQL projects without leaving the capabilities
of the relational model behind you
Postgres is the best of both worlds, and it’s open source!
Say ‘Yes’ to ‘Not Only SQL’
© 2014 EnterpriseDB Corporation. All rights reserved. 26
•  More evaluation scenarios
−  EDB will continue publishing evaluation scenarios for new
workloads
−  EDB encourages participation, discussion and debate
•  More examples
−  EDB will continue publishing code samples to facilitate
adoption of Postgres as the NoSQL Solution for Enterprise
•  More webinars
−  Keep your eyes open for the series of NoSQL-focused
webinars throughout the summer
•  Review the Postgres NoSQL resources
−  github.com/EnterpriseDB/pg_nosql_benchmark
−  http://www.enterprisedb.com/nosql-for-enterprise
What’s Next?
© 2014 EnterpriseDB Corporation. All rights reserved. 27
POSTGRES
innovation
ENTERPRISE
reliability
24/7
support
Services
& training
Enterprise-class
features & tools
Indemnification
Product
road-map
Control
Thousands
of developers
Fast
development
cycles
Low cost
No vendor
lock-in
Advanced
features
Enabling commercial
adoption of Postgres
© 2014 EnterpriseDB Corporation. All rights reserved. 28

Contenu connexe

Tendances

Tendances (20)

MongoDB, E-commerce and Transactions
MongoDB, E-commerce and TransactionsMongoDB, E-commerce and Transactions
MongoDB, E-commerce and Transactions
 
MongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combinationMongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combination
 
MongoDB
MongoDBMongoDB
MongoDB
 
MongoDB for Genealogy
MongoDB for GenealogyMongoDB for Genealogy
MongoDB for Genealogy
 
Mongodb - NoSql Database
Mongodb - NoSql DatabaseMongodb - NoSql Database
Mongodb - NoSql Database
 
Transitioning from SQL to MongoDB
Transitioning from SQL to MongoDBTransitioning from SQL to MongoDB
Transitioning from SQL to MongoDB
 
An Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDBAn Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDB
 
Mongo DB
Mongo DBMongo DB
Mongo DB
 
Relational to Graph - Import
Relational to Graph - ImportRelational to Graph - Import
Relational to Graph - Import
 
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
Benefits of Using MongoDB Over RDBMS (At An Evening with MongoDB Minneapolis ...
 
MongoDB as a fast and queryable cache
MongoDB as a fast and queryable cacheMongoDB as a fast and queryable cache
MongoDB as a fast and queryable cache
 
Moving from SQL Server to MongoDB
Moving from SQL Server to MongoDBMoving from SQL Server to MongoDB
Moving from SQL Server to MongoDB
 
OrientDB vs Neo4j - and an introduction to NoSQL databases
OrientDB vs Neo4j - and an introduction to NoSQL databasesOrientDB vs Neo4j - and an introduction to NoSQL databases
OrientDB vs Neo4j - and an introduction to NoSQL databases
 
Mongodb and Totsy - E-commerce Case Study
Mongodb and Totsy - E-commerce Case StudyMongodb and Totsy - E-commerce Case Study
Mongodb and Totsy - E-commerce Case Study
 
MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)MongoDB for Coder Training (Coding Serbia 2013)
MongoDB for Coder Training (Coding Serbia 2013)
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB
 
MongoDB and Schema Design
MongoDB and Schema DesignMongoDB and Schema Design
MongoDB and Schema Design
 
MongoDB Aggregation Performance
MongoDB Aggregation PerformanceMongoDB Aggregation Performance
MongoDB Aggregation Performance
 
TechEd AU 2014: Microsoft Azure DocumentDB Deep Dive
TechEd AU 2014: Microsoft Azure DocumentDB Deep DiveTechEd AU 2014: Microsoft Azure DocumentDB Deep Dive
TechEd AU 2014: Microsoft Azure DocumentDB Deep Dive
 
Back to Basics Webinar 1: Introduction to NoSQL
Back to Basics Webinar 1: Introduction to NoSQLBack to Basics Webinar 1: Introduction to NoSQL
Back to Basics Webinar 1: Introduction to NoSQL
 

En vedette

Why we need document management system - 10.2
Why we need document management system - 10.2Why we need document management system - 10.2
Why we need document management system - 10.2
pandaeyes
 
Top 10 Tips for an Effective Postgres Deployment
Top 10 Tips for an Effective Postgres DeploymentTop 10 Tips for an Effective Postgres Deployment
Top 10 Tips for an Effective Postgres Deployment
EDB
 
PGEncryption_Tutorial
PGEncryption_TutorialPGEncryption_Tutorial
PGEncryption_Tutorial
Vibhor Kumar
 

En vedette (9)

Why we need document management system - 10.2
Why we need document management system - 10.2Why we need document management system - 10.2
Why we need document management system - 10.2
 
EnterpriseDB Postgres Survey Results - 2013
EnterpriseDB Postgres Survey Results - 2013EnterpriseDB Postgres Survey Results - 2013
EnterpriseDB Postgres Survey Results - 2013
 
Top 10 Tips for an Effective Postgres Deployment
Top 10 Tips for an Effective Postgres DeploymentTop 10 Tips for an Effective Postgres Deployment
Top 10 Tips for an Effective Postgres Deployment
 
PGEncryption_Tutorial
PGEncryption_TutorialPGEncryption_Tutorial
PGEncryption_Tutorial
 
Getting Started with PostGIS
Getting Started with PostGISGetting Started with PostGIS
Getting Started with PostGIS
 
Migrating from Oracle to Postgres
Migrating from Oracle to PostgresMigrating from Oracle to Postgres
Migrating from Oracle to Postgres
 
Key Methodologies for Migrating from Oracle to Postgres
Key Methodologies for Migrating from Oracle to PostgresKey Methodologies for Migrating from Oracle to Postgres
Key Methodologies for Migrating from Oracle to Postgres
 
Partition and conquer large data in PostgreSQL 10
Partition and conquer large data in PostgreSQL 10Partition and conquer large data in PostgreSQL 10
Partition and conquer large data in PostgreSQL 10
 
Best Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture SetupBest Practices for a Complete Postgres Enterprise Architecture Setup
Best Practices for a Complete Postgres Enterprise Architecture Setup
 

Similaire à NoSQL on ACID - Meet Unstructured Postgres

EDB NoSQL German Webinar 2015
EDB NoSQL German Webinar 2015EDB NoSQL German Webinar 2015
EDB NoSQL German Webinar 2015
EDB
 
NoSQL Now: Postgres - The NoSQL Cake You Can Eat
NoSQL Now: Postgres - The NoSQL Cake You Can EatNoSQL Now: Postgres - The NoSQL Cake You Can Eat
NoSQL Now: Postgres - The NoSQL Cake You Can Eat
DATAVERSITY
 

Similaire à NoSQL on ACID - Meet Unstructured Postgres (20)

Postgres NoSQL - Delivering Apps Faster
Postgres NoSQL - Delivering Apps FasterPostgres NoSQL - Delivering Apps Faster
Postgres NoSQL - Delivering Apps Faster
 
EDB NoSQL German Webinar 2015
EDB NoSQL German Webinar 2015EDB NoSQL German Webinar 2015
EDB NoSQL German Webinar 2015
 
Postgres: The NoSQL Cake You Can Eat
Postgres: The NoSQL Cake You Can EatPostgres: The NoSQL Cake You Can Eat
Postgres: The NoSQL Cake You Can Eat
 
NoSQL Now: Postgres - The NoSQL Cake You Can Eat
NoSQL Now: Postgres - The NoSQL Cake You Can EatNoSQL Now: Postgres - The NoSQL Cake You Can Eat
NoSQL Now: Postgres - The NoSQL Cake You Can Eat
 
NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQL
 
NoSQL on ACID: Meet Unstructured Postgres
NoSQL on ACID: Meet Unstructured PostgresNoSQL on ACID: Meet Unstructured Postgres
NoSQL on ACID: Meet Unstructured Postgres
 
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
 
Slides: NoSQL Data Modeling Using JSON Documents – A Practical Approach
Slides: NoSQL Data Modeling Using JSON Documents – A Practical ApproachSlides: NoSQL Data Modeling Using JSON Documents – A Practical Approach
Slides: NoSQL Data Modeling Using JSON Documents – A Practical Approach
 
Optymalizacja środowiska Open Source w celu zwiększenia oszczędności i kontroli
Optymalizacja środowiska Open Source w celu zwiększenia oszczędności i kontroliOptymalizacja środowiska Open Source w celu zwiększenia oszczędności i kontroli
Optymalizacja środowiska Open Source w celu zwiększenia oszczędności i kontroli
 
NoSQL and MongoDB Introdction
NoSQL and MongoDB IntrodctionNoSQL and MongoDB Introdction
NoSQL and MongoDB Introdction
 
Postgres for the Future
Postgres for the FuturePostgres for the Future
Postgres for the Future
 
CDC to the Max!
CDC to the Max!CDC to the Max!
CDC to the Max!
 
Postgres for Digital Transformation: NoSQL Features, Replication, FDW & More
Postgres for Digital Transformation:NoSQL Features, Replication, FDW & MorePostgres for Digital Transformation:NoSQL Features, Replication, FDW & More
Postgres for Digital Transformation: NoSQL Features, Replication, FDW & More
 
The Central View of your Data with Postgres
The Central View of your Data with PostgresThe Central View of your Data with Postgres
The Central View of your Data with Postgres
 
Optimize with Open Source
Optimize with Open SourceOptimize with Open Source
Optimize with Open Source
 
Doing More with Postgres - Yesterday's Vision Becomes Today's Reality
Doing More with Postgres - Yesterday's Vision Becomes Today's RealityDoing More with Postgres - Yesterday's Vision Becomes Today's Reality
Doing More with Postgres - Yesterday's Vision Becomes Today's Reality
 
Postgres Foreign Data Wrappers
Postgres Foreign Data Wrappers  Postgres Foreign Data Wrappers
Postgres Foreign Data Wrappers
 
MongoDB Basics
MongoDB BasicsMongoDB Basics
MongoDB Basics
 
Mongo DB at Community Engine
Mongo DB at Community EngineMongo DB at Community Engine
Mongo DB at Community Engine
 
MongoDB at community engine
MongoDB at community engineMongoDB at community engine
MongoDB at community engine
 

Plus de EDB

EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021
EDB
 
Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?
EDB
 
A Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINA Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAIN
EDB
 

Plus de EDB (20)

Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaSCloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
 
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr UnternehmenDie 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
 
Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube
 
EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021
 
Benchmarking Cloud Native PostgreSQL
Benchmarking Cloud Native PostgreSQLBenchmarking Cloud Native PostgreSQL
Benchmarking Cloud Native PostgreSQL
 
Las Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQLLas Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQL
 
Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?
 
Data Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQLData Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQL
 
Practical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresPractical Partitioning in Production with Postgres
Practical Partitioning in Production with Postgres
 
A Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINA Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAIN
 
IOT with PostgreSQL
IOT with PostgreSQLIOT with PostgreSQL
IOT with PostgreSQL
 
A Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQLA Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQL
 
Psql is awesome!
Psql is awesome!Psql is awesome!
Psql is awesome!
 
EDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJEDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJ
 
Comment sauvegarder correctement vos données
Comment sauvegarder correctement vos donnéesComment sauvegarder correctement vos données
Comment sauvegarder correctement vos données
 
Cloud Native PostgreSQL - Italiano
Cloud Native PostgreSQL - ItalianoCloud Native PostgreSQL - Italiano
Cloud Native PostgreSQL - Italiano
 
New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13
 
Best Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLBest Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQL
 
Cloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJCloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJ
 
Best Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLBest Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQL
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

NoSQL on ACID - Meet Unstructured Postgres

  • 1. © 2014 EnterpriseDB Corporation. All rights reserved. 1 NoSQL on ACID - Meet Unstructured Postgres Marc Linster – SVP, Products and Services
  • 2. © 2014 EnterpriseDB Corporation. All rights reserved. 2 •  Why NoSQL: Use Cases and Business Drivers •  Postgres’ response: JSON and HSTORE −  Examples −  More Examples −  Even More Examples •  Performance Evaluation •  No SQL Only or Not Only SQL? •  Next Steps Objectives
  • 3. © 2014 EnterpriseDB Corporation. All rights reserved. 3 •  Where did NoSQL come from? −  Where all cool tech stuff comes from – Internet companies •  Why did they make NoSQL? −  To support huge data volumes and evolving demands for ways to work with new data types •  What does NoSQL accomplish? −  Enables you to work with new data types: email, mobile interactions, machine data, social connections −  Enables you to work in new ways: incremental development and continuous release •  Why did they have to build something new? −  There were limitations to most relational databases Let’s Ask Ourselves, Why NoSQL?
  • 4. © 2014 EnterpriseDB Corporation. All rights reserved. 4 NoSQL: Real-world Applications •  Emergency Management System −  High variability among data sources required high schema flexibility •  Massively Open Online Course −  Massive read scalability, content integration, low latency •  Patient Data and Prescription Records −  Efficient write scalability •  Social Marketing Analytics −  Map reduce analytical approaches Source: Gartner, A Tour of NoSQL in 8 Use Cases, by Nick Heudecker and Merv Adrian, February 28, 2014
  • 5. © 2014 EnterpriseDB Corporation. All rights reserved. 5 •  Traditional relational databases −  Don’t offer enough flexibility −  Every change in the table requires DBA support −  Data models evolve over time −  Incremental iterative development does not allow for upfront design and extensive data normalization −  New data types (documents, key value pairs, graphs) are not available •  Many projects are −  Developer driven −  Use cases and data access patterns emerge as the application matures Why not use SQL?
  • 6. © 2014 EnterpriseDB Corporation. All rights reserved. 6 •  HSTORE −  Key-value pair −  Simple, fast and easy −  Postgres v 8.2 – pre-dates many NoSQL-only solutions −  Ideal for flat data structures that are sparsely populated •  JSON −  Hierarchical document model −  Introduced in Postgres 9.2, perfected in 9.3 •  JSONB −  Binary version of JSON −  Faster, more operators and even more robust −  Postgres 9.4 Postgres’ Response
  • 7. © 2014 EnterpriseDB Corporation. All rights reserved. 7 •  Supported since 2006, the HStore contrib module enables storing key/ value pairs within a single column •  Allows you to create a schema-less, ACID compliant data store within Postgres Postgres: Key-value Store •  Combines flexibility with ACID compliance •  Create single HStore column and include, for each row, only those keys which pertain to the record •  Add attributes to a table and query without advance planning
  • 8. © 2014 EnterpriseDB Corporation. All rights reserved. 8 •  Create a table with HSTORE field CREATE TABLE hstore_data (data HSTORE);! •  Insert a record into hstore_data INSERT INTO hstore_data (data) VALUES (’! ! !"cost"=>"500", ! ! !"product"=>"iphone", ! ! !"provider"=>"apple"');! •  Select data from hstore_data SELECT data FROM hstore_data ; ------------------------------------------! "cost"=>"500”,"product"=>"iphone”,"provider"=>"Apple"! (1 row) ! HSTORE Examples
  • 9. © 2014 EnterpriseDB Corporation. All rights reserved. 9 •  Convert HSTORE data to JSON SELECT hstore_to_json(data) FROM hstore_data ;! hstore_to_json ! ------------------------------------------------ {"cost": "500", "product": "iphone", "provider": "Apple"}! SELECT hstore_to_json(data)->>'cost' as price ! FROM hstore_data ;! price ! -------! 500! HSTORE Examples
  • 10. © 2014 EnterpriseDB Corporation. All rights reserved. 10 •  JSON is the most popular data-interchange format on the web •  Supported by virtually every programming language •  New supporting technologies continue to expand JSON’s utility −  PL/V8 JavaScript extension −  PL/Coffee V8 extension −  Node.js •  Postgres has a native JSON data type (v9.2) and a JSON parser and a variety of JSON functions (v9.3) •  Postgres will have a JSONB data type with binary storage and indexing (coming – v9.4) Postgres: Document Store
  • 11. © 2014 EnterpriseDB Corporation. All rights reserved. 11 •  Creating a table with a JSONB field CREATE TABLE json_data (data JSONB);! •  Simple JSON data element: {"name": "Apple Phone", "type": "phone", "brand": "ACME", "price": 200, "available": true, "warranty_years": 1}! •  Inserting this data element into the table json_data INSERT INTO json_data (data) VALUES ! !(’ { !"name": "Apple Phone", ! ! !"type": "phone", ! ! !"brand": "ACME", ! ! !"price": 200, ! ! !"available": true, ! ! !"warranty_years": 1 ! !! !} ')! JSON Examples
  • 12. © 2014 EnterpriseDB Corporation. All rights reserved. 12 •  JSON data element with nesting: {“full name”: “John Joseph Carl Salinger”,! “names”: ! ![! !{"type": "firstname", “value”: ”John”},! !{“type”: “middlename”, “value”: “Joseph”},! !{“type”: “middlename”, “value”: “Carl”},! !{“type”: “lastname”, “value”: “Salinger”} !! !]! }! JSON Examples
  • 13. © 2014 EnterpriseDB Corporation. All rights reserved. 13 SELECT DISTINCT ! !data->>'name' as products ! FROM json_data;
 ! products ! ------------------------------! Cable TV Basic Service Package! AC3 Case Black! Phone Service Basic Plan! AC3 Phone! AC3 Case Green! Phone Service Family Plan! AC3 Case Red! AC7 Phone! A simple query for JSON data This query does not return JSON data – it returns text values associated with the key ‘name’
  • 14. © 2014 EnterpriseDB Corporation. All rights reserved. 14 SELECT data FROM json_data;! data ! ------------------------------------------! {"name": "Apple Phone", "type": "phone", "brand": "ACME", "price": 200, "available": true, "warranty_years": 1}! A query that returns JSON data This query returns the JSON data in its original format
  • 15. © 2014 EnterpriseDB Corporation. All rights reserved. 15 •  BSON – stands for ‘Binary JSON’ •  BSON != JSONB −  BSON cannot represent an integer or floating-point number with more than 64 bits of precision. −  JSONB can represent arbitrary JSON values. •  Caveat Emptor! −  This limitation will not be obvious during early stages of a project! JSONB and BSON
  • 16. © 2014 EnterpriseDB Corporation. All rights reserved. 16 •  JSON is naturally integrated with ANSI SQL in Postgres •  JSON and SQL queries use the same language, the same planner, and the same ACID compliant transaction framework •  JSON and HSTORE are elegant and easy to use extensions of the underlying object-relational model JSON and ANSI SQL - PB&J for the DBA
  • 17. © 2014 EnterpriseDB Corporation. All rights reserved. 17 SELECT DISTINCT product_type, data->>'brand' as Brand, data->>'available' as Availability FROM json_data JOIN products ON (products.product_type=json_data.data->>'name') WHERE json_data.data->>'available'=true; product_type | brand | availability ---------------------------+-----------+-------------- AC3 Phone | ACME | true JSON and ANSI SQL Example ANSI SQL JSON No need for programmatic logic to combine SQL and NoSQL in the application – Postgres does it all
  • 18. © 2014 EnterpriseDB Corporation. All rights reserved. 18 Bridging between SQL and JSON Simple ANSI SQL Table Definition CREATE TABLE products (id integer, product_name text );! Select query returning standard data set SELECT * FROM products;
 ! id | product_name ! ----+--------------! 1 | iPhone! 2 | Samsung! 3 | Nokia! Select query returning the same result as a JSON data set SELECT ROW_TO_JSON(products) FROM products; {"id":1,"product_name":"iPhone"} {"id":2,"product_name":"Samsung"} {"id":3,"product_name":"Nokia”}
  • 19. © 2014 EnterpriseDB Corporation. All rights reserved. 19 •  Goal −  Help our customers understand when to chose Postgres and when to chose a specialty solution −  Help us understand where the NoSQL limits of Postgres are •  Setup −  Compare Postgres 9.4 to Mongo 2.6 −  Single instance setup on AWS M3.2XLARGE (32GB) •  Test Focus −  Data ingestion (bulk and individual) −  Data retrieval JSON Performance Evaluation Load Generator Postgres 9.4 MongoDB 2.6
  • 20. © 2014 EnterpriseDB Corporation. All rights reserved. 20 Performance Evaluation Generate 10 Million JSON Documents Load into MongoDB 2.6 (IMPORT) Load into Postgres 9.4 (COPY) 10 Million individual INSERT commands 10 Million individual INSERT commands Multiple SELECT statements Multiple SELECT statements T1 T2 T3
  • 21. © 2014 EnterpriseDB Corporation. All rights reserved. 21 Performance Evaluations - Results MongoDB 2.6   Postgres 9.4   Data load (s)   2,624   1,193   Inserts (s)   16,491   5,637   Selects (s)   187   67   DB Size (GB)   20.05   14.89  
  • 22. © 2014 EnterpriseDB Corporation. All rights reserved. 22 •  Initial tests confirm that Postgres’ can handle many NoSQL workloads •  EDB is making the test scripts publically available •  EDB encourages community participation to better define where Postgres should be used and where specialty solutions are appropriate •  Download the source at https://github.com/EnterpriseDB/pg_nosql_benchmark •  Join us to discuss the findings at http://bit.ly/EDB-NoSQL-Postgres-Benchmark Performance Evaluations – Next Steps
  • 23. © 2014 EnterpriseDB Corporation. All rights reserved. 23 •  Postgres has many NoSQL features without the drawbacks: −  Schema-less data types, with sophisticated indexing support −  Schema changes with rapid additional and removal of columns −  Durable by default, but controllable per-table or per-transaction •  Postgres was originally architected to be an object- relational database −  Extensible (e.g. PostGIS extension for geospatial) −  Supports objects and classes in the schemas and query language −  Supports custom data types and methods •  Postgres: The Best of Both Worlds
  • 24. © 2014 EnterpriseDB Corporation. All rights reserved. 24 •  Structures and standards emerge! •  Data has references (products link to catalogues; products have bills of material; components appear in multiple products; storage locations link to ISO country tables) •  When the database has duplicate data entries, then the application has to manage updates in multiple places – what happens when there is no ACID transactional model? “No SQL Only” or “Not Only SQL”?
  • 25. © 2014 EnterpriseDB Corporation. All rights reserved. 25 •  Postgres is Not Only SQL (NoSQL is No SQL) •  Fully ACID compliant •  Proven track record •  Fully capable of handling the variety, velocity and volume requirements of most applications •  Tackle NoSQL projects without leaving the capabilities of the relational model behind you Postgres is the best of both worlds, and it’s open source! Say ‘Yes’ to ‘Not Only SQL’
  • 26. © 2014 EnterpriseDB Corporation. All rights reserved. 26 •  More evaluation scenarios −  EDB will continue publishing evaluation scenarios for new workloads −  EDB encourages participation, discussion and debate •  More examples −  EDB will continue publishing code samples to facilitate adoption of Postgres as the NoSQL Solution for Enterprise •  More webinars −  Keep your eyes open for the series of NoSQL-focused webinars throughout the summer •  Review the Postgres NoSQL resources −  github.com/EnterpriseDB/pg_nosql_benchmark −  http://www.enterprisedb.com/nosql-for-enterprise What’s Next?
  • 27. © 2014 EnterpriseDB Corporation. All rights reserved. 27 POSTGRES innovation ENTERPRISE reliability 24/7 support Services & training Enterprise-class features & tools Indemnification Product road-map Control Thousands of developers Fast development cycles Low cost No vendor lock-in Advanced features Enabling commercial adoption of Postgres
  • 28. © 2014 EnterpriseDB Corporation. All rights reserved. 28