SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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 2013PostgresOpen
 
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 IGDTUWAnkur Raina
 
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
 
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 MongoDBMongoDB
 
MongoDB - A Document NoSQL Database
MongoDB - A Document NoSQL DatabaseMongoDB - A Document NoSQL Database
MongoDB - A Document NoSQL DatabaseRuben Inoto Soto
 
Ebook Pembuatan Aplikasi Rental film 2012
Ebook Pembuatan Aplikasi Rental film 2012Ebook Pembuatan Aplikasi Rental film 2012
Ebook Pembuatan Aplikasi Rental film 2012yantoit2011
 
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 shardingMongoDB
 
2011 mongo FR - scaling with mongodb
2011 mongo FR - scaling with mongodb2011 mongo FR - scaling with mongodb
2011 mongo FR - scaling with mongodbantoinegirbal
 
Mongo db updatedocumentusecases
Mongo db updatedocumentusecasesMongo db updatedocumentusecases
Mongo db updatedocumentusecaseszarigatongy
 
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 MongoDBMongoDB
 
mongoDB Performance
mongoDB PerformancemongoDB Performance
mongoDB PerformanceMoshe Kaplan
 
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 appBruce 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 ApplicationMongoDB
 

Was ist angesagt? (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
 

Andere mochten auch

Website evaluation
Website evaluationWebsite evaluation
Website evaluationMrsCragle
 
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
 
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
 
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 tgMèo Hoang
 
About profession
About professionAbout profession
About professionChris 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 booleWang Ruan
 
39.2015.tt.bnnptnt
39.2015.tt.bnnptnt39.2015.tt.bnnptnt
39.2015.tt.bnnptntMè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 SystemDmitry Tolpeko
 
Corbett gardens cat hearing presentation 2015
Corbett gardens cat hearing presentation 2015Corbett gardens cat hearing presentation 2015
Corbett gardens cat hearing presentation 2015WSCCEC
 
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ựngMèo Hoang
 
Thecompellingimage sxsw
Thecompellingimage sxswThecompellingimage sxsw
Thecompellingimage sxswMarty 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
淺談測試Part1Chris Chang
 

Andere mochten auch (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
 

Ähnlich wie Omnibus database machine

20160407_GTC2016_PgSQL_In_Place
20160407_GTC2016_PgSQL_In_Place20160407_GTC2016_PgSQL_In_Place
20160407_GTC2016_PgSQL_In_PlaceKohei 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 TeamGreg Goltsov
 
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 StrategiesJonathan Katz
 
NoSQL meets Microservices - Michael Hackstein
NoSQL meets Microservices -  Michael HacksteinNoSQL meets Microservices -  Michael Hackstein
NoSQL meets Microservices - Michael Hacksteindistributed matters
 
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 KnowKristian Alexander
 
Get expertise with mongo db
Get expertise with mongo dbGet expertise with mongo db
Get expertise with mongo dbAmit 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 DivConqeTimeline, LLC
 
D3 Mapping Visualization
D3 Mapping VisualizationD3 Mapping Visualization
D3 Mapping VisualizationSudhir 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. MongoDBScaleGrid.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 VintedDainius Jocas
 
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 BeyondIke Walker
 
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 MongoDBElieHannouch
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 

Kürzlich hochgeladen (20)

Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

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