SlideShare a Scribd company logo
ToroDB
Open-source, MongoDB-compatible database,
built on top of PostgreSQL
Álvaro Hernández <aht@torodb.com>
ToroDB @NoSQLonSQL
DEMO!
ToroDB @NoSQLonSQL
About *8Kdata*
● Research & Development in databases
●
Consulting, Training and Support in PostgreSQL
●
Founders of PostgreSQL España, 3rd
largest PUG
in the world (>400 members as of today)
●
About myself: CTO at 8Kdata:
@ahachete
http://linkd.in/1jhvzQ3
www.8kdata.com
ToroDB @NoSQLonSQL
ToroDB in one slide
●
Document-oriented, JSON, NoSQL db
●
Open source (AGPL)
●
MongoDB compatibility (wire protocol
level)
●
Uses PostgreSQL as a storage backend
ToroDB @NoSQLonSQL
Why relational databases:
technical perspective
●
Document model is very appealing to
many. But all dbs started from scratch
●
DRY: why not use relational
databases? They are proven, durable,
concurrent and flexible
●
Why not base it on relational databases,
like PostgreSQL?
ToroDB @NoSQLonSQL
ToroDB
tables structure
ToroDB @NoSQLonSQL
ToroDB storage
●
Data is stored in tables. No blobs
●
JSON documents are split by hierarchy
levels into “subdocuments”, which
contain no nested structures. Each
subdocument level is stored separately
●
Subdocuments are classified by “type”.
Each “type” maps to a different table
ToroDB @NoSQLonSQL
ToroDB storage (II)
●
A “structure” table keeps the
subdocument “schema”
●
Keys in JSON are mapped to attributes,
which retain the original name
●
Tables are created dinamically and
transparently to match the exact types of
the documents
ToroDB @NoSQLonSQL
ToroDB storage internals
{
"name": "ToroDB",
"data": {
"a": 42, "b": "hello world!"
},
"nested": {
"j": 42,
"deeper": {
"a": 21, "b": "hello"
}
}
}
ToroDB @NoSQLonSQL
ToroDB storage internals
The document is split into the following subdocuments:
{ "name": "ToroDB", "data": {}, "nested": {} }
{ "a": 42, "b": "hello world!"}
{ "j": 42, "deeper": {}}
{ "a": 21, "b": "hello"}
ToroDB @NoSQLonSQL
ToroDB storage internals
select * from demo.t_3
┌─────┬───────┬────────────────────────────┬────────┐
│ did │ index │ _id │ name │
├─────┼───────┼────────────────────────────┼────────┤
│ 0 │ ¤ │ x5451a07de7032d23a908576d │ ToroDB │
└─────┴───────┴────────────────────────────┴────────┘
select * from demo.t_1
┌─────┬───────┬────┬──────────────┐
│ did │ index │ a │ b │
├─────┼───────┼────┼──────────────┤
│ 0 │ ¤ │ 42 │ hello world! │
│ 0 │ 1 │ 21 │ hello │
└─────┴───────┴────┴──────────────┘
select * from demo.t_2
┌─────┬───────┬────┐
│ did │ index │ j │
├─────┼───────┼────┤
│ 0 │ ¤ │ 42 │
└─────┴───────┴────┘
ToroDB @NoSQLonSQL
ToroDB storage internals
select * from demo.structures
┌─────┬────────────────────────────────────────────────────────────────────────────┐
│ sid │ _structure │
├─────┼────────────────────────────────────────────────────────────────────────────┤
│ 0 │ {"t": 3, "data": {"t": 1}, "nested": {"t": 2, "deeper": {"i": 1, "t": 1}}} │
└─────┴────────────────────────────────────────────────────────────────────────────┘
select * from demo.root;
┌─────┬─────┐
│ did │ sid │
├─────┼─────┤
│ 0 │ 0 │
└─────┴─────┘
ToroDB @NoSQLonSQL
ToroDB storage and I/O savings
29% - 68% storage required,
compared to Mongo 2.6
ToroDB @NoSQLonSQL
The software
ToroDB is written in Java, compatible with
versions 6 and above.
It has been tested on Oracle's VM, but we
will also test and verify it on Azul's VM.
It is currently a standalone JAR file but will
also be offered as an EAR, to easily
deploy to application servers.
ToroDB @NoSQLonSQL
Going beyond MongoDB
ToroDB @NoSQLonSQL
Going beyond MongoDB
MongoDB brought the document model
and several features that many love.
But can we go further than that?
Can't the foundation of relational
databases provide a basis for offering
new features on a NoSQL, document-like,
JSON database?
ToroDB @NoSQLonSQL
Going beyond MongoDB
●
Avoid schema repetition. Query-by-type
●
Cheap single-node durability
●
“Clean” reads
●
Atomic bulk operations
●
Highest concurrency
ToroDB @NoSQLonSQL
The schema-less fallacy
{
“name”: “Álvaro”,
“surname”: “Hernández”,
“height”: 200,
“hobbies”: [
“PostgreSQL”, “triathlon”
]
}
ToroDB @NoSQLonSQL
The schema-less fallacy
{
“name”: “Álvaro”,
“surname”: “Hernández”,
“height”: 200,
“hobbies”: [
“PostgreSQL”, “triathlon”
]
}
metadata → Isn't that... schema?
ToroDB @NoSQLonSQL
The schema-less fallacy: BSON
metadata → Isn't that... schema?
{
“name”: (string) “Álvaro”,
“surname”: (string) “Hernández”,
“height”: (number) 200,
“hobbies”: {
“0”: (string) “PostgreSQL” ,
“1”: (string) “triathlon”
}
}
ToroDB @NoSQLonSQL
The schema-less fallacy
●
It's not schema-less
●
It is “attached-schema”
●
It carries an overhead which is not 0
ToroDB @NoSQLonSQL
Schema-attached repetition
{ “a”: 1, “b”: 2 }
{ “a”: 3 }
{ “a”: 4, “c”: 5 }
{ “a”: 6, “b”: 7 }
{ “b”: 8 }
{ “a”: 9, “b”: 10 }
{ “a”: 11, “b”: 12, “j”: 13 }
{ “a”: 14, “c”: 15 }
Counting
“document
types” in
collections
of millions:
at most,
1000s of
different
types
ToroDB @NoSQLonSQL
Schema-attached repetition
How data is stored in schema-less
ToroDB @NoSQLonSQL
This is how we store in ToroDB
ToroDB @NoSQLonSQL
ToroDB: query “by structure”
●
ToroDB is effectively partitioning by
type
●
Structures (schemas, partitioning types)
are cached in ToroDB memory
●
Queries only scan a subset of the data.
●
Negative queries are served directly
from memory.
ToroDB @NoSQLonSQL
Cheap single-node durability
●
Without journaling, MongoDB is not
durable nor crash-safe
●
MongoDB requires “j: true” for true
single-node durability. But who
guarantees its consistent usage? Who
uses it by default?
j:true creates I/O storms equivalent to
SQL CHECKPOINTs
ToroDB @NoSQLonSQL
“Clean” reads
Oh really?
ToroDB @NoSQLonSQL
“Clean” reads
http://docs.mongodb.org/manual/reference/write-concern/#read-isolation-behavior
“MongoDB will allow clients to read the results of a
write operation before the write operation returns.”
“If the mongod terminates before the journal
commits, even if a write returns successfully, queries
may have read data that will not exist after the
mongod restarts.”
“Other database systems refer to these isolation
semantics as read uncommitted.”
ToroDB @NoSQLonSQL
“Clean” reads
Thus, MongoDB suffers from dirty reads.
Or probably better called “tainted
reads”.
What about $snapshot? Nope:
“The snapshot() does not guarantee that the data returned
by the query will reflect a single moment in time nor does it
provide isolation from insert or delete operations.”
http://docs.mongodb.org/manual/faq/developers/#faq-developers-isolate-cursors
ToroDB @NoSQLonSQL
ToroDB: going beyond MongoDB
●
Cheap single-node durability
PostgreSQL is 100% durable. Always.
And it's cheap (doesn't do I/O storms)
●
“Clean” reads
Cursors in ToroDB run in repeatable
read, read-only mode:
globalCursorDataSource.setTransactionIsolation("TRANSACTIO
N_REPEATABLE_READ");
globalCursorDataSource.setReadOnly(true);
ToroDB @NoSQLonSQL
Atomic operations
●
There is no support for atomic bulk
insert/update/delete operations
●
Not even with $isolated:
“Prevents a write operation that affects multiple documents
from yielding to other reads or writes […] You can ensure
that no client sees the changes until the operation completes
or errors out. The $isolated isolation operator does not
provide “all-or-nothing” atomicity for write
operations.”
http://docs.mongodb.org/manual/reference/operator/update/isolated/
ToroDB @NoSQLonSQL
High concurrency
●
MMAPv1 is still collection-locked
●
WiredTiger is document-locked
●
But still exclusive locks (MMAP). Most
relational databases have MVCC, which
means almost conflict-free readers and
writers at the same time
ToroDB @NoSQLonSQL
●
Atomic bulk operations
By default, bulk operations in ToroDB are
atomic. Use flag ContinueOnError: 1 to
perform non-atomic bulk operations
●
Highest concurrency
PostgreSQL uses MVCC. Readers and
writers do not block each other. Writers
block writers only for the same record
ToroDB: going beyond MongoDB
ToroDB @NoSQLonSQL
ToroDB: Developer Preview
●
ToroDB launched on October 2014, as
a Developer Preview. Support for CRUD
and most of the SELECT API
●
github.com/torodb
●
RERO policy. Comments, feedback,
patches... greatly appreciated
●
AGPLv3
ToroDB @NoSQLonSQL
ToroDB: Developer Preview
●
Clone the repo, build with Maven
●
Or download the JAR:
http://maven.torodb.com/jar/com/torodb/torodb/
0.20/torodb.jar
●
Usage:
java -jar torodb-0.20.jar –help
java -jar torodb-0.20.jar -d dbname -u dbuser -P 27017
Connect with normal mongo console!
ToroDB @NoSQLonSQL
ToroDB: Community Response
ToroDB @NoSQLonSQL
ToroDB: Community Response
ToroDB @NoSQLonSQL
ToroDB: Roadmap
●
Current Developer Preview is
single-node
●
Version 1.0:
➔
Expected Q4 2015
➔
Production-ready
➔
MongoDB Replication support
➔
Very high compatibility with Mongo API
ToroDB @NoSQLonSQL
ToroDB: Development priorities
#1 Offer MongoDB-like experience on
top of existing IT infrastructure, like
relational databases and app servers
#2 Go beyond current MongoDB
features, like in ACID and concurrency
#3 Great performance
ToroDB @NoSQLonSQL
ToroDB: Experimental research directions
●
User columnar storage (CitusDB)
●
Use Postgres-XL as a backend. This
requires us to distribute ToroDB's cache
(ehcache, Hazelcast)
●
Use pg_shard for sharding
ToroDB @NoSQLonSQL
Big Data speaking mongo:
Vertical ToroDB
What if we use CitusData's cstore to store
the JSON documents?
ToroDB @NoSQLonSQL
1.17% - 20.26% storage required,
compared to Mongo 2.6
Big Data speaking mongo:
Vertical ToroDB
Toro DB- Open-source, MongoDB-compatible database,  built on top of PostgreSQL

More Related Content

PDF
Case Studies on PostgreSQL
PPTX
Building Spark as Service in Cloud
PDF
PostgreSQL 9.5 - Major Features
PDF
PostgreSQL WAL for DBAs
PDF
PostgreSQL Write-Ahead Log (Heikki Linnakangas)
ODP
Logical replication with pglogical
PDF
Logical Replication in PostgreSQL - FLOSSUK 2016
PDF
PostgreSQL and RAM usage
Case Studies on PostgreSQL
Building Spark as Service in Cloud
PostgreSQL 9.5 - Major Features
PostgreSQL WAL for DBAs
PostgreSQL Write-Ahead Log (Heikki Linnakangas)
Logical replication with pglogical
Logical Replication in PostgreSQL - FLOSSUK 2016
PostgreSQL and RAM usage

What's hot (20)

PDF
Streaming huge databases using logical decoding
PDF
Patroni - HA PostgreSQL made easy
PDF
In-core compression: how to shrink your database size in several times
PDF
Demystifying postgres logical replication percona live sc
PDF
High Availability PostgreSQL with Zalando Patroni
PDF
Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installa...
PDF
Tuning Linux for Databases.
PDF
Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...
PPTX
Streaming replication in PostgreSQL
PDF
Streaming Replication (Keynote @ PostgreSQL Conference 2009 Japan)
PDF
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
PDF
Really Big Elephants: PostgreSQL DW
PDF
Query Parallelism in PostgreSQL: What's coming next?
PDF
PostgreSQL High Availability in a Containerized World
PDF
Get to know PostgreSQL!
PDF
Как PostgreSQL работает с диском
PDF
PostgreSQL and Redis - talk at pgcon 2013
PDF
PostgreSQL HA
PDF
Parallel Replication in MySQL and MariaDB
PDF
PostgreSQL 9.6 Performance-Scalability Improvements
Streaming huge databases using logical decoding
Patroni - HA PostgreSQL made easy
In-core compression: how to shrink your database size in several times
Demystifying postgres logical replication percona live sc
High Availability PostgreSQL with Zalando Patroni
Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installa...
Tuning Linux for Databases.
Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...
Streaming replication in PostgreSQL
Streaming Replication (Keynote @ PostgreSQL Conference 2009 Japan)
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
Really Big Elephants: PostgreSQL DW
Query Parallelism in PostgreSQL: What's coming next?
PostgreSQL High Availability in a Containerized World
Get to know PostgreSQL!
Как PostgreSQL работает с диском
PostgreSQL and Redis - talk at pgcon 2013
PostgreSQL HA
Parallel Replication in MySQL and MariaDB
PostgreSQL 9.6 Performance-Scalability Improvements
Ad

Viewers also liked (20)

PDF
Attacking Web Proxies
PDF
Optimizer Hints
PDF
Introduction to cocoa sql mapper
PDF
Building Machine Learning Pipelines
PPTX
Cloud Computing (CCSME 2015 talk) - mypapit
DOCX
Available for sale
PPTX
Igualdad libertad
PPTX
Scenic royal kingdom of rajasthan tour itarnary for 9 Nights 10 Days
PDF
Booklets
PPTX
CA World 2010 Wily Impact Awards - Axciom
PDF
Tools and Methodology for Research: Future of Science
PPTX
інновації для сайта
PPTX
PHP Security Tips
PPTX
Sanbenitofuneraria
PPTX
130811 高専カンファレンスin岐阜2
PPTX
Calidad 1 clases 081010
PPT
Mobile, Mobile, Data
POT
赛马会官方网址 SlideShare
PPTX
SCHF 2012 - Fare SMM nel B2B: si può? L’esperienza SAP Italia
Attacking Web Proxies
Optimizer Hints
Introduction to cocoa sql mapper
Building Machine Learning Pipelines
Cloud Computing (CCSME 2015 talk) - mypapit
Available for sale
Igualdad libertad
Scenic royal kingdom of rajasthan tour itarnary for 9 Nights 10 Days
Booklets
CA World 2010 Wily Impact Awards - Axciom
Tools and Methodology for Research: Future of Science
інновації для сайта
PHP Security Tips
Sanbenitofuneraria
130811 高専カンファレンスin岐阜2
Calidad 1 clases 081010
Mobile, Mobile, Data
赛马会官方网址 SlideShare
SCHF 2012 - Fare SMM nel B2B: si può? L’esperienza SAP Italia
Ad

Similar to Toro DB- Open-source, MongoDB-compatible database, built on top of PostgreSQL (20)

PDF
ToroDB: scaling PostgreSQL like MongoDB / Álvaro Hernández Tortosa (8Kdata)
PDF
ToroDB: Scaling PostgreSQL like MongoDB by Álvaro Hernández at Big Data Spain...
PPTX
Mongo db
PPTX
Kalp Corporate MongoDB Tutorials
PPTX
Python Ireland Conference 2016 - Python and MongoDB Workshop
ODP
Introduction to MongoDB
PPTX
NOSQL and MongoDB Database
PDF
PDF
Introduction to MongoDB
PPTX
Mongo db intro.pptx
PDF
MongoDB
PDF
A Study on Mongodb Database
PDF
A Study on Mongodb Database.pdf
PPT
Introduction to MongoDB
PPT
Mongo Bb - NoSQL tutorial
PPT
MongoDb - Details on the POC
PDF
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
PDF
Introduction to MongoDB Basics from SQL to NoSQL
PDF
Introduction to MongoDB
ODP
MongoDB - A Document NoSQL Database
ToroDB: scaling PostgreSQL like MongoDB / Álvaro Hernández Tortosa (8Kdata)
ToroDB: Scaling PostgreSQL like MongoDB by Álvaro Hernández at Big Data Spain...
Mongo db
Kalp Corporate MongoDB Tutorials
Python Ireland Conference 2016 - Python and MongoDB Workshop
Introduction to MongoDB
NOSQL and MongoDB Database
Introduction to MongoDB
Mongo db intro.pptx
MongoDB
A Study on Mongodb Database
A Study on Mongodb Database.pdf
Introduction to MongoDB
Mongo Bb - NoSQL tutorial
MongoDb - Details on the POC
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
Introduction to MongoDB Basics from SQL to NoSQL
Introduction to MongoDB
MongoDB - A Document NoSQL Database

More from InMobi Technology (20)

PDF
Ensemble Methods for Algorithmic Trading
PPTX
Backbone & Graphs
PDF
24/7 Monitoring and Alerting of PostgreSQL
PPTX
Reflective and Stored XSS- Cross Site Scripting
PDF
Introduction to Threat Modeling
PDF
HTTP Basics Demo
PDF
The Synapse IoT Stack: Technology Trends in IOT and Big Data
PPTX
What's new in Hadoop Yarn- Dec 2014
PPTX
Security News Bytes Null Dec Meet Bangalore
PPTX
Matriux blue
PPTX
PCI DSS v3 - Protecting Cardholder data
PDF
Running Hadoop as Service in AltiScale Platform
PPTX
Shodan- That Device Search Engine
PPTX
Big Data BI Simplified
PDF
Massively Parallel Processing with Procedural Python - Pivotal HAWQ
PPTX
Tez Data Processing over Yarn
PDF
Building Audience Analytics Platform
PPTX
Big Data and User Segmentation in Mobile Context
PDF
Freedom Hack Report 2014
PPTX
Hadoop fundamentals
Ensemble Methods for Algorithmic Trading
Backbone & Graphs
24/7 Monitoring and Alerting of PostgreSQL
Reflective and Stored XSS- Cross Site Scripting
Introduction to Threat Modeling
HTTP Basics Demo
The Synapse IoT Stack: Technology Trends in IOT and Big Data
What's new in Hadoop Yarn- Dec 2014
Security News Bytes Null Dec Meet Bangalore
Matriux blue
PCI DSS v3 - Protecting Cardholder data
Running Hadoop as Service in AltiScale Platform
Shodan- That Device Search Engine
Big Data BI Simplified
Massively Parallel Processing with Procedural Python - Pivotal HAWQ
Tez Data Processing over Yarn
Building Audience Analytics Platform
Big Data and User Segmentation in Mobile Context
Freedom Hack Report 2014
Hadoop fundamentals

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Programs and apps: productivity, graphics, security and other tools
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Electronic commerce courselecture one. Pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Encapsulation theory and applications.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
sap open course for s4hana steps from ECC to s4
Programs and apps: productivity, graphics, security and other tools
The AUB Centre for AI in Media Proposal.docx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Chapter 3 Spatial Domain Image Processing.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Per capita expenditure prediction using model stacking based on satellite ima...
Understanding_Digital_Forensics_Presentation.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Electronic commerce courselecture one. Pdf
MIND Revenue Release Quarter 2 2025 Press Release
Encapsulation theory and applications.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Agricultural_Statistics_at_a_Glance_2022_0.pdf

Toro DB- Open-source, MongoDB-compatible database, built on top of PostgreSQL

  • 1. ToroDB Open-source, MongoDB-compatible database, built on top of PostgreSQL Álvaro Hernández <aht@torodb.com>
  • 3. ToroDB @NoSQLonSQL About *8Kdata* ● Research & Development in databases ● Consulting, Training and Support in PostgreSQL ● Founders of PostgreSQL España, 3rd largest PUG in the world (>400 members as of today) ● About myself: CTO at 8Kdata: @ahachete http://linkd.in/1jhvzQ3 www.8kdata.com
  • 4. ToroDB @NoSQLonSQL ToroDB in one slide ● Document-oriented, JSON, NoSQL db ● Open source (AGPL) ● MongoDB compatibility (wire protocol level) ● Uses PostgreSQL as a storage backend
  • 5. ToroDB @NoSQLonSQL Why relational databases: technical perspective ● Document model is very appealing to many. But all dbs started from scratch ● DRY: why not use relational databases? They are proven, durable, concurrent and flexible ● Why not base it on relational databases, like PostgreSQL?
  • 7. ToroDB @NoSQLonSQL ToroDB storage ● Data is stored in tables. No blobs ● JSON documents are split by hierarchy levels into “subdocuments”, which contain no nested structures. Each subdocument level is stored separately ● Subdocuments are classified by “type”. Each “type” maps to a different table
  • 8. ToroDB @NoSQLonSQL ToroDB storage (II) ● A “structure” table keeps the subdocument “schema” ● Keys in JSON are mapped to attributes, which retain the original name ● Tables are created dinamically and transparently to match the exact types of the documents
  • 9. ToroDB @NoSQLonSQL ToroDB storage internals { "name": "ToroDB", "data": { "a": 42, "b": "hello world!" }, "nested": { "j": 42, "deeper": { "a": 21, "b": "hello" } } }
  • 10. ToroDB @NoSQLonSQL ToroDB storage internals The document is split into the following subdocuments: { "name": "ToroDB", "data": {}, "nested": {} } { "a": 42, "b": "hello world!"} { "j": 42, "deeper": {}} { "a": 21, "b": "hello"}
  • 11. ToroDB @NoSQLonSQL ToroDB storage internals select * from demo.t_3 ┌─────┬───────┬────────────────────────────┬────────┐ │ did │ index │ _id │ name │ ├─────┼───────┼────────────────────────────┼────────┤ │ 0 │ ¤ │ x5451a07de7032d23a908576d │ ToroDB │ └─────┴───────┴────────────────────────────┴────────┘ select * from demo.t_1 ┌─────┬───────┬────┬──────────────┐ │ did │ index │ a │ b │ ├─────┼───────┼────┼──────────────┤ │ 0 │ ¤ │ 42 │ hello world! │ │ 0 │ 1 │ 21 │ hello │ └─────┴───────┴────┴──────────────┘ select * from demo.t_2 ┌─────┬───────┬────┐ │ did │ index │ j │ ├─────┼───────┼────┤ │ 0 │ ¤ │ 42 │ └─────┴───────┴────┘
  • 12. ToroDB @NoSQLonSQL ToroDB storage internals select * from demo.structures ┌─────┬────────────────────────────────────────────────────────────────────────────┐ │ sid │ _structure │ ├─────┼────────────────────────────────────────────────────────────────────────────┤ │ 0 │ {"t": 3, "data": {"t": 1}, "nested": {"t": 2, "deeper": {"i": 1, "t": 1}}} │ └─────┴────────────────────────────────────────────────────────────────────────────┘ select * from demo.root; ┌─────┬─────┐ │ did │ sid │ ├─────┼─────┤ │ 0 │ 0 │ └─────┴─────┘
  • 13. ToroDB @NoSQLonSQL ToroDB storage and I/O savings 29% - 68% storage required, compared to Mongo 2.6
  • 14. ToroDB @NoSQLonSQL The software ToroDB is written in Java, compatible with versions 6 and above. It has been tested on Oracle's VM, but we will also test and verify it on Azul's VM. It is currently a standalone JAR file but will also be offered as an EAR, to easily deploy to application servers.
  • 16. ToroDB @NoSQLonSQL Going beyond MongoDB MongoDB brought the document model and several features that many love. But can we go further than that? Can't the foundation of relational databases provide a basis for offering new features on a NoSQL, document-like, JSON database?
  • 17. ToroDB @NoSQLonSQL Going beyond MongoDB ● Avoid schema repetition. Query-by-type ● Cheap single-node durability ● “Clean” reads ● Atomic bulk operations ● Highest concurrency
  • 18. ToroDB @NoSQLonSQL The schema-less fallacy { “name”: “Álvaro”, “surname”: “Hernández”, “height”: 200, “hobbies”: [ “PostgreSQL”, “triathlon” ] }
  • 19. ToroDB @NoSQLonSQL The schema-less fallacy { “name”: “Álvaro”, “surname”: “Hernández”, “height”: 200, “hobbies”: [ “PostgreSQL”, “triathlon” ] } metadata → Isn't that... schema?
  • 20. ToroDB @NoSQLonSQL The schema-less fallacy: BSON metadata → Isn't that... schema? { “name”: (string) “Álvaro”, “surname”: (string) “Hernández”, “height”: (number) 200, “hobbies”: { “0”: (string) “PostgreSQL” , “1”: (string) “triathlon” } }
  • 21. ToroDB @NoSQLonSQL The schema-less fallacy ● It's not schema-less ● It is “attached-schema” ● It carries an overhead which is not 0
  • 22. ToroDB @NoSQLonSQL Schema-attached repetition { “a”: 1, “b”: 2 } { “a”: 3 } { “a”: 4, “c”: 5 } { “a”: 6, “b”: 7 } { “b”: 8 } { “a”: 9, “b”: 10 } { “a”: 11, “b”: 12, “j”: 13 } { “a”: 14, “c”: 15 } Counting “document types” in collections of millions: at most, 1000s of different types
  • 23. ToroDB @NoSQLonSQL Schema-attached repetition How data is stored in schema-less
  • 24. ToroDB @NoSQLonSQL This is how we store in ToroDB
  • 25. ToroDB @NoSQLonSQL ToroDB: query “by structure” ● ToroDB is effectively partitioning by type ● Structures (schemas, partitioning types) are cached in ToroDB memory ● Queries only scan a subset of the data. ● Negative queries are served directly from memory.
  • 26. ToroDB @NoSQLonSQL Cheap single-node durability ● Without journaling, MongoDB is not durable nor crash-safe ● MongoDB requires “j: true” for true single-node durability. But who guarantees its consistent usage? Who uses it by default? j:true creates I/O storms equivalent to SQL CHECKPOINTs
  • 28. ToroDB @NoSQLonSQL “Clean” reads http://docs.mongodb.org/manual/reference/write-concern/#read-isolation-behavior “MongoDB will allow clients to read the results of a write operation before the write operation returns.” “If the mongod terminates before the journal commits, even if a write returns successfully, queries may have read data that will not exist after the mongod restarts.” “Other database systems refer to these isolation semantics as read uncommitted.”
  • 29. ToroDB @NoSQLonSQL “Clean” reads Thus, MongoDB suffers from dirty reads. Or probably better called “tainted reads”. What about $snapshot? Nope: “The snapshot() does not guarantee that the data returned by the query will reflect a single moment in time nor does it provide isolation from insert or delete operations.” http://docs.mongodb.org/manual/faq/developers/#faq-developers-isolate-cursors
  • 30. ToroDB @NoSQLonSQL ToroDB: going beyond MongoDB ● Cheap single-node durability PostgreSQL is 100% durable. Always. And it's cheap (doesn't do I/O storms) ● “Clean” reads Cursors in ToroDB run in repeatable read, read-only mode: globalCursorDataSource.setTransactionIsolation("TRANSACTIO N_REPEATABLE_READ"); globalCursorDataSource.setReadOnly(true);
  • 31. ToroDB @NoSQLonSQL Atomic operations ● There is no support for atomic bulk insert/update/delete operations ● Not even with $isolated: “Prevents a write operation that affects multiple documents from yielding to other reads or writes […] You can ensure that no client sees the changes until the operation completes or errors out. The $isolated isolation operator does not provide “all-or-nothing” atomicity for write operations.” http://docs.mongodb.org/manual/reference/operator/update/isolated/
  • 32. ToroDB @NoSQLonSQL High concurrency ● MMAPv1 is still collection-locked ● WiredTiger is document-locked ● But still exclusive locks (MMAP). Most relational databases have MVCC, which means almost conflict-free readers and writers at the same time
  • 33. ToroDB @NoSQLonSQL ● Atomic bulk operations By default, bulk operations in ToroDB are atomic. Use flag ContinueOnError: 1 to perform non-atomic bulk operations ● Highest concurrency PostgreSQL uses MVCC. Readers and writers do not block each other. Writers block writers only for the same record ToroDB: going beyond MongoDB
  • 34. ToroDB @NoSQLonSQL ToroDB: Developer Preview ● ToroDB launched on October 2014, as a Developer Preview. Support for CRUD and most of the SELECT API ● github.com/torodb ● RERO policy. Comments, feedback, patches... greatly appreciated ● AGPLv3
  • 35. ToroDB @NoSQLonSQL ToroDB: Developer Preview ● Clone the repo, build with Maven ● Or download the JAR: http://maven.torodb.com/jar/com/torodb/torodb/ 0.20/torodb.jar ● Usage: java -jar torodb-0.20.jar –help java -jar torodb-0.20.jar -d dbname -u dbuser -P 27017 Connect with normal mongo console!
  • 38. ToroDB @NoSQLonSQL ToroDB: Roadmap ● Current Developer Preview is single-node ● Version 1.0: ➔ Expected Q4 2015 ➔ Production-ready ➔ MongoDB Replication support ➔ Very high compatibility with Mongo API
  • 39. ToroDB @NoSQLonSQL ToroDB: Development priorities #1 Offer MongoDB-like experience on top of existing IT infrastructure, like relational databases and app servers #2 Go beyond current MongoDB features, like in ACID and concurrency #3 Great performance
  • 40. ToroDB @NoSQLonSQL ToroDB: Experimental research directions ● User columnar storage (CitusDB) ● Use Postgres-XL as a backend. This requires us to distribute ToroDB's cache (ehcache, Hazelcast) ● Use pg_shard for sharding
  • 41. ToroDB @NoSQLonSQL Big Data speaking mongo: Vertical ToroDB What if we use CitusData's cstore to store the JSON documents?
  • 42. ToroDB @NoSQLonSQL 1.17% - 20.26% storage required, compared to Mongo 2.6 Big Data speaking mongo: Vertical ToroDB