SlideShare a Scribd company logo
omnibus database machine 
How to NoSQL in Postgres with Django
so much database 
I’m Aleck 
mainly: django + python + js 
github.com/alecklandgraf 
@aleck_landgraf 
aleck@buildingenergy.com 
I’m Gavin 
github.com/gmcquillan 
@gmcquillan
our use case 
people want to load their data… 
… and play with it: 
- django app for managing building data 
- unstructured data 
- relational data 
- orgs/perms/projects 
- utility meter ts data
we have unstructured data 
- lack of fixed schema 
- can create new fields without DB migration 
- 2,000 fields in the standard ontology 
- business logic (MCM) to map raw data to an 
ontology if possible 
- other logic to keep track of keys 
- different for each user or organization
we have relational data 
- everything we load relates to everything else 
in the system 
- buildings → organizations → permissions 
- buildings → utilities → meters → ts data 
- building v12010 → building v22011
unstructured and relational data 
- django can connect to mongo 
- django can connect to postgres 
- complex 
- is there something better?
PostgreSQL 9.2+ JSON type 
- native type for JSON (9.4+ jsonb) 
- GIN index, soon GiST index 
- supports search and lookup 
- easy to convert python dict to json 
- json is the de facto standard for web APIs
why not mongo * 
- MongoDB doesn’t seem to be more 
performant than PostgreSQL. 
- And you still get all of PostgreSQL’s goodies. 
- Larger documents will probably continue to 
favor PostgreSQL. 
- As will larger tables. 
*from Christophe Pettus’ talk at OSCON ‘13
did someone say django app? 
- are you ready to get beta 
- django-pgjson (version 0.2.0, 2014-09-13) 
- works best with dev postgres 9.4 and Django 
1.7+ 
- in beta development 
- also a kickstarter project to help build some of 
this out
setting up your django model 
from django.db import models 
from django_pgjson.fields import JsonField 
class Something(models.Model): 
name = models.CharField(max_length=32) 
data = JsonField()
querying the JSON data 
>>> Something.object.bulk_create([ 
... Something(data={"name": "foo", "tags": ["sad", "romantic"]}), 
... Something(data={"name": "bar", "tags": ["sad", "intelligent"]}) 
... ]) 
>>> Something.objects.filter(data__at_name="foo").count() 
1 
>>> Something.objects.filter(data__jcontains={"tags": ["sad"]}).count() 
2
what about order_by and distinct? 
- unsupported until PSQL 9.4 with jsonb 
- we wrote our own inside a custom queryset 
if order_by not in known_columns: 
qs = list(qs) 
qs.sort( 
key=lambda x: getattr(x, field).get(order_by), 
reverse=order_by_rev 
)
JSON value order_by in SQL 
SELECT id, NULLIF(extra_data->>'Total GHG Emissions (MtCO2e)', 
'')::float AS ghg_emissions from seed_buildingsnapshot WHERE 
extra_data->>'Total GHG Emissions (MtCO2e)' != '' ORDER BY 
NULLIF(extra_data->>'Total GHG Emissions (MtCO2e)', '')::float 
DESC LIMIT 10; 
Django order_by doesn’t 
work on ‘non-model-fields’
order_by 
- can also push it to Postgres with a PL script 
- http://hyperthese.net/post/sorting-json-fields-in- 
postgresql/ 
- jsonb support in Postgres 9.4 for this, but not 
for json
is this fast?
who is using this? 
With JSONB and other enhancements in 9.4 "we 
now have full document storage and awesome 
performance with little effort," explained Craig 
Kerstiens, a developer at Salesforce-backed 
Heroku, in a personal blog post.
further thoughts 
- Postgresql full text search with JSON? 
- joins
links 
- https://github.com/djangonauts/django-pgjson 
- http://www.postgresql.org/docs/9.4/static/functions-json.html 
- http://thebuild.com/presentations/pg-as-nosql-pgday-fosdem-2013.pdf 
- http://www.postgresql.org/docs/9.4/static/datatype-json.html 
- http://lwn.net/Articles/599705/ 
- http://simko.home.cern.ch/simko/postgresql-mongodb-json-select-speed. 
html

More Related Content

What's hot

MongoDB - Ekino PHP
MongoDB - Ekino PHPMongoDB - Ekino PHP
MongoDB - Ekino PHP
Florent DENIS
 
Andrew Dunstan 9.3 JSON Presentation @ Postgres Open 2013
Andrew Dunstan 9.3 JSON Presentation @ Postgres Open 2013Andrew Dunstan 9.3 JSON Presentation @ Postgres Open 2013
Andrew Dunstan 9.3 JSON Presentation @ Postgres Open 2013
PostgresOpen
 
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
MongoDB
 
Introduction to MongoDB at IGDTUW
Introduction to MongoDB at IGDTUWIntroduction to MongoDB at IGDTUW
Introduction to MongoDB at IGDTUW
Ankur Raina
 
Latinoware
LatinowareLatinoware
Latinoware
kchodorow
 
Sydney Python Presentation (Feb 2010) - Tracking Large Metallic Objects / Goo...
Sydney Python Presentation (Feb 2010) - Tracking Large Metallic Objects / Goo...Sydney Python Presentation (Feb 2010) - Tracking Large Metallic Objects / Goo...
Sydney Python Presentation (Feb 2010) - Tracking Large Metallic Objects / Goo...
Kelvin Nicholson
 
Querying mongo db
Querying mongo dbQuerying mongo db
Querying mongo db
Bogdan Sabău
 
Back to Basics 2017: Mí primera aplicación MongoDB
Back to Basics 2017: Mí primera aplicación MongoDBBack to Basics 2017: Mí primera aplicación MongoDB
Back to Basics 2017: Mí primera aplicación MongoDB
MongoDB
 
MongoDB - A Document NoSQL Database
MongoDB - A Document NoSQL DatabaseMongoDB - A Document NoSQL Database
MongoDB - A Document NoSQL Database
Ruben Inoto Soto
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
Algiers Tech Meetup
 
Ebook Pembuatan Aplikasi Rental film 2012
Ebook Pembuatan Aplikasi Rental film 2012Ebook Pembuatan Aplikasi Rental film 2012
Ebook Pembuatan Aplikasi Rental film 2012
yantoit2011
 
Back to Basics Spanish 4 Introduction to sharding
Back to Basics Spanish 4 Introduction to shardingBack to Basics Spanish 4 Introduction to sharding
Back to Basics Spanish 4 Introduction to sharding
MongoDB
 
2011 mongo FR - scaling with mongodb
2011 mongo FR - scaling with mongodb2011 mongo FR - scaling with mongodb
2011 mongo FR - scaling with mongodb
antoinegirbal
 
Mongo db updatedocumentusecases
Mongo db updatedocumentusecasesMongo db updatedocumentusecases
Mongo db updatedocumentusecases
zarigatongy
 
Connecting and using PostgreSQL database with psycopg2 [Python 2.7]
Connecting and using PostgreSQL database with psycopg2 [Python 2.7]Connecting and using PostgreSQL database with psycopg2 [Python 2.7]
Connecting and using PostgreSQL database with psycopg2 [Python 2.7]
Dinesh Neupane
 
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDBMongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB
 
mongoDB Performance
mongoDB PerformancemongoDB Performance
mongoDB Performance
Moshe Kaplan
 
NoSQL Infrastructure
NoSQL InfrastructureNoSQL Infrastructure
NoSQL Infrastructure
Server Density
 
Do something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appDo something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing app
Bruce McPherson
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 

What's hot (20)

MongoDB - Ekino PHP
MongoDB - Ekino PHPMongoDB - Ekino PHP
MongoDB - Ekino PHP
 
Andrew Dunstan 9.3 JSON Presentation @ Postgres Open 2013
Andrew Dunstan 9.3 JSON Presentation @ Postgres Open 2013Andrew Dunstan 9.3 JSON Presentation @ Postgres Open 2013
Andrew Dunstan 9.3 JSON Presentation @ Postgres Open 2013
 
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
MongoDB.local DC 2018: Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Applic...
 
Introduction to MongoDB at IGDTUW
Introduction to MongoDB at IGDTUWIntroduction to MongoDB at IGDTUW
Introduction to MongoDB at IGDTUW
 
Latinoware
LatinowareLatinoware
Latinoware
 
Sydney Python Presentation (Feb 2010) - Tracking Large Metallic Objects / Goo...
Sydney Python Presentation (Feb 2010) - Tracking Large Metallic Objects / Goo...Sydney Python Presentation (Feb 2010) - Tracking Large Metallic Objects / Goo...
Sydney Python Presentation (Feb 2010) - Tracking Large Metallic Objects / Goo...
 
Querying mongo db
Querying mongo dbQuerying mongo db
Querying mongo db
 
Back to Basics 2017: Mí primera aplicación MongoDB
Back to Basics 2017: Mí primera aplicación MongoDBBack to Basics 2017: Mí primera aplicación MongoDB
Back to Basics 2017: Mí primera aplicación MongoDB
 
MongoDB - A Document NoSQL Database
MongoDB - A Document NoSQL DatabaseMongoDB - A Document NoSQL Database
MongoDB - A Document NoSQL Database
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Ebook Pembuatan Aplikasi Rental film 2012
Ebook Pembuatan Aplikasi Rental film 2012Ebook Pembuatan Aplikasi Rental film 2012
Ebook Pembuatan Aplikasi Rental film 2012
 
Back to Basics Spanish 4 Introduction to sharding
Back to Basics Spanish 4 Introduction to shardingBack to Basics Spanish 4 Introduction to sharding
Back to Basics Spanish 4 Introduction to sharding
 
2011 mongo FR - scaling with mongodb
2011 mongo FR - scaling with mongodb2011 mongo FR - scaling with mongodb
2011 mongo FR - scaling with mongodb
 
Mongo db updatedocumentusecases
Mongo db updatedocumentusecasesMongo db updatedocumentusecases
Mongo db updatedocumentusecases
 
Connecting and using PostgreSQL database with psycopg2 [Python 2.7]
Connecting and using PostgreSQL database with psycopg2 [Python 2.7]Connecting and using PostgreSQL database with psycopg2 [Python 2.7]
Connecting and using PostgreSQL database with psycopg2 [Python 2.7]
 
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDBMongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
 
mongoDB Performance
mongoDB PerformancemongoDB Performance
mongoDB Performance
 
NoSQL Infrastructure
NoSQL InfrastructureNoSQL Infrastructure
NoSQL Infrastructure
 
Do something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appDo something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing app
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
 

Viewers also liked

Hex Series
Hex SeriesHex Series
Hex Series
TECHNOMED INDIA
 
Website evaluation
Website evaluationWebsite evaluation
Website evaluation
MrsCragle
 
Innovators Jumpstart 2015- McInnes Cooper (Business Structure Basics)
Innovators Jumpstart 2015- McInnes Cooper (Business Structure Basics)Innovators Jumpstart 2015- McInnes Cooper (Business Structure Basics)
Innovators Jumpstart 2015- McInnes Cooper (Business Structure Basics)
PlanetHatch
 
CEC
CECCEC
CEC
WSCCEC
 
La vote ory 2 (no animations)
La vote ory 2 (no animations)La vote ory 2 (no animations)
La vote ory 2 (no animations)
DrBamboozler
 
2014 EMBEDDED TITLES FOR BE, ME
2014 EMBEDDED TITLES FOR BE, ME2014 EMBEDDED TITLES FOR BE, ME
2014 EMBEDDED TITLES FOR BE, ME
BlueChip Technology
 
BionicMe
BionicMeBionicMe
BionicMe
Bionicme
 
Baltijas ceļa pasākumi ārvalstīs augustā un septembrī
Baltijas ceļa pasākumi ārvalstīs augustā un septembrīBaltijas ceļa pasākumi ārvalstīs augustā un septembrī
Baltijas ceļa pasākumi ārvalstīs augustā un septembrī
Valdības māja
 
27.2015.qđ.t tg
27.2015.qđ.t tg27.2015.qđ.t tg
27.2015.qđ.t tg
Mèo Hoang
 
About profession
About professionAbout profession
About profession
Chris Chang
 
Advanta Healthcare Partners Capabilities
Advanta Healthcare Partners Capabilities Advanta Healthcare Partners Capabilities
Advanta Healthcare Partners Capabilities
Advanta
 
Kts c2-dai so boole
Kts c2-dai so booleKts c2-dai so boole
Kts c2-dai so boole
Wang Ruan
 
39.2015.tt.bnnptnt
39.2015.tt.bnnptnt39.2015.tt.bnnptnt
39.2015.tt.bnnptnt
Mèo Hoang
 
Epam BI - Near Realtime Marketing Support System
Epam BI - Near Realtime Marketing Support SystemEpam BI - Near Realtime Marketing Support System
Epam BI - Near Realtime Marketing Support System
Dmitry Tolpeko
 
Corbett gardens cat hearing presentation 2015
Corbett gardens cat hearing presentation 2015Corbett gardens cat hearing presentation 2015
Corbett gardens cat hearing presentation 2015
WSCCEC
 
Innovators Jumpstart 2015-Booking for Small Businesses
Innovators Jumpstart 2015-Booking for Small Businesses Innovators Jumpstart 2015-Booking for Small Businesses
Innovators Jumpstart 2015-Booking for Small Businesses
PlanetHatch
 
46/2015/NĐ-CP về quản lý chất lượng công trình xây dựng
46/2015/NĐ-CP về quản lý chất lượng công trình xây dựng46/2015/NĐ-CP về quản lý chất lượng công trình xây dựng
46/2015/NĐ-CP về quản lý chất lượng công trình xây dựng
Mèo Hoang
 
Thecompellingimage sxsw
Thecompellingimage sxswThecompellingimage sxsw
Thecompellingimage sxsw
Marty Coleman
 
Innovators Jumpstart 2015-NBIF (The Perfect Pitch)
Innovators Jumpstart 2015-NBIF (The Perfect Pitch)Innovators Jumpstart 2015-NBIF (The Perfect Pitch)
Innovators Jumpstart 2015-NBIF (The Perfect Pitch)
PlanetHatch
 
淺談測試Part1
淺談測試Part1淺談測試Part1
淺談測試Part1
Chris Chang
 

Viewers also liked (20)

Hex Series
Hex SeriesHex Series
Hex Series
 
Website evaluation
Website evaluationWebsite evaluation
Website evaluation
 
Innovators Jumpstart 2015- McInnes Cooper (Business Structure Basics)
Innovators Jumpstart 2015- McInnes Cooper (Business Structure Basics)Innovators Jumpstart 2015- McInnes Cooper (Business Structure Basics)
Innovators Jumpstart 2015- McInnes Cooper (Business Structure Basics)
 
CEC
CECCEC
CEC
 
La vote ory 2 (no animations)
La vote ory 2 (no animations)La vote ory 2 (no animations)
La vote ory 2 (no animations)
 
2014 EMBEDDED TITLES FOR BE, ME
2014 EMBEDDED TITLES FOR BE, ME2014 EMBEDDED TITLES FOR BE, ME
2014 EMBEDDED TITLES FOR BE, ME
 
BionicMe
BionicMeBionicMe
BionicMe
 
Baltijas ceļa pasākumi ārvalstīs augustā un septembrī
Baltijas ceļa pasākumi ārvalstīs augustā un septembrīBaltijas ceļa pasākumi ārvalstīs augustā un septembrī
Baltijas ceļa pasākumi ārvalstīs augustā un septembrī
 
27.2015.qđ.t tg
27.2015.qđ.t tg27.2015.qđ.t tg
27.2015.qđ.t tg
 
About profession
About professionAbout profession
About profession
 
Advanta Healthcare Partners Capabilities
Advanta Healthcare Partners Capabilities Advanta Healthcare Partners Capabilities
Advanta Healthcare Partners Capabilities
 
Kts c2-dai so boole
Kts c2-dai so booleKts c2-dai so boole
Kts c2-dai so boole
 
39.2015.tt.bnnptnt
39.2015.tt.bnnptnt39.2015.tt.bnnptnt
39.2015.tt.bnnptnt
 
Epam BI - Near Realtime Marketing Support System
Epam BI - Near Realtime Marketing Support SystemEpam BI - Near Realtime Marketing Support System
Epam BI - Near Realtime Marketing Support System
 
Corbett gardens cat hearing presentation 2015
Corbett gardens cat hearing presentation 2015Corbett gardens cat hearing presentation 2015
Corbett gardens cat hearing presentation 2015
 
Innovators Jumpstart 2015-Booking for Small Businesses
Innovators Jumpstart 2015-Booking for Small Businesses Innovators Jumpstart 2015-Booking for Small Businesses
Innovators Jumpstart 2015-Booking for Small Businesses
 
46/2015/NĐ-CP về quản lý chất lượng công trình xây dựng
46/2015/NĐ-CP về quản lý chất lượng công trình xây dựng46/2015/NĐ-CP về quản lý chất lượng công trình xây dựng
46/2015/NĐ-CP về quản lý chất lượng công trình xây dựng
 
Thecompellingimage sxsw
Thecompellingimage sxswThecompellingimage sxsw
Thecompellingimage sxsw
 
Innovators Jumpstart 2015-NBIF (The Perfect Pitch)
Innovators Jumpstart 2015-NBIF (The Perfect Pitch)Innovators Jumpstart 2015-NBIF (The Perfect Pitch)
Innovators Jumpstart 2015-NBIF (The Perfect Pitch)
 
淺談測試Part1
淺談測試Part1淺談測試Part1
淺談測試Part1
 

Similar to Omnibus database machine

20160407_GTC2016_PgSQL_In_Place
20160407_GTC2016_PgSQL_In_Place20160407_GTC2016_PgSQL_In_Place
20160407_GTC2016_PgSQL_In_Place
Kohei KaiGai
 
Full-Stack Data Science: How to be a One-person Data Team
Full-Stack Data Science: How to be a One-person Data TeamFull-Stack Data Science: How to be a One-person Data Team
Full-Stack Data Science: How to be a One-person Data Team
Greg Goltsov
 
Mongo db dla administratora
Mongo db dla administratoraMongo db dla administratora
Mongo db dla administratora
Łukasz Jagiełło
 
Webscale PostgreSQL - JSONB and Horizontal Scaling Strategies
Webscale PostgreSQL - JSONB and Horizontal Scaling StrategiesWebscale PostgreSQL - JSONB and Horizontal Scaling Strategies
Webscale PostgreSQL - JSONB and Horizontal Scaling Strategies
Jonathan Katz
 
NoSQL meets Microservices - Michael Hackstein
NoSQL meets Microservices -  Michael HacksteinNoSQL meets Microservices -  Michael Hackstein
NoSQL meets Microservices - Michael Hackstein
distributed matters
 
Gur1009
Gur1009Gur1009
Gur1009
Cdiscount
 
Spark SQL - 10 Things You Need to Know
Spark SQL - 10 Things You Need to KnowSpark SQL - 10 Things You Need to Know
Spark SQL - 10 Things You Need to Know
Kristian Alexander
 
Get expertise with mongo db
Get expertise with mongo dbGet expertise with mongo db
Get expertise with mongo db
Amit Thakkar
 
Giovanni Lanzani – SQL & NoSQL databases for data driven applications - NoSQL...
Giovanni Lanzani – SQL & NoSQL databases for data driven applications - NoSQL...Giovanni Lanzani – SQL & NoSQL databases for data driven applications - NoSQL...
Giovanni Lanzani – SQL & NoSQL databases for data driven applications - NoSQL...
NoSQLmatters
 
Data Types/Structures in DivConq
Data Types/Structures in DivConqData Types/Structures in DivConq
Data Types/Structures in DivConq
eTimeline, LLC
 
Prestogres internals
Prestogres internalsPrestogres internals
Prestogres internals
Sadayuki Furuhashi
 
D3 Mapping Visualization
D3 Mapping VisualizationD3 Mapping Visualization
D3 Mapping Visualization
Sudhir Chowbina
 
Working with JSON Data in PostgreSQL vs. MongoDB
Working with JSON Data in PostgreSQL vs. MongoDBWorking with JSON Data in PostgreSQL vs. MongoDB
Working with JSON Data in PostgreSQL vs. MongoDB
ScaleGrid.io
 
Lessons Learned While Scaling Elasticsearch at Vinted
Lessons Learned While Scaling Elasticsearch at VintedLessons Learned While Scaling Elasticsearch at Vinted
Lessons Learned While Scaling Elasticsearch at Vinted
Dainius Jocas
 
An Introduction to Postgresql
An Introduction to PostgresqlAn Introduction to Postgresql
An Introduction to Postgresql
عباس بني اسدي مقدم
 
Practical JSON in MySQL 5.7 and Beyond
Practical JSON in MySQL 5.7 and BeyondPractical JSON in MySQL 5.7 and Beyond
Practical JSON in MySQL 5.7 and Beyond
Ike Walker
 
hadoop
hadoophadoop
hadoop
longhao
 
MongoDB dla administratora
MongoDB dla administratora MongoDB dla administratora
MongoDB dla administratora
3camp
 
2016 foss4 g track: developing and implementing spatial etl processes with...
2016 foss4 g track:  developing and implementing  spatial etl processes  with...2016 foss4 g track:  developing and implementing  spatial etl processes  with...
2016 foss4 g track: developing and implementing spatial etl processes with...
GIS in the Rockies
 
Introduction To MongoDB
Introduction To MongoDBIntroduction To MongoDB
Introduction To MongoDB
ElieHannouch
 

Similar to Omnibus database machine (20)

20160407_GTC2016_PgSQL_In_Place
20160407_GTC2016_PgSQL_In_Place20160407_GTC2016_PgSQL_In_Place
20160407_GTC2016_PgSQL_In_Place
 
Full-Stack Data Science: How to be a One-person Data Team
Full-Stack Data Science: How to be a One-person Data TeamFull-Stack Data Science: How to be a One-person Data Team
Full-Stack Data Science: How to be a One-person Data Team
 
Mongo db dla administratora
Mongo db dla administratoraMongo db dla administratora
Mongo db dla administratora
 
Webscale PostgreSQL - JSONB and Horizontal Scaling Strategies
Webscale PostgreSQL - JSONB and Horizontal Scaling StrategiesWebscale PostgreSQL - JSONB and Horizontal Scaling Strategies
Webscale PostgreSQL - JSONB and Horizontal Scaling Strategies
 
NoSQL meets Microservices - Michael Hackstein
NoSQL meets Microservices -  Michael HacksteinNoSQL meets Microservices -  Michael Hackstein
NoSQL meets Microservices - Michael Hackstein
 
Gur1009
Gur1009Gur1009
Gur1009
 
Spark SQL - 10 Things You Need to Know
Spark SQL - 10 Things You Need to KnowSpark SQL - 10 Things You Need to Know
Spark SQL - 10 Things You Need to Know
 
Get expertise with mongo db
Get expertise with mongo dbGet expertise with mongo db
Get expertise with mongo db
 
Giovanni Lanzani – SQL & NoSQL databases for data driven applications - NoSQL...
Giovanni Lanzani – SQL & NoSQL databases for data driven applications - NoSQL...Giovanni Lanzani – SQL & NoSQL databases for data driven applications - NoSQL...
Giovanni Lanzani – SQL & NoSQL databases for data driven applications - NoSQL...
 
Data Types/Structures in DivConq
Data Types/Structures in DivConqData Types/Structures in DivConq
Data Types/Structures in DivConq
 
Prestogres internals
Prestogres internalsPrestogres internals
Prestogres internals
 
D3 Mapping Visualization
D3 Mapping VisualizationD3 Mapping Visualization
D3 Mapping Visualization
 
Working with JSON Data in PostgreSQL vs. MongoDB
Working with JSON Data in PostgreSQL vs. MongoDBWorking with JSON Data in PostgreSQL vs. MongoDB
Working with JSON Data in PostgreSQL vs. MongoDB
 
Lessons Learned While Scaling Elasticsearch at Vinted
Lessons Learned While Scaling Elasticsearch at VintedLessons Learned While Scaling Elasticsearch at Vinted
Lessons Learned While Scaling Elasticsearch at Vinted
 
An Introduction to Postgresql
An Introduction to PostgresqlAn Introduction to Postgresql
An Introduction to Postgresql
 
Practical JSON in MySQL 5.7 and Beyond
Practical JSON in MySQL 5.7 and BeyondPractical JSON in MySQL 5.7 and Beyond
Practical JSON in MySQL 5.7 and Beyond
 
hadoop
hadoophadoop
hadoop
 
MongoDB dla administratora
MongoDB dla administratora MongoDB dla administratora
MongoDB dla administratora
 
2016 foss4 g track: developing and implementing spatial etl processes with...
2016 foss4 g track:  developing and implementing  spatial etl processes  with...2016 foss4 g track:  developing and implementing  spatial etl processes  with...
2016 foss4 g track: developing and implementing spatial etl processes with...
 
Introduction To MongoDB
Introduction To MongoDBIntroduction To MongoDB
Introduction To MongoDB
 

Recently uploaded

Going AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applicationsGoing AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applications
Alina Yurenko
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
Paul Brebner
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
sandeepmenon62
 
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
kgyxske
 
The Role of DevOps in Digital Transformation.pdf
The Role of DevOps in Digital Transformation.pdfThe Role of DevOps in Digital Transformation.pdf
The Role of DevOps in Digital Transformation.pdf
mohitd6
 
Boost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management AppsBoost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management Apps
Jhone kinadey
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery FleetStork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
Vince Scalabrino
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
kalichargn70th171
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
Pedro J. Molina
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
kalichargn70th171
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Paul Brebner
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
ervikas4
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
aeeva
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies
 

Recently uploaded (20)

Going AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applicationsGoing AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applications
 
Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...Superpower Your Apache Kafka Applications Development with Complementary Open...
Superpower Your Apache Kafka Applications Development with Complementary Open...
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
 
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
 
The Role of DevOps in Digital Transformation.pdf
The Role of DevOps in Digital Transformation.pdfThe Role of DevOps in Digital Transformation.pdf
The Role of DevOps in Digital Transformation.pdf
 
Boost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management AppsBoost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management Apps
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery FleetStork Product Overview: An AI-Powered Autonomous Delivery Fleet
Stork Product Overview: An AI-Powered Autonomous Delivery Fleet
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
 

Omnibus database machine

  • 1. omnibus database machine How to NoSQL in Postgres with Django
  • 2. so much database I’m Aleck mainly: django + python + js github.com/alecklandgraf @aleck_landgraf aleck@buildingenergy.com I’m Gavin github.com/gmcquillan @gmcquillan
  • 3. our use case people want to load their data… … and play with it: - django app for managing building data - unstructured data - relational data - orgs/perms/projects - utility meter ts data
  • 4. we have unstructured data - lack of fixed schema - can create new fields without DB migration - 2,000 fields in the standard ontology - business logic (MCM) to map raw data to an ontology if possible - other logic to keep track of keys - different for each user or organization
  • 5. we have relational data - everything we load relates to everything else in the system - buildings → organizations → permissions - buildings → utilities → meters → ts data - building v12010 → building v22011
  • 6. unstructured and relational data - django can connect to mongo - django can connect to postgres - complex - is there something better?
  • 7. PostgreSQL 9.2+ JSON type - native type for JSON (9.4+ jsonb) - GIN index, soon GiST index - supports search and lookup - easy to convert python dict to json - json is the de facto standard for web APIs
  • 8. why not mongo * - MongoDB doesn’t seem to be more performant than PostgreSQL. - And you still get all of PostgreSQL’s goodies. - Larger documents will probably continue to favor PostgreSQL. - As will larger tables. *from Christophe Pettus’ talk at OSCON ‘13
  • 9. did someone say django app? - are you ready to get beta - django-pgjson (version 0.2.0, 2014-09-13) - works best with dev postgres 9.4 and Django 1.7+ - in beta development - also a kickstarter project to help build some of this out
  • 10. setting up your django model from django.db import models from django_pgjson.fields import JsonField class Something(models.Model): name = models.CharField(max_length=32) data = JsonField()
  • 11. querying the JSON data >>> Something.object.bulk_create([ ... Something(data={"name": "foo", "tags": ["sad", "romantic"]}), ... Something(data={"name": "bar", "tags": ["sad", "intelligent"]}) ... ]) >>> Something.objects.filter(data__at_name="foo").count() 1 >>> Something.objects.filter(data__jcontains={"tags": ["sad"]}).count() 2
  • 12. what about order_by and distinct? - unsupported until PSQL 9.4 with jsonb - we wrote our own inside a custom queryset if order_by not in known_columns: qs = list(qs) qs.sort( key=lambda x: getattr(x, field).get(order_by), reverse=order_by_rev )
  • 13. JSON value order_by in SQL SELECT id, NULLIF(extra_data->>'Total GHG Emissions (MtCO2e)', '')::float AS ghg_emissions from seed_buildingsnapshot WHERE extra_data->>'Total GHG Emissions (MtCO2e)' != '' ORDER BY NULLIF(extra_data->>'Total GHG Emissions (MtCO2e)', '')::float DESC LIMIT 10; Django order_by doesn’t work on ‘non-model-fields’
  • 14. order_by - can also push it to Postgres with a PL script - http://hyperthese.net/post/sorting-json-fields-in- postgresql/ - jsonb support in Postgres 9.4 for this, but not for json
  • 16. who is using this? With JSONB and other enhancements in 9.4 "we now have full document storage and awesome performance with little effort," explained Craig Kerstiens, a developer at Salesforce-backed Heroku, in a personal blog post.
  • 17. further thoughts - Postgresql full text search with JSON? - joins
  • 18. links - https://github.com/djangonauts/django-pgjson - http://www.postgresql.org/docs/9.4/static/functions-json.html - http://thebuild.com/presentations/pg-as-nosql-pgday-fosdem-2013.pdf - http://www.postgresql.org/docs/9.4/static/datatype-json.html - http://lwn.net/Articles/599705/ - http://simko.home.cern.ch/simko/postgresql-mongodb-json-select-speed. html