SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler offline
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Boriss Mejías
Consultant - 2ndQuadrant
Air Guitar Player
Internet of Things
with PostgreSQL
Performance & Security
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Boriss Mejías
Consultant - 2ndQuadrant
Air Guitar Player
Internet of Things
with PostgreSQL
Performance & Security
@postgreswomen
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Internet (of people)
Internet of Things
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Internet of Things
● Many Data Collectors
● Widely distributed
● Via public networks
● Multiple measures
● Massive volumes
● Low value data
● Insert-mostly workload
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Internet of Things
● Many Data Collectors
● Widely distributed
● Via public networks SSL mode on
● Multiple measures
● Massive volumes
● Low value data
● Insert-mostly workload “append-only”
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Which day is it?
● Recent and active data for immediate analysis
and immediate actions
● Older data for analytics to detect trends and
patterns
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Why PostgreSQL
● SQL with post-relational features
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Why PostgreSQL
● SQL with post-relational features
● DBEngines Database of the Year 2017
● Stack Overflow #1 Best Loved RDBMS 2018
● Cloud Adoption (AWS, Google, Microsoft, IBM)
● Other databases following PostgreSQL features
● Many forks, but open source version is strong
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Logical Database Design
CREATE TABLE iot
(device_id TEXT NOT NULL
,logtime TIMESTAMP WITHOUT TIME ZONE
,datum JSONB);
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Logical Database Design
CREATE TABLE iot
(device_id TEXT NOT NULL
,logtime TIMESTAMP WITHOUT TIME ZONE
,datum JSONB);
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Logical Database Design
CREATE TABLE iot
(device_id TEXT NOT NULL
,logtime TIMESTAMP WITHOUT TIME ZONE
,datum JSONB);
● Encrypted communication
● Authenticate each device
© 2ndQuadrant 2014-8
IoT with PostgreSQL
JSON Features
● JSON
● JSONB
● Search functions
● Manipulation functions
© 2ndQuadrant 2014-8
IoT with PostgreSQL
JSON Features
● JSON
● JSONB
● Search functions
● Manipulation functions
● Partition by JSON expression
● Index on JSON field
● HOT updates on JSON fields
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Declarative Partitioning
CREATE TABLE iot
(device_id TEXT NOT NULL
,logtime TIMESTAMP WITHOUT TIME ZONE
,datum JSONB)
PARTITION BY RANGE (logtime);
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Partition over Time
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Partition over Device
CREATE TABLE iot
(device_id TEXT NOT NULL
,logtime TIMESTAMP WITHOUT TIME ZONE
,datum JSONB)
PARTITION BY LIST (device_id);
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Partition over Device and Time
CREATE TABLE iot
(device_id TEXT NOT NULL
,logtime TIMESTAMP WITHOUT TIME ZONE
,datum JSONB)
PARTITION BY LIST (device_id);
CREATE TABLE device_a
PARTITION OF iot FOR VALUES IN ('a')
PARTITION BY RANGE (logtime);
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Declarative Partitioning
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Workload - extending partitions
● ATTACH PARTITION
● DETACH PARTITION
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Workload - extending partitions
● ATTACH PARTITION
● DETACH PARTITION
● Local protection laws:
– Easier to delete → Compliance
– Detached data → Retention Policy
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Partitioning Solutions
● Use fewer partitions, each with BRIN indexes
● Add partitions in groups
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Aggregate Data
● From ARM nodes
● To VLDB
● Using logical
replication
(pglogical)
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Aggregate Data
● From ARM nodes
● To VLDB
● Using logical
replication
(pglogical)
● Do NOT use trust
on pg_hba
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Bi-Directional Replication (BDR)
© 2ndQuadrant 2014-8
IoT with PostgreSQL
Conclusions
● IoT produces a lot of data
● Scale insert with partitions and BRIN
● Use JSON
● Scale with many nodes and pglogical
● PostgreSQL is really cool for IoT
© 2ndQuadrant 2014-8
IoT with PostgreSQL
© 2ndQuadrant 2014-8
IoT with PostgreSQL
● Sustainable Open Source Development
● 24/7 Bug Fix Support
● On-premise, Cloud, Hybrid with RemoteDBA
● Consulting & Training

Mais conteúdo relacionado

Último

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 

Último (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 

Destaque

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destaque (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

PGDay.Amsterdam 2018 - Boriss Mejias - Internet of Things with PostgreSQL

  • 1. © 2ndQuadrant 2014-8 IoT with PostgreSQL Boriss Mejías Consultant - 2ndQuadrant Air Guitar Player Internet of Things with PostgreSQL Performance & Security
  • 2. © 2ndQuadrant 2014-8 IoT with PostgreSQL Boriss Mejías Consultant - 2ndQuadrant Air Guitar Player Internet of Things with PostgreSQL Performance & Security @postgreswomen
  • 3. © 2ndQuadrant 2014-8 IoT with PostgreSQL Internet (of people) Internet of Things
  • 4. © 2ndQuadrant 2014-8 IoT with PostgreSQL Internet of Things ● Many Data Collectors ● Widely distributed ● Via public networks ● Multiple measures ● Massive volumes ● Low value data ● Insert-mostly workload
  • 5. © 2ndQuadrant 2014-8 IoT with PostgreSQL Internet of Things ● Many Data Collectors ● Widely distributed ● Via public networks SSL mode on ● Multiple measures ● Massive volumes ● Low value data ● Insert-mostly workload “append-only”
  • 6. © 2ndQuadrant 2014-8 IoT with PostgreSQL Which day is it? ● Recent and active data for immediate analysis and immediate actions ● Older data for analytics to detect trends and patterns
  • 7. © 2ndQuadrant 2014-8 IoT with PostgreSQL Why PostgreSQL ● SQL with post-relational features
  • 8. © 2ndQuadrant 2014-8 IoT with PostgreSQL Why PostgreSQL ● SQL with post-relational features ● DBEngines Database of the Year 2017 ● Stack Overflow #1 Best Loved RDBMS 2018 ● Cloud Adoption (AWS, Google, Microsoft, IBM) ● Other databases following PostgreSQL features ● Many forks, but open source version is strong
  • 9. © 2ndQuadrant 2014-8 IoT with PostgreSQL Logical Database Design CREATE TABLE iot (device_id TEXT NOT NULL ,logtime TIMESTAMP WITHOUT TIME ZONE ,datum JSONB);
  • 10. © 2ndQuadrant 2014-8 IoT with PostgreSQL Logical Database Design CREATE TABLE iot (device_id TEXT NOT NULL ,logtime TIMESTAMP WITHOUT TIME ZONE ,datum JSONB);
  • 11. © 2ndQuadrant 2014-8 IoT with PostgreSQL Logical Database Design CREATE TABLE iot (device_id TEXT NOT NULL ,logtime TIMESTAMP WITHOUT TIME ZONE ,datum JSONB); ● Encrypted communication ● Authenticate each device
  • 12. © 2ndQuadrant 2014-8 IoT with PostgreSQL JSON Features ● JSON ● JSONB ● Search functions ● Manipulation functions
  • 13. © 2ndQuadrant 2014-8 IoT with PostgreSQL JSON Features ● JSON ● JSONB ● Search functions ● Manipulation functions ● Partition by JSON expression ● Index on JSON field ● HOT updates on JSON fields
  • 14. © 2ndQuadrant 2014-8 IoT with PostgreSQL Declarative Partitioning CREATE TABLE iot (device_id TEXT NOT NULL ,logtime TIMESTAMP WITHOUT TIME ZONE ,datum JSONB) PARTITION BY RANGE (logtime);
  • 15. © 2ndQuadrant 2014-8 IoT with PostgreSQL Partition over Time
  • 16. © 2ndQuadrant 2014-8 IoT with PostgreSQL Partition over Device CREATE TABLE iot (device_id TEXT NOT NULL ,logtime TIMESTAMP WITHOUT TIME ZONE ,datum JSONB) PARTITION BY LIST (device_id);
  • 17. © 2ndQuadrant 2014-8 IoT with PostgreSQL Partition over Device and Time CREATE TABLE iot (device_id TEXT NOT NULL ,logtime TIMESTAMP WITHOUT TIME ZONE ,datum JSONB) PARTITION BY LIST (device_id); CREATE TABLE device_a PARTITION OF iot FOR VALUES IN ('a') PARTITION BY RANGE (logtime);
  • 18. © 2ndQuadrant 2014-8 IoT with PostgreSQL Declarative Partitioning
  • 19. © 2ndQuadrant 2014-8 IoT with PostgreSQL Workload - extending partitions ● ATTACH PARTITION ● DETACH PARTITION
  • 20. © 2ndQuadrant 2014-8 IoT with PostgreSQL Workload - extending partitions ● ATTACH PARTITION ● DETACH PARTITION ● Local protection laws: – Easier to delete → Compliance – Detached data → Retention Policy
  • 21. © 2ndQuadrant 2014-8 IoT with PostgreSQL Partitioning Solutions ● Use fewer partitions, each with BRIN indexes ● Add partitions in groups
  • 22. © 2ndQuadrant 2014-8 IoT with PostgreSQL Aggregate Data ● From ARM nodes ● To VLDB ● Using logical replication (pglogical)
  • 23. © 2ndQuadrant 2014-8 IoT with PostgreSQL Aggregate Data ● From ARM nodes ● To VLDB ● Using logical replication (pglogical) ● Do NOT use trust on pg_hba
  • 24. © 2ndQuadrant 2014-8 IoT with PostgreSQL Bi-Directional Replication (BDR)
  • 25. © 2ndQuadrant 2014-8 IoT with PostgreSQL Conclusions ● IoT produces a lot of data ● Scale insert with partitions and BRIN ● Use JSON ● Scale with many nodes and pglogical ● PostgreSQL is really cool for IoT
  • 26. © 2ndQuadrant 2014-8 IoT with PostgreSQL
  • 27. © 2ndQuadrant 2014-8 IoT with PostgreSQL ● Sustainable Open Source Development ● 24/7 Bug Fix Support ● On-premise, Cloud, Hybrid with RemoteDBA ● Consulting & Training