SlideShare a Scribd company logo
1 of 26
Download to read offline
How Databases Work 
• Gurjeet Singh | 09.18.14 
© 2013 EDB All rights reserved. 1
Who Am I 
Database Architect @ EDB 
– Index Advisor 
– Optimizer Hints 
– Postgres Enterprise Manager 
– Postgres Plus Cloud Database 
Postgres Contributor 
– Postgres Hibernator and others 
Learnt From Mistakes 
© 2013 EDB All rights reserved. 2
Goal 
Impart some new knowledge, that helps you do your 
job better. 
(The “Full Monty” slides is where the meat of the talk 
is) 
© 2013 EDB All rights reserved. 3
Agenda 
• ACID 
• Application Interaction 
• Backend Operations 
• Concurrent/Cooperating Operations 
• OS/Disk Interaction 
• NoSQL 
© 2013 EDB All rights reserved. 4
ACID 
© 2013 EDB All rights reserved. 5
ACID 
Traits of a transaction in an RDBMS 
• Atomicity 
– Changes done by a transaction are one unit; all or 
nothing. 
• Consistency 
– Transaction end leaves database in a consistent 
state; constraints cannot be violated. 
• Isolation 
– Transactions behave as if only one transaction is 
in progress at a time. 
• Durability 
– Transactions, once committed, will not be lost. 
© 2013 EDB All rights reserved. 6
NoSQL 
© 2013 EDB All rights reserved. 7
NoSQL 
• We are not going to discuss NoSQL databases. 
• They compromise on at least one of ACID properties 
© 2013 EDB All rights reserved. 8
Application Interaction 
© 2013 EDB All rights reserved. 9
Application Interaction 
• Applications use a database driver 
• The driver uses a custom protocol (language) 
• Enables Client-Server/n-Tier architectures 
Java 
Ruby 
Python 
JavaScript 
C/C++ 
© 2013 EDB All rights reserved. 10
Backend Operations 
© 2013 EDB All rights reserved. 11
Backend Operations 
• Query Processing 
– Tokenize/Parse 
– Parse Analysis 
– Plan/Optimize 
– Execute 
© 2013 EDB All rights reserved. 12
Backend Operations – Tokenize/Parse 
SELECT e.id, d.name 
FROM emp e JOIN dept d 
ON e.dept = d.id 
WHERE emp.name = 'Agent Smith'; 
SELECT e . id , d . name 
FROM emp e JOIN dept d 
ON e . dept = d . id 
WHERE emp . name = 'Agent Smith' ; 
© 2013 EDB All rights reserved. 13
Backend Operations – Tokenize/Parse 
SELECT List FROM List WHERE List 
e.id d.name emp dept = 
= 
© 2013 EDB All rights reserved. 14 
e.name 'Agent Smith' 
Parse Tree 
ON 
e.dept d.id
Backend Operations – Parse Analysis 
• Ensure that 
– The objects (tables, columns, functions, etc.) exist 
– Resolve/expand views 
• Type Coercion 
© 2013 EDB All rights reserved. 15
Backend Operations – Plan/Optimize 
Generate all possible plans to access objects 
• Compare cost of 
– Accessing tables using various methods 
● Full Table Scan, Index Scan, Bitmap Index, etc. 
– Joining tables using various methods 
● Nested Loop join, Hash Join, Sort-Merge Join 
– Other operations like distinct, ordering, grouping. 
• Choose the best plan 
• Best may mean 
– Fastest (e.g. LIMIT clause) 
– Cheapest 
© 2013 EDB All rights reserved. 16
Backend Operations – Plan/Optimize 
Plan/Execution Tree 
Result 
Nested Loop 
Index Scan - emp 
Condition: name = 
'Agent Smith' 
Filter: e.dept = 
© 2013 EDB All rights reserved. 17 
Full Table Scan - dept 
d.id 
To Client
Backend Operations - Execute 
• Traverse the Execution Tree recursively 
• Pull rows from each execution node, until exhausted 
• Insert/Update rows 
– Delete in Postgres is just an update of row header 
– Update is similar to Delete + Insert 
– Multi-Version Concurrency Control (MVCC) 
• Send result/rows to the client 
© 2013 EDB All rights reserved. 18
Concurrent/Cooperating 
Operations 
© 2013 EDB All rights reserved. 19
Concurrent/Cooperating Operations 
• Read data from disk 
• Share data 
• Locks to prevent concurrent update 
• Write data to disk 
© 2013 EDB All rights reserved. 20
Block Structure 
© 2013 EDB All rights reserved. 21 
Free Space 
Block Header 
Row Pointers 
Row Header
MVCC 
Isolation; A transaction will: 
• Ignore changes done by newer transactions 
• Ignore changes done by running transactions 
• Ignore changes done by rolled-back transactions 
• Only “see” changes by older and committed 
transactions 
Effectively: 
• Readers don't block writers 
• Writers don't block readers 
© 2013 EDB All rights reserved. 22
MVCC 
Provides 
• Atomicity; with the help of commit log (clog) 
• Isolation 
Consistency 
• Ensured by the individual backends 
© 2013 EDB All rights reserved. 23
Full Monty 
Client 1 Client 2 Client 3 Client n 
Network 
Backend 1 Backend 2 Backend n Postmaster 
© 2013 EDB All rights reserved. 24 
Checkpointer 
Autovacuum 
RAM 
Disk Cache 
Shared Buffers 
WAL Buffers 
Controller Cache Controller Cache 
BGWriter
Full Monty 
• WAL – Write Ahead Log 
– Record change before the actual change 
– Sequential, always growing infinite log 
• Checkpoint 
– Flush dirty data blocks to database 
– Truncate WAL; prevent infinite growth 
• Autovacuum 
– Clean up dead row versions 
• BGWriter 
– Write dirty blocks so backends don't have to 
© 2013 EDB All rights reserved. 25
Be Curious 
Thank You 
© 2013 EDB All rights reserved. 26

More Related Content

What's hot

Scale out Magento 2 at AWS
Scale out Magento 2 at AWSScale out Magento 2 at AWS
Scale out Magento 2 at AWSroot360 GmbH
 
Google Cloud platform: GKE with CI/CD using CircleCI and Flux
Google Cloud platform: GKE with CI/CD using CircleCI and FluxGoogle Cloud platform: GKE with CI/CD using CircleCI and Flux
Google Cloud platform: GKE with CI/CD using CircleCI and Fluxkomaldevg
 
Building & Testing Scalable Rails Applications
Building & Testing Scalable Rails ApplicationsBuilding & Testing Scalable Rails Applications
Building & Testing Scalable Rails Applicationsevilmike
 
Architecture Of Large Scale Websites
Architecture Of Large Scale WebsitesArchitecture Of Large Scale Websites
Architecture Of Large Scale WebsitesFeng Yu
 
Data Collection & Caching using redis | Swatantra Kumar
Data Collection & Caching using redis | Swatantra KumarData Collection & Caching using redis | Swatantra Kumar
Data Collection & Caching using redis | Swatantra KumarSwatantra Kumar
 
RedisConf18 - Video Experience Operational Insights in Real Time.
RedisConf18 - Video Experience Operational Insights in Real Time.RedisConf18 - Video Experience Operational Insights in Real Time.
RedisConf18 - Video Experience Operational Insights in Real Time.Redis Labs
 
Siebel CRM in Production - What Now?
Siebel CRM in Production - What  Now?Siebel CRM in Production - What  Now?
Siebel CRM in Production - What Now?Frank
 
When and how to migrate from a relational database to Cassandra
When and how to migrate from a relational database to CassandraWhen and how to migrate from a relational database to Cassandra
When and how to migrate from a relational database to CassandraBen Slater
 
Nginx caching
Nginx cachingNginx caching
Nginx cachingreneedv
 
Writing HTTP Middleware In Go
Writing HTTP Middleware In GoWriting HTTP Middleware In Go
Writing HTTP Middleware In GoShiju Varghese
 
Microservices Architecture and Containers.
Microservices Architecture and Containers.Microservices Architecture and Containers.
Microservices Architecture and Containers.imjacobclark
 
Cassandra summit 2015 - Simplifying Streaming Analytics
Cassandra summit 2015 - Simplifying Streaming AnalyticsCassandra summit 2015 - Simplifying Streaming Analytics
Cassandra summit 2015 - Simplifying Streaming AnalyticsBrenden Matthews
 
Google Cloud & Your Data
Google Cloud & Your DataGoogle Cloud & Your Data
Google Cloud & Your DataMike Fowler
 
Introduction to CloudStack Storage Subsystem
Introduction to CloudStack Storage SubsystemIntroduction to CloudStack Storage Subsystem
Introduction to CloudStack Storage Subsystembuildacloud
 
eCommerce Series Part 4 - Data Center
eCommerce Series Part 4 - Data CentereCommerce Series Part 4 - Data Center
eCommerce Series Part 4 - Data CenterAshwinee Kumar
 
CDN implmentation consideration
CDN implmentation considerationCDN implmentation consideration
CDN implmentation considerationAvi Shalisman
 
JS Lab`16. Андрей Колодницкий: "Разработка REST сервисов на SailsJS"
JS Lab`16. Андрей Колодницкий: "Разработка REST сервисов на SailsJS"JS Lab`16. Андрей Колодницкий: "Разработка REST сервисов на SailsJS"
JS Lab`16. Андрей Колодницкий: "Разработка REST сервисов на SailsJS"GeeksLab Odessa
 
Ingress controller present, past and future
Ingress controller present, past and futureIngress controller present, past and future
Ingress controller present, past and futureJuraj Hantak
 

What's hot (19)

Scale out Magento 2 at AWS
Scale out Magento 2 at AWSScale out Magento 2 at AWS
Scale out Magento 2 at AWS
 
Google Cloud platform: GKE with CI/CD using CircleCI and Flux
Google Cloud platform: GKE with CI/CD using CircleCI and FluxGoogle Cloud platform: GKE with CI/CD using CircleCI and Flux
Google Cloud platform: GKE with CI/CD using CircleCI and Flux
 
Building & Testing Scalable Rails Applications
Building & Testing Scalable Rails ApplicationsBuilding & Testing Scalable Rails Applications
Building & Testing Scalable Rails Applications
 
Architecture Of Large Scale Websites
Architecture Of Large Scale WebsitesArchitecture Of Large Scale Websites
Architecture Of Large Scale Websites
 
Data Collection & Caching using redis | Swatantra Kumar
Data Collection & Caching using redis | Swatantra KumarData Collection & Caching using redis | Swatantra Kumar
Data Collection & Caching using redis | Swatantra Kumar
 
RedisConf18 - Video Experience Operational Insights in Real Time.
RedisConf18 - Video Experience Operational Insights in Real Time.RedisConf18 - Video Experience Operational Insights in Real Time.
RedisConf18 - Video Experience Operational Insights in Real Time.
 
Siebel CRM in Production - What Now?
Siebel CRM in Production - What  Now?Siebel CRM in Production - What  Now?
Siebel CRM in Production - What Now?
 
When and how to migrate from a relational database to Cassandra
When and how to migrate from a relational database to CassandraWhen and how to migrate from a relational database to Cassandra
When and how to migrate from a relational database to Cassandra
 
Nginx caching
Nginx cachingNginx caching
Nginx caching
 
Writing HTTP Middleware In Go
Writing HTTP Middleware In GoWriting HTTP Middleware In Go
Writing HTTP Middleware In Go
 
Microservices Architecture and Containers.
Microservices Architecture and Containers.Microservices Architecture and Containers.
Microservices Architecture and Containers.
 
Cassandra summit 2015 - Simplifying Streaming Analytics
Cassandra summit 2015 - Simplifying Streaming AnalyticsCassandra summit 2015 - Simplifying Streaming Analytics
Cassandra summit 2015 - Simplifying Streaming Analytics
 
Google Cloud & Your Data
Google Cloud & Your DataGoogle Cloud & Your Data
Google Cloud & Your Data
 
Introduction to CloudStack Storage Subsystem
Introduction to CloudStack Storage SubsystemIntroduction to CloudStack Storage Subsystem
Introduction to CloudStack Storage Subsystem
 
eCommerce Series Part 4 - Data Center
eCommerce Series Part 4 - Data CentereCommerce Series Part 4 - Data Center
eCommerce Series Part 4 - Data Center
 
Apache Gobblin
Apache GobblinApache Gobblin
Apache Gobblin
 
CDN implmentation consideration
CDN implmentation considerationCDN implmentation consideration
CDN implmentation consideration
 
JS Lab`16. Андрей Колодницкий: "Разработка REST сервисов на SailsJS"
JS Lab`16. Андрей Колодницкий: "Разработка REST сервисов на SailsJS"JS Lab`16. Андрей Колодницкий: "Разработка REST сервисов на SailsJS"
JS Lab`16. Андрей Колодницкий: "Разработка REST сервисов на SailsJS"
 
Ingress controller present, past and future
Ingress controller present, past and futureIngress controller present, past and future
Ingress controller present, past and future
 

Similar to How Databases Work - for Developers, Accidental DBAs and Managers

Slow things down to make them go faster [FOSDEM 2022]
Slow things down to make them go faster [FOSDEM 2022]Slow things down to make them go faster [FOSDEM 2022]
Slow things down to make them go faster [FOSDEM 2022]Jimmy Angelakos
 
GLOC 2014 NEOOUG - Oracle Database 12c New Features
GLOC 2014 NEOOUG - Oracle Database 12c New FeaturesGLOC 2014 NEOOUG - Oracle Database 12c New Features
GLOC 2014 NEOOUG - Oracle Database 12c New FeaturesBiju Thomas
 
Integrating Hybrid Cloud Database-as-a-Service with Cloud Foundry’s Service​ ...
Integrating Hybrid Cloud Database-as-a-Service with Cloud Foundry’s Service​ ...Integrating Hybrid Cloud Database-as-a-Service with Cloud Foundry’s Service​ ...
Integrating Hybrid Cloud Database-as-a-Service with Cloud Foundry’s Service​ ...VMware Tanzu
 
What's New in Postgres Plus Advanced Server 9.3
What's New in Postgres Plus Advanced Server 9.3What's New in Postgres Plus Advanced Server 9.3
What's New in Postgres Plus Advanced Server 9.3EDB
 
PPCD_And_AmazonRDS
PPCD_And_AmazonRDSPPCD_And_AmazonRDS
PPCD_And_AmazonRDSVibhor Kumar
 
Oracle SOA Suite Performance Tuning- UKOUG Application Server & Middleware SI...
Oracle SOA Suite Performance Tuning- UKOUG Application Server & Middleware SI...Oracle SOA Suite Performance Tuning- UKOUG Application Server & Middleware SI...
Oracle SOA Suite Performance Tuning- UKOUG Application Server & Middleware SI...C2B2 Consulting
 
New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13EDB
 
A Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQLA Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQLEDB
 
The Central View of your Data with Postgres
The Central View of your Data with PostgresThe Central View of your Data with Postgres
The Central View of your Data with PostgresEDB
 
Oracle Coherence & WebLogic 12c Web Sockets: Delivering Real Time Push at Scale
Oracle Coherence & WebLogic 12c Web Sockets: Delivering Real Time Push at ScaleOracle Coherence & WebLogic 12c Web Sockets: Delivering Real Time Push at Scale
Oracle Coherence & WebLogic 12c Web Sockets: Delivering Real Time Push at ScaleC2B2 Consulting
 
The Real Scoop on Migrating from Oracle Databases
The Real Scoop on Migrating from Oracle DatabasesThe Real Scoop on Migrating from Oracle Databases
The Real Scoop on Migrating from Oracle DatabasesEDB
 
An overview of reference architectures for Postgres
An overview of reference architectures for PostgresAn overview of reference architectures for Postgres
An overview of reference architectures for PostgresEDB
 
026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...
026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...
026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...Neo4j
 
An overview of reference architectures for Postgres
An overview of reference architectures for PostgresAn overview of reference architectures for Postgres
An overview of reference architectures for PostgresEDB
 
Les nouveautés d'EDB Postgres 11
Les nouveautés d'EDB Postgres 11Les nouveautés d'EDB Postgres 11
Les nouveautés d'EDB Postgres 11EDB
 
EDB Postgres Platform 11 Webinar
EDB Postgres Platform 11 WebinarEDB Postgres Platform 11 Webinar
EDB Postgres Platform 11 WebinarEDB
 
Neuerungen in EDB Postgres 11
Neuerungen in EDB Postgres 11Neuerungen in EDB Postgres 11
Neuerungen in EDB Postgres 11EDB
 

Similar to How Databases Work - for Developers, Accidental DBAs and Managers (20)

Slow things down to make them go faster [FOSDEM 2022]
Slow things down to make them go faster [FOSDEM 2022]Slow things down to make them go faster [FOSDEM 2022]
Slow things down to make them go faster [FOSDEM 2022]
 
GLOC 2014 NEOOUG - Oracle Database 12c New Features
GLOC 2014 NEOOUG - Oracle Database 12c New FeaturesGLOC 2014 NEOOUG - Oracle Database 12c New Features
GLOC 2014 NEOOUG - Oracle Database 12c New Features
 
Integrating Hybrid Cloud Database-as-a-Service with Cloud Foundry’s Service​ ...
Integrating Hybrid Cloud Database-as-a-Service with Cloud Foundry’s Service​ ...Integrating Hybrid Cloud Database-as-a-Service with Cloud Foundry’s Service​ ...
Integrating Hybrid Cloud Database-as-a-Service with Cloud Foundry’s Service​ ...
 
Multi-Tenancy
Multi-TenancyMulti-Tenancy
Multi-Tenancy
 
What's New in Postgres Plus Advanced Server 9.3
What's New in Postgres Plus Advanced Server 9.3What's New in Postgres Plus Advanced Server 9.3
What's New in Postgres Plus Advanced Server 9.3
 
PPCD_And_AmazonRDS
PPCD_And_AmazonRDSPPCD_And_AmazonRDS
PPCD_And_AmazonRDS
 
Oracle SOA Suite Performance Tuning- UKOUG Application Server & Middleware SI...
Oracle SOA Suite Performance Tuning- UKOUG Application Server & Middleware SI...Oracle SOA Suite Performance Tuning- UKOUG Application Server & Middleware SI...
Oracle SOA Suite Performance Tuning- UKOUG Application Server & Middleware SI...
 
New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13
 
A Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQLA Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQL
 
The Central View of your Data with Postgres
The Central View of your Data with PostgresThe Central View of your Data with Postgres
The Central View of your Data with Postgres
 
Oracle Coherence & WebLogic 12c Web Sockets: Delivering Real Time Push at Scale
Oracle Coherence & WebLogic 12c Web Sockets: Delivering Real Time Push at ScaleOracle Coherence & WebLogic 12c Web Sockets: Delivering Real Time Push at Scale
Oracle Coherence & WebLogic 12c Web Sockets: Delivering Real Time Push at Scale
 
The Real Scoop on Migrating from Oracle Databases
The Real Scoop on Migrating from Oracle DatabasesThe Real Scoop on Migrating from Oracle Databases
The Real Scoop on Migrating from Oracle Databases
 
An overview of reference architectures for Postgres
An overview of reference architectures for PostgresAn overview of reference architectures for Postgres
An overview of reference architectures for Postgres
 
026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...
026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...
026 Neo4j Data Loading (ETL_ELT) Best Practices - NODES2022 AMERICAS Advanced...
 
An overview of reference architectures for Postgres
An overview of reference architectures for PostgresAn overview of reference architectures for Postgres
An overview of reference architectures for Postgres
 
Les nouveautés d'EDB Postgres 11
Les nouveautés d'EDB Postgres 11Les nouveautés d'EDB Postgres 11
Les nouveautés d'EDB Postgres 11
 
EDB Postgres Platform 11 Webinar
EDB Postgres Platform 11 WebinarEDB Postgres Platform 11 Webinar
EDB Postgres Platform 11 Webinar
 
Neuerungen in EDB Postgres 11
Neuerungen in EDB Postgres 11Neuerungen in EDB Postgres 11
Neuerungen in EDB Postgres 11
 
Distributed query deep dive conor cunningham
Distributed query deep dive   conor cunninghamDistributed query deep dive   conor cunningham
Distributed query deep dive conor cunningham
 
Greenplum Architecture
Greenplum ArchitectureGreenplum Architecture
Greenplum Architecture
 

More from EDB

Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaSCloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaSEDB
 
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr UnternehmenDie 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr UnternehmenEDB
 
Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube EDB
 
EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021EDB
 
Benchmarking Cloud Native PostgreSQL
Benchmarking Cloud Native PostgreSQLBenchmarking Cloud Native PostgreSQL
Benchmarking Cloud Native PostgreSQLEDB
 
Las Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQLLas Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQLEDB
 
NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLEDB
 
Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?EDB
 
Data Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQLData Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQLEDB
 
Practical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresPractical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresEDB
 
A Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINA Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINEDB
 
IOT with PostgreSQL
IOT with PostgreSQLIOT with PostgreSQL
IOT with PostgreSQLEDB
 
Psql is awesome!
Psql is awesome!Psql is awesome!
Psql is awesome!EDB
 
EDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJEDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJEDB
 
Comment sauvegarder correctement vos données
Comment sauvegarder correctement vos donnéesComment sauvegarder correctement vos données
Comment sauvegarder correctement vos donnéesEDB
 
Cloud Native PostgreSQL - Italiano
Cloud Native PostgreSQL - ItalianoCloud Native PostgreSQL - Italiano
Cloud Native PostgreSQL - ItalianoEDB
 
New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13EDB
 
Best Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLBest Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLEDB
 
Cloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJCloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJEDB
 
Best Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLBest Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLEDB
 

More from EDB (20)

Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaSCloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
 
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr UnternehmenDie 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
 
Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube
 
EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021
 
Benchmarking Cloud Native PostgreSQL
Benchmarking Cloud Native PostgreSQLBenchmarking Cloud Native PostgreSQL
Benchmarking Cloud Native PostgreSQL
 
Las Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQLLas Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQL
 
NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQL
 
Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?
 
Data Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQLData Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQL
 
Practical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresPractical Partitioning in Production with Postgres
Practical Partitioning in Production with Postgres
 
A Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINA Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAIN
 
IOT with PostgreSQL
IOT with PostgreSQLIOT with PostgreSQL
IOT with PostgreSQL
 
Psql is awesome!
Psql is awesome!Psql is awesome!
Psql is awesome!
 
EDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJEDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJ
 
Comment sauvegarder correctement vos données
Comment sauvegarder correctement vos donnéesComment sauvegarder correctement vos données
Comment sauvegarder correctement vos données
 
Cloud Native PostgreSQL - Italiano
Cloud Native PostgreSQL - ItalianoCloud Native PostgreSQL - Italiano
Cloud Native PostgreSQL - Italiano
 
New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13
 
Best Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLBest Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQL
 
Cloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJCloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJ
 
Best Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLBest Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQL
 

Recently uploaded

What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfIdiosysTechnologies1
 

Recently uploaded (20)

What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdf
 

How Databases Work - for Developers, Accidental DBAs and Managers

  • 1. How Databases Work • Gurjeet Singh | 09.18.14 © 2013 EDB All rights reserved. 1
  • 2. Who Am I Database Architect @ EDB – Index Advisor – Optimizer Hints – Postgres Enterprise Manager – Postgres Plus Cloud Database Postgres Contributor – Postgres Hibernator and others Learnt From Mistakes © 2013 EDB All rights reserved. 2
  • 3. Goal Impart some new knowledge, that helps you do your job better. (The “Full Monty” slides is where the meat of the talk is) © 2013 EDB All rights reserved. 3
  • 4. Agenda • ACID • Application Interaction • Backend Operations • Concurrent/Cooperating Operations • OS/Disk Interaction • NoSQL © 2013 EDB All rights reserved. 4
  • 5. ACID © 2013 EDB All rights reserved. 5
  • 6. ACID Traits of a transaction in an RDBMS • Atomicity – Changes done by a transaction are one unit; all or nothing. • Consistency – Transaction end leaves database in a consistent state; constraints cannot be violated. • Isolation – Transactions behave as if only one transaction is in progress at a time. • Durability – Transactions, once committed, will not be lost. © 2013 EDB All rights reserved. 6
  • 7. NoSQL © 2013 EDB All rights reserved. 7
  • 8. NoSQL • We are not going to discuss NoSQL databases. • They compromise on at least one of ACID properties © 2013 EDB All rights reserved. 8
  • 9. Application Interaction © 2013 EDB All rights reserved. 9
  • 10. Application Interaction • Applications use a database driver • The driver uses a custom protocol (language) • Enables Client-Server/n-Tier architectures Java Ruby Python JavaScript C/C++ © 2013 EDB All rights reserved. 10
  • 11. Backend Operations © 2013 EDB All rights reserved. 11
  • 12. Backend Operations • Query Processing – Tokenize/Parse – Parse Analysis – Plan/Optimize – Execute © 2013 EDB All rights reserved. 12
  • 13. Backend Operations – Tokenize/Parse SELECT e.id, d.name FROM emp e JOIN dept d ON e.dept = d.id WHERE emp.name = 'Agent Smith'; SELECT e . id , d . name FROM emp e JOIN dept d ON e . dept = d . id WHERE emp . name = 'Agent Smith' ; © 2013 EDB All rights reserved. 13
  • 14. Backend Operations – Tokenize/Parse SELECT List FROM List WHERE List e.id d.name emp dept = = © 2013 EDB All rights reserved. 14 e.name 'Agent Smith' Parse Tree ON e.dept d.id
  • 15. Backend Operations – Parse Analysis • Ensure that – The objects (tables, columns, functions, etc.) exist – Resolve/expand views • Type Coercion © 2013 EDB All rights reserved. 15
  • 16. Backend Operations – Plan/Optimize Generate all possible plans to access objects • Compare cost of – Accessing tables using various methods ● Full Table Scan, Index Scan, Bitmap Index, etc. – Joining tables using various methods ● Nested Loop join, Hash Join, Sort-Merge Join – Other operations like distinct, ordering, grouping. • Choose the best plan • Best may mean – Fastest (e.g. LIMIT clause) – Cheapest © 2013 EDB All rights reserved. 16
  • 17. Backend Operations – Plan/Optimize Plan/Execution Tree Result Nested Loop Index Scan - emp Condition: name = 'Agent Smith' Filter: e.dept = © 2013 EDB All rights reserved. 17 Full Table Scan - dept d.id To Client
  • 18. Backend Operations - Execute • Traverse the Execution Tree recursively • Pull rows from each execution node, until exhausted • Insert/Update rows – Delete in Postgres is just an update of row header – Update is similar to Delete + Insert – Multi-Version Concurrency Control (MVCC) • Send result/rows to the client © 2013 EDB All rights reserved. 18
  • 19. Concurrent/Cooperating Operations © 2013 EDB All rights reserved. 19
  • 20. Concurrent/Cooperating Operations • Read data from disk • Share data • Locks to prevent concurrent update • Write data to disk © 2013 EDB All rights reserved. 20
  • 21. Block Structure © 2013 EDB All rights reserved. 21 Free Space Block Header Row Pointers Row Header
  • 22. MVCC Isolation; A transaction will: • Ignore changes done by newer transactions • Ignore changes done by running transactions • Ignore changes done by rolled-back transactions • Only “see” changes by older and committed transactions Effectively: • Readers don't block writers • Writers don't block readers © 2013 EDB All rights reserved. 22
  • 23. MVCC Provides • Atomicity; with the help of commit log (clog) • Isolation Consistency • Ensured by the individual backends © 2013 EDB All rights reserved. 23
  • 24. Full Monty Client 1 Client 2 Client 3 Client n Network Backend 1 Backend 2 Backend n Postmaster © 2013 EDB All rights reserved. 24 Checkpointer Autovacuum RAM Disk Cache Shared Buffers WAL Buffers Controller Cache Controller Cache BGWriter
  • 25. Full Monty • WAL – Write Ahead Log – Record change before the actual change – Sequential, always growing infinite log • Checkpoint – Flush dirty data blocks to database – Truncate WAL; prevent infinite growth • Autovacuum – Clean up dead row versions • BGWriter – Write dirty blocks so backends don't have to © 2013 EDB All rights reserved. 25
  • 26. Be Curious Thank You © 2013 EDB All rights reserved. 26