EDB White Paper Using The NoSQL Features in Postgres PDF
EDB White Paper Using The NoSQL Features in Postgres PDF
Postgres
An EnterpriseDB
White Paper
For DBAs, Developers
& Database Architects
July 2015
Table of Contents
Why NoSQL?
Document Database-JSON
10
11
12
14
15
17
About EnterpriseDB
17
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 2
Why NoSQL?
Businesses and technology teams are demanding greater flexibility,
faster time to market and continuous refinement of existing systems.
This requires an unprecedented agility in data management that
traditional relational database management systems have been striving
to deliver. NoSQL-only solutions, such as document stores and keyvalue stores, emerged to support incremental development
methodologies where data models emerge as the application goes
through cycles of agile development. This is in contrast to traditional
methods of carefully crafting data models upfront using ERdiagramming, normal form analysis, and conceptual/logical/physical
design frameworks.
PostgreSQL (often called Postgres) introduced JSON and HSTORE to
provide solution architects and developers a schema-less data
management option that is fully integrated with Postgres robust ACID
(Atomic, Consistent, Isolation and Durable) model. HSTORE has been
an integral part of Postgres since 2006; JSON was first introduced in
Postgres v9.2. With the upcoming release of Postgres v9.4 this fall,
Postgres NoSQL capabilities will dramatically expand and performance
will skyrocket.
This paper reviews and illustrates Postgres NoSQL capabilities in the
context of Postgres robust relational competencies. The paper also
describes performance tests that demonstrate that Postgres, the
leading open source relational database solution, is a superior platform
for handling many NoSQL workloads.
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 3
more feature rich over the past 15 years, that original design hurdle
has turned into a unique advantage. The fact that Postgres is an
object-relational database means new capabilities can be developed
and plugged into the database as needs evolve.
Using this level of extensibility, Postgres developers have expanded
the database to include new features and capabilities as new
workloads requiring greater flexibility in the data model emerged. The
most relevant examples in the NoSQL discussion are JSON and
HSTORE. With JSON and HSTORE, Postgres can support
applications that require a great deal of flexibility in the data model.
Document Database JSON
Document database capabilities in Postgres advanced significantly
when support for the JSON data type was introduced in 2012 as part of
Postgres 9.2. JSON (JavaScript Object Notation) is one of the most
popular data-interchange formats on the web. It is supported by
virtually every programming language in use today, and continues to
gain traction. Some NoSQL-only systems, such as MongoDB, use
JSON (or its more limited binary cousin BSON) as their native data
interchange format.
Postgres offers robust support for JSON. Postgres has a JSON data
type, which validates and stores JSON data and provides functions for
extracting elements from JSON values. And, it offers the ability to
easily encode query result sets using JSON. This last piece of
functionality is particularly important, as it means that applications that
prefer to work natively with JSON can easily obtain their data from
Postgres in JSON.
Below are some examples of using JSON data in Postgres.
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 4
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 5
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 6
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 7
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 8
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 9
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 10
The tag
FROM
data as old_price_data,
json_data_update
(
data,
'price'::text,
'200'::text
) as new_price_data
json_data
WHERE data->>'name' = 'AC3 Phone';
Result
old_price_data | {"name": "AC3 Phone", "type": "phone", "brand":
"ACME", "price": 200, "available": true, "warranty_years": 1}
new_price_data | "{\"name\": \"AC3
Phone\", \"type\": \"phone\", \"brand\": \"ACME\", \"price\":
200, \"available\": true, \"warranty_years\": 1}"
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 11
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 12
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 13
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 14
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 15
PostgreSQL 9.4
15391
7319
Inserts (s)
85639
29125
Selects (s)
1929
753
DB Size (GB)
92.63
69.36
Figure 10: Relative Performance Comparison of MongoDB 2.6 with PostgreSQL 9.4
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 16
Get Started Today. Let EnterpriseDB help you build and execute your
game plan. Contact us at +1-877-377-4352 or +1-781-357-3390, or
send an email to [email protected] to get started today on your
path to database independence.
About EnterpriseDB
EntepriseDB is the only worldwide provider of enterprise-class
products and services based on PostgreSQL, the worlds most
advanced and independent open source database.
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 17
20140815
2015 EnterpriseDB Corporation. All rights reserved. EnterpriseDB and Postgres Plus are trademarks
of EnterpriseDB Corporation. Other names may be trademarks of their respective owners.
http://www.enterprisedb.com
Page: 18