SlideShare uma empresa Scribd logo
1 de 64
Baixar para ler offline
Sumedh Pathak, Co-Founder & VP Engineering, Citus Data
QCon London 2018
The Future of Distributed
Databases is Relational
@moss_toss | @citusdata
About Me
• Co-Founder & VP
Engineering at Citus Data
• Amazon Shopping Cart
(former)
• Amazon Supply Chain &
Order Fulfillment (former)
• Stanford Computer Science
Citus Data co-founders, left-to-right
Ozgun Erdogan, Sumedh Pathak, & Umur Cubukcu
Photo cred: Willy Johnson, Monterey CA, Sep 2017
Sumedh Pathak | Citus Data | QCon London 2018
Why
RDBMS?
Sumedh Pathak | Citus Data | QCon London 2018
Streaming Storage
Map
Reduce
NoSQL
SQL
Database
SELECT ...
Application
Application
Sumedh Pathak | Citus Data | QCon London 2018
Because your architecture could be simpler
An RDBMS is a
general-purpose
data platform
Sumedh Pathak | Citus Data | QCon London 2018
Fast writes
Real-time & bulk
High throughput
High concurrency
Data consistency
Query optimizers
PostgreSQL
MySQL
MongoDB
SQL Server +
Oracle
Source: Hacker News, https://news.ycombinator.com
Startups Are Choosing Postgres% database job posts mentioning each database, across 20K+ job posts
Sumedh Pathak | Citus Data | QCon London 2018
but RDBMS’s
don’t scale, right?
Sumedh Pathak | Citus Data | QCon London 2018
but RDBMS’s don’t scale
RDBMS’s are hard to scale
Sumedh Pathak | Citus Data | QCon London 2018
What exactly needs to Scale?
- Tables (Data)
- Partitioning, Co-location, Reference Tables
- SQL (Reads)
- How do we express and optimize distributed SQL
- Transactions (Writes)
- Cross Shard updates/deletes, Global Atomic Transactions
Sumedh Pathak | Citus Data | QCon London 2018
1
2
3
Scaling
Tables
Sumedh Pathak | Citus Data | QCon London 2018
How to partition the data?
- Pick a column
- Date
- Id (customer_id, cart_id)
- Pick a method
- Hash
- Range
Partition data across nodes
R1
R2
R3
R4
R5
R6
R7
Coordinator
Node
Worker
Nodes
Shards
Sumedh Pathak | Citus Data | QCon London 2018
Worker → RDBMS, Shard → Table
Reference Tables
N1
N1
N1
N1
Copies of same table
Sumedh Pathak | Citus Data | QCon London 2018
Coordinator
Node
Worker
Nodes
Co-Location
R1
R2
R3
R4
S1
S2
S3
S4
Explicit Co-Location API.
E.g. Partition by Tenant
Sumedh Pathak | Citus Data | QCon London 2018
Coordinator
Node
Worker
Nodes
What about Foreign Keys?
The key to scaling tables...
- Use relational databases as a building block
- Understand semantics of application—to be smart about
partitioning
- Multi-tenant applications
Scaling
SQL
FROM table R
SELECT x Projectx
(R) → R’
WHERE f(x) Filterf(x)
(R) → R’
… JOIN … R × S → R’
SQL ↔ Relational Algebra
Sumedh Pathak | Citus Data | QCon London 2018
FROM sharded_table Collect(R1
,R2
,...) → R
Distributed Relational Algebra
R1
R2
C
Sumedh Pathak | Citus Data | QCon London 2018
Projectx
(Collect(R1
,R2
,...)) = Collect(Projectx
(R1
), Projectx
(R2
)...)
Commutative property
R1
R2
C
R1
R2
C
Px
Px
Px
Sumedh Pathak | Citus Data | QCon London 2018
Collect(R1
,R2
,...) x Collect(S1
,S2
,...) = Collect(R1
× S1
,R2
× S2,
...)
Distributive property
R1
R2
C
×
C
S1
S2
R1
R2
C
×
S1
S2
×
X = Join Operator
SUM(x)(Collect(R1
,R2
,...)) = SUM(Collect(SUM(R1
), SUM(R2
)...))
Associative property
R1
R2
C
R1
R2
C
Sumx
Sumx
Sumx
Sumedh Pathak | Citus Data | QCon London 2018
Sumx
SELECT sum(price) FROM orders, nation
WHERE orders.nation = nation.name AND
orders.date >= '2012-01-01' AND
nation.region = 'Asia';
Sumedh Pathak | Citus Data | QCon London 2018
Sumedh Pathak | Citus Data | QCon London 2018
Sumedh Pathak | Citus Data | QCon London 2018
Volcano style processing
Data flows
from
bottom
to top
Sumedh Pathak | Citus Data | QCon London 2018
Sumedh Pathak | Citus Data | QCon London 2018
Sumedh Pathak | Citus Data | QCon London 2018
Parallelize
Aggregate
Push Joins & Filters
below collect. Run in
parallel across all
nodes
Filters & Projections
done before Join
SELECT sum(intermediate_col)
FROM <concatenated results>;
SELECT sum(price)
FROM orders_2 JOIN nation_2
ON (orders_2.name = nation_2.name)
WHERE
orders_2.date >= '2017-01-01'
AND
nation_2.region = 'Asia';
SELECT sum(price)
FROM orders_2 JOIN nation_1
ON (orders_2.name = nation_1.name)
WHERE
orders_2.date >= '2017-01-01'
AND
nation_2.region = 'Asia';
Sumedh Pathak | Citus Data | QCon London 2018
Executing Distributed SQL
SQL database
orders_1
nation_1
orders
nation
SELECT sum(price)
FROM orders_2 o JOIN nation_1
ON (o.name = n.name)
WHERE o.date >= '2017-01-01'
AND n.region = 'Asia';
SELECT sum(price)
FROM orders_1 o JOIN nation_1
ON (o.name = n.name)
WHERE o.date >= '2017-01-01'
AND n.region = 'Asia';
SELECT sum(price) FROM <results>;
SQL database
orders_2
nation_1
The key to scaling SQL...
- New relational algebra operators for
distributed processing
- Relational Algebra Properties to optimize
tree: Commutativity, Associativity, &
Distributivity
- Map / Reduce operators
Scaling
Transactions
Money Transfer, as an example
BEGIN;
UPDATE accounts SET balance = balance -
100 WHERE id = ‘ALICE’;
UPDATE accounts SET balance = balance +
100 WHERE id = ‘BOB’;
COMMIT;
Sumedh Pathak | Citus Data | QCon London 2018
A1
A2
BEGIN;
UPDATE accounts SET balance = balance -
100 WHERE id = ‘ALICE’;
UPDATE accounts SET balance = balance +
100 WHERE id = ‘BOB’;
COMMIT;
A3
A4
Coordinator
Sumedh Pathak | Citus Data | QCon London 2018
A1
A2
BEGIN;
UPDATE accounts SET balance = balance -
100 WHERE id = ‘ALICE’;
UPDATE accounts SET balance = balance +
100 WHERE id = ‘BOB’;
COMMIT;
A3
A4
BEGIN;
UPDATE accounts SET balance = balance -
100 WHERE id = ‘ALICE’;
Sumedh Pathak | Citus Data | QCon London 2018
Coordinator
A1
A2
BEGIN;
UPDATE accounts SET balance = balance -
100 WHERE id = ‘ALICE’;
UPDATE accounts SET balance = balance +
100 WHERE id = ‘BOB’;
COMMIT;
A3
A4
BEGIN;
UPDATE accounts SET balance = balance -
100 WHERE id = ‘ALICE’;
COMMIT;
Sumedh Pathak | Citus Data | QCon London 2018
Coordinator
A1
A2
BEGIN;
UPDATE accounts SET balance = balance -
100 WHERE id = ‘ALICE’;
UPDATE accounts SET balance = balance +
100 WHERE id = ‘BOB’;
COMMIT;
A3
A4
Coordinator
BEGIN;
UPDATE accounts SET balance =
balance + 100 WHERE id = ‘BOB’;
Sumedh Pathak | Citus Data | QCon London 2018
BEGIN;
UPDATE accounts SET balance = balance
- 100 WHERE id = ‘ALICE’;
A1
A2
BEGIN;
UPDATE accounts SET balance = balance -
100 WHERE id = ‘ALICE’;
UPDATE accounts SET balance = balance +
100 WHERE id = ‘BOB’;
COMMIT;
A3
A4
BEGIN;
UPDATE accounts SET balance =
balance + 100 WHERE id = ‘BOB’;
COMMIT
Sumedh Pathak | Citus Data | QCon London 2018
BEGIN;
UPDATE accounts SET balance = balance
- 100 WHERE id = ‘ALICE’;
Coordinator
A1
A2
BEGIN;
UPDATE accounts SET balance = balance -
100 WHERE id = ‘ALICE’;
UPDATE accounts SET balance = balance +
100 WHERE id = ‘BOB’;
COMMIT;
A3
A4
PREPARE TRANSACTION ‘citus_...98’; PREPARE TRANSACTION ‘citus_...98’;
Sumedh Pathak | Citus Data | QCon London 2018
Coordinator
What happens during PREPARE?
State of transaction stored
on a durable store
Locks are
maintained
&
A1
A2
BEGIN;
UPDATE accounts SET balance = balance -
100 WHERE id = ‘ALICE’;
UPDATE accounts SET balance = balance +
100 WHERE id = ‘BOB’;
COMMIT;
A3
A4
Coordinator
PREPARE TRANSACTION ‘citus_...98’; ROLLBACK TRANSACTION ‘citus_...98’;
Sumedh Pathak | Citus Data | QCon London 2018
A1
A2
BEGIN;
UPDATE accounts SET balance = balance -
100 WHERE id = ‘ALICE’;
UPDATE accounts SET balance = balance +
100 WHERE id = ‘BOB’;
COMMIT;
A3
A4
PREPARE TRANSACTION ‘citus_...98’; PREPARE TRANSACTION ‘citus_...98’;
Sumedh Pathak | Citus Data | QCon London 2018
Coordinator
A1
A2
BEGIN;
UPDATE accounts SET balance = balance -
100 WHERE id = ‘ALICE’;
UPDATE accounts SET balance = balance +
100 WHERE id = ‘BOB’;
COMMIT;
A3
A4
COMMIT PREPARED ‘citus_...98’; COMMIT PREPARED ‘citus_...98’;
Sumedh Pathak | Citus Data | QCon London 2018
Coordinator
A1
A2
BEGIN;
UPDATE accounts SET balance = balance -
100 WHERE id = ‘ALICE’;
UPDATE accounts SET balance = balance +
100 WHERE id = ‘BOB’;
COMMIT;
A3
A4
COMMIT PREPARED ‘citus_...98’; COMMIT PREPARED ‘citus_...98’;
Sumedh Pathak | Citus Data | QCon London 2018
Coordinator
A1
A2
BEGIN;
UPDATE accounts SET balance = balance -
100 WHERE id = ‘ALICE’;
UPDATE accounts SET balance = balance +
100 WHERE id = ‘BOB’;
COMMIT;
A3
A4
COMMIT PREPARED ‘citus_...98’; COMMIT PREPARED ‘citus_...98’;
Sumedh Pathak | Citus Data | QCon London 2018
Coordinator
But....
Deadlocks!
Example
// SESSION 1
BEGIN;
UPDATE accounts SET balance
= balance - 100 WHERE id =
‘ALICE’;
(LOCK on ROW with id
‘ALICE’)
// SESSION 2
Sumedh Pathak | Citus Data | QCon London 2018
Example
// SESSION 1
BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE
id = ‘ALICE’;
(LOCK on ROW with id ‘ALICE’)
// SESSION 2
BEGIN;
UPDATE accounts SET balance
= balance + 100 WHERE id =
‘BOB’;
(LOCK on ROW with id ‘BOB’)
Sumedh Pathak | Citus Data | QCon London 2018
Example
// SESSION 1
BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE
id = ‘ALICE’;
(LOCK on ROW with id ‘ALICE’)
UPDATE accounts SET balance
= balance + 100 WHERE id =
‘BOB’;
// SESSION 2
BEGIN;
UPDATE accounts SET balance = balance + 100 WHERE
id = ‘BOB’;
(LOCK on ROW with id ‘BOB’)
Sumedh Pathak | Citus Data | QCon London 2018
Example
// SESSION 1
BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE
id = ‘ALICE’;
(LOCK on ROW with id ‘ALICE’)
UPDATE accounts SET balance = balance + 100
WHERE id = ‘BOB’;
// SESSION 2
BEGIN;
UPDATE accounts SET balance = balance + 100 WHERE
id = ‘BOB’;
(LOCK on ROW with id ‘BOB’)
UPDATE accounts SET balance
= balance - 100 WHERE id =
‘ALICE’
Sumedh Pathak | Citus Data | QCon London 2018
How do Relational DB’s solve this?
S1
S2
- Construct a
Directed Graph
- Each node is a
session/transaction
- Edge represents a
wait on a lock
Waiting
on ‘Bob’
Waiting on
‘Alice’
S1
S2
S1 S2
S2 S1
S2 Waits on S1 S1 Waits on S2
Sumedh Pathak | Citus Data | QCon London 2018
S1
S2
S1 S2
S2 S1
S2 Waits on S1 S1 Waits on S2
Distributed
Deadlock
Detector
S1
S2 S2
S1
Sumedh Pathak | Citus Data | QCon London 2018
keys to scaling transactions
- 2PC to ensure atomic transactions across nodes
- Deadlock Detection—to scale complex & concurrent
transaction workloads
- MVCC
- Failure Handling
4
It’s 2018. Distributed can be Relational
- Scale tables—via sharding
- Scale SQL—via distributed relational algebra
- Scale transactions—via 2PC & Deadlock Detection
Sumedh Pathak | Citus Data | QCon London 2018
Now, how do we implement all of this?
Postgres
Sumedh Pathak | Citus Data | QCon London 2018
PostgreSQL
Planner
Executor
Custom scan
Commit / abort
Extension (.so)
Access methods
Foreign tables
Functions
...
...
...
...
...
...
...
CREATE EXTENSION ...
PostgreSQL PostgreSQL
PostgreSQL
shardsshardsshard
shardsshardsshard
SELECT … FROM distributed_table …
SELECT … FROM shard… SELECT … FROM shard…
Citus
PostgreSQL
Citus
PostGIS PL/Python
JSONB
2PC
Replication...
Sequences
Indexes
Full-Text SearchTransactions
…
dblink
Sumedh Pathak | Citus Data | QCon London 2018
Rich
ecosystem of
tooling, data
types,
& extensions
in
PostgreSQL
PostgreSQL can be
extended into an all-purpose
distributed RDBMS
I believe the future of distributed
databases is relational.
Thank you!
Sumedh Pathak
sumedh@citusdata.com
@moss_toss | @citusdata | citusdata.com
QCon London 2018 | The Future of Distributed Databases is Relational

Mais conteúdo relacionado

Semelhante a The Future of Distributed Databases is Relational

Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)
Geoffrey De Smet
 
Why and how to leverage the simplicity and power of SQL on Flink
Why and how to leverage the simplicity and power of SQL on FlinkWhy and how to leverage the simplicity and power of SQL on Flink
Why and how to leverage the simplicity and power of SQL on Flink
DataWorks Summit
 
Flink Forward San Francisco 2018: Fabian Hueske & Timo Walther - "Why and how...
Flink Forward San Francisco 2018: Fabian Hueske & Timo Walther - "Why and how...Flink Forward San Francisco 2018: Fabian Hueske & Timo Walther - "Why and how...
Flink Forward San Francisco 2018: Fabian Hueske & Timo Walther - "Why and how...
Flink Forward
 
Document splitting in New GL in SAP
Document splitting in New GL in SAPDocument splitting in New GL in SAP
Document splitting in New GL in SAP
Rajesh Shanbhag
 

Semelhante a The Future of Distributed Databases is Relational (20)

Rpa conference new delhi
Rpa conference new delhiRpa conference new delhi
Rpa conference new delhi
 
Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)
 
capital budgeting In financial management
capital budgeting In financial managementcapital budgeting In financial management
capital budgeting In financial management
 
SQL Server 2008 Portfolio
SQL Server 2008 PortfolioSQL Server 2008 Portfolio
SQL Server 2008 Portfolio
 
Flink Forward Berlin 2018: Igal Shilman - "data Artisans Product Announcement"
Flink Forward Berlin 2018: Igal Shilman - "data Artisans Product Announcement"Flink Forward Berlin 2018: Igal Shilman - "data Artisans Product Announcement"
Flink Forward Berlin 2018: Igal Shilman - "data Artisans Product Announcement"
 
Ark scorecard v3 addendum
Ark scorecard v3 addendumArk scorecard v3 addendum
Ark scorecard v3 addendum
 
Why and how to leverage the simplicity and power of SQL on Flink
Why and how to leverage the simplicity and power of SQL on FlinkWhy and how to leverage the simplicity and power of SQL on Flink
Why and how to leverage the simplicity and power of SQL on Flink
 
Oracle Goldengate for Big Data - LendingClub Implementation
Oracle Goldengate for Big Data - LendingClub ImplementationOracle Goldengate for Big Data - LendingClub Implementation
Oracle Goldengate for Big Data - LendingClub Implementation
 
Data Time Travel by Delta Time Machine
Data Time Travel by Delta Time MachineData Time Travel by Delta Time Machine
Data Time Travel by Delta Time Machine
 
My Favorite Calc Code
My Favorite Calc CodeMy Favorite Calc Code
My Favorite Calc Code
 
Flink Forward San Francisco 2018: Fabian Hueske & Timo Walther - "Why and how...
Flink Forward San Francisco 2018: Fabian Hueske & Timo Walther - "Why and how...Flink Forward San Francisco 2018: Fabian Hueske & Timo Walther - "Why and how...
Flink Forward San Francisco 2018: Fabian Hueske & Timo Walther - "Why and how...
 
77565239 13-cost-benefit-analysis
77565239 13-cost-benefit-analysis77565239 13-cost-benefit-analysis
77565239 13-cost-benefit-analysis
 
project
projectproject
project
 
LendingClub RealTime BigData Platform with Oracle GoldenGate
LendingClub RealTime BigData Platform with Oracle GoldenGateLendingClub RealTime BigData Platform with Oracle GoldenGate
LendingClub RealTime BigData Platform with Oracle GoldenGate
 
Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...
Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...
Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...
 
Think Outside the Close: Profitability & Costing Reconciliations in EPM Cloud...
Think Outside the Close: Profitability & Costing Reconciliations in EPM Cloud...Think Outside the Close: Profitability & Costing Reconciliations in EPM Cloud...
Think Outside the Close: Profitability & Costing Reconciliations in EPM Cloud...
 
Computer Science Project on Management System
Computer Science Project on Management System Computer Science Project on Management System
Computer Science Project on Management System
 
Document splitting in New GL in SAP
Document splitting in New GL in SAPDocument splitting in New GL in SAP
Document splitting in New GL in SAP
 
ADAPTIVE FEATURES OR: HOW I LEARNED TO STOP WORRYING AND TROUBLESHOOT THE BOMB
ADAPTIVE FEATURES OR: HOW I LEARNED TO STOP WORRYING AND TROUBLESHOOT THE BOMBADAPTIVE FEATURES OR: HOW I LEARNED TO STOP WORRYING AND TROUBLESHOOT THE BOMB
ADAPTIVE FEATURES OR: HOW I LEARNED TO STOP WORRYING AND TROUBLESHOOT THE BOMB
 
Calculating ETC In 4 Different Scenarios
Calculating ETC In 4 Different ScenariosCalculating ETC In 4 Different Scenarios
Calculating ETC In 4 Different Scenarios
 

Mais de Citus Data

Why developers need marketing now more than ever | GlueCon 2019 | Claire Gior...
Why developers need marketing now more than ever | GlueCon 2019 | Claire Gior...Why developers need marketing now more than ever | GlueCon 2019 | Claire Gior...
Why developers need marketing now more than ever | GlueCon 2019 | Claire Gior...
Citus Data
 

Mais de Citus Data (20)

Architecting peta-byte-scale analytics by scaling out Postgres on Azure with ...
Architecting peta-byte-scale analytics by scaling out Postgres on Azure with ...Architecting peta-byte-scale analytics by scaling out Postgres on Azure with ...
Architecting peta-byte-scale analytics by scaling out Postgres on Azure with ...
 
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...
 
JSONB Tricks: Operators, Indexes, and When (Not) to Use It | PostgresOpen 201...
JSONB Tricks: Operators, Indexes, and When (Not) to Use It | PostgresOpen 201...JSONB Tricks: Operators, Indexes, and When (Not) to Use It | PostgresOpen 201...
JSONB Tricks: Operators, Indexes, and When (Not) to Use It | PostgresOpen 201...
 
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...
Tutorial: Implementing your first Postgres extension | PGConf EU 2019 | Burak...
 
Whats wrong with postgres | PGConf EU 2019 | Craig Kerstiens
Whats wrong with postgres | PGConf EU 2019 | Craig KerstiensWhats wrong with postgres | PGConf EU 2019 | Craig Kerstiens
Whats wrong with postgres | PGConf EU 2019 | Craig Kerstiens
 
When it all goes wrong | PGConf EU 2019 | Will Leinweber
When it all goes wrong | PGConf EU 2019 | Will LeinweberWhen it all goes wrong | PGConf EU 2019 | Will Leinweber
When it all goes wrong | PGConf EU 2019 | Will Leinweber
 
Amazing SQL your ORM can (or can't) do | PGConf EU 2019 | Louise Grandjonc
Amazing SQL your ORM can (or can't) do | PGConf EU 2019 | Louise GrandjoncAmazing SQL your ORM can (or can't) do | PGConf EU 2019 | Louise Grandjonc
Amazing SQL your ORM can (or can't) do | PGConf EU 2019 | Louise Grandjonc
 
What Microsoft is doing with Postgres & the Citus Data acquisition | PGConf E...
What Microsoft is doing with Postgres & the Citus Data acquisition | PGConf E...What Microsoft is doing with Postgres & the Citus Data acquisition | PGConf E...
What Microsoft is doing with Postgres & the Citus Data acquisition | PGConf E...
 
Deep Postgres Extensions in Rust | PGCon 2019 | Jeff Davis
Deep Postgres Extensions in Rust | PGCon 2019 | Jeff DavisDeep Postgres Extensions in Rust | PGCon 2019 | Jeff Davis
Deep Postgres Extensions in Rust | PGCon 2019 | Jeff Davis
 
Why Postgres Why This Database Why Now | SF Bay Area Postgres Meetup | Claire...
Why Postgres Why This Database Why Now | SF Bay Area Postgres Meetup | Claire...Why Postgres Why This Database Why Now | SF Bay Area Postgres Meetup | Claire...
Why Postgres Why This Database Why Now | SF Bay Area Postgres Meetup | Claire...
 
A story on Postgres index types | PostgresLondon 2019 | Louise Grandjonc
A story on Postgres index types | PostgresLondon 2019 | Louise GrandjoncA story on Postgres index types | PostgresLondon 2019 | Louise Grandjonc
A story on Postgres index types | PostgresLondon 2019 | Louise Grandjonc
 
Why developers need marketing now more than ever | GlueCon 2019 | Claire Gior...
Why developers need marketing now more than ever | GlueCon 2019 | Claire Gior...Why developers need marketing now more than ever | GlueCon 2019 | Claire Gior...
Why developers need marketing now more than ever | GlueCon 2019 | Claire Gior...
 
The Art of PostgreSQL | PostgreSQL Ukraine | Dimitri Fontaine
The Art of PostgreSQL | PostgreSQL Ukraine | Dimitri FontaineThe Art of PostgreSQL | PostgreSQL Ukraine | Dimitri Fontaine
The Art of PostgreSQL | PostgreSQL Ukraine | Dimitri Fontaine
 
Optimizing your app by understanding your Postgres | RailsConf 2019 | Samay S...
Optimizing your app by understanding your Postgres | RailsConf 2019 | Samay S...Optimizing your app by understanding your Postgres | RailsConf 2019 | Samay S...
Optimizing your app by understanding your Postgres | RailsConf 2019 | Samay S...
 
When it all goes wrong (with Postgres) | RailsConf 2019 | Will Leinweber
When it all goes wrong (with Postgres) | RailsConf 2019 | Will LeinweberWhen it all goes wrong (with Postgres) | RailsConf 2019 | Will Leinweber
When it all goes wrong (with Postgres) | RailsConf 2019 | Will Leinweber
 
The Art of PostgreSQL | PostgreSQL Ukraine Meetup | Dimitri Fontaine
The Art of PostgreSQL | PostgreSQL Ukraine Meetup | Dimitri FontaineThe Art of PostgreSQL | PostgreSQL Ukraine Meetup | Dimitri Fontaine
The Art of PostgreSQL | PostgreSQL Ukraine Meetup | Dimitri Fontaine
 
Using Postgres and Citus for Lightning Fast Analytics, also ft. Rollups | Liv...
Using Postgres and Citus for Lightning Fast Analytics, also ft. Rollups | Liv...Using Postgres and Citus for Lightning Fast Analytics, also ft. Rollups | Liv...
Using Postgres and Citus for Lightning Fast Analytics, also ft. Rollups | Liv...
 
How to write SQL queries | pgDay Paris 2019 | Dimitri Fontaine
How to write SQL queries | pgDay Paris 2019 | Dimitri FontaineHow to write SQL queries | pgDay Paris 2019 | Dimitri Fontaine
How to write SQL queries | pgDay Paris 2019 | Dimitri Fontaine
 
When it all Goes Wrong |Nordic PGDay 2019 | Will Leinweber
When it all Goes Wrong |Nordic PGDay 2019 | Will LeinweberWhen it all Goes Wrong |Nordic PGDay 2019 | Will Leinweber
When it all Goes Wrong |Nordic PGDay 2019 | Will Leinweber
 
Why PostgreSQL Why This Database Why Now | Nordic PGDay 2019 | Claire Giordano
Why PostgreSQL Why This Database Why Now | Nordic PGDay 2019 | Claire GiordanoWhy PostgreSQL Why This Database Why Now | Nordic PGDay 2019 | Claire Giordano
Why PostgreSQL Why This Database Why Now | Nordic PGDay 2019 | Claire Giordano
 

Último

Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
nirzagarg
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
wsppdmt
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Computer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdfComputer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdf
SayantanBiswas37
 
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
nirzagarg
 
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
gajnagarg
 
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
gajnagarg
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
nirzagarg
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
HyderabadDolls
 

Último (20)

Kings of Saudi Arabia, information about them
Kings of Saudi Arabia, information about themKings of Saudi Arabia, information about them
Kings of Saudi Arabia, information about them
 
Aspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraAspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - Almora
 
Statistics notes ,it includes mean to index numbers
Statistics notes ,it includes mean to index numbersStatistics notes ,it includes mean to index numbers
Statistics notes ,it includes mean to index numbers
 
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
 
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
 
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt
 
Computer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdfComputer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdf
 
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowVadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
 
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
 
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
 
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
High Profile Call Girls Service in Jalore { 9332606886 } VVIP NISHA Call Girl...
 
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
 

The Future of Distributed Databases is Relational

  • 1. Sumedh Pathak, Co-Founder & VP Engineering, Citus Data QCon London 2018 The Future of Distributed Databases is Relational @moss_toss | @citusdata
  • 2. About Me • Co-Founder & VP Engineering at Citus Data • Amazon Shopping Cart (former) • Amazon Supply Chain & Order Fulfillment (former) • Stanford Computer Science Citus Data co-founders, left-to-right Ozgun Erdogan, Sumedh Pathak, & Umur Cubukcu Photo cred: Willy Johnson, Monterey CA, Sep 2017 Sumedh Pathak | Citus Data | QCon London 2018
  • 3.
  • 4. Why RDBMS? Sumedh Pathak | Citus Data | QCon London 2018
  • 5. Streaming Storage Map Reduce NoSQL SQL Database SELECT ... Application Application Sumedh Pathak | Citus Data | QCon London 2018 Because your architecture could be simpler
  • 6. An RDBMS is a general-purpose data platform Sumedh Pathak | Citus Data | QCon London 2018 Fast writes Real-time & bulk High throughput High concurrency Data consistency Query optimizers
  • 7. PostgreSQL MySQL MongoDB SQL Server + Oracle Source: Hacker News, https://news.ycombinator.com Startups Are Choosing Postgres% database job posts mentioning each database, across 20K+ job posts Sumedh Pathak | Citus Data | QCon London 2018
  • 8. but RDBMS’s don’t scale, right? Sumedh Pathak | Citus Data | QCon London 2018
  • 9. but RDBMS’s don’t scale RDBMS’s are hard to scale Sumedh Pathak | Citus Data | QCon London 2018
  • 10. What exactly needs to Scale? - Tables (Data) - Partitioning, Co-location, Reference Tables - SQL (Reads) - How do we express and optimize distributed SQL - Transactions (Writes) - Cross Shard updates/deletes, Global Atomic Transactions Sumedh Pathak | Citus Data | QCon London 2018 1 2 3
  • 11. Scaling Tables Sumedh Pathak | Citus Data | QCon London 2018
  • 12. How to partition the data? - Pick a column - Date - Id (customer_id, cart_id) - Pick a method - Hash - Range
  • 13. Partition data across nodes R1 R2 R3 R4 R5 R6 R7 Coordinator Node Worker Nodes Shards Sumedh Pathak | Citus Data | QCon London 2018
  • 14. Worker → RDBMS, Shard → Table
  • 15. Reference Tables N1 N1 N1 N1 Copies of same table Sumedh Pathak | Citus Data | QCon London 2018 Coordinator Node Worker Nodes
  • 16. Co-Location R1 R2 R3 R4 S1 S2 S3 S4 Explicit Co-Location API. E.g. Partition by Tenant Sumedh Pathak | Citus Data | QCon London 2018 Coordinator Node Worker Nodes
  • 18. The key to scaling tables... - Use relational databases as a building block - Understand semantics of application—to be smart about partitioning - Multi-tenant applications
  • 20. FROM table R SELECT x Projectx (R) → R’ WHERE f(x) Filterf(x) (R) → R’ … JOIN … R × S → R’ SQL ↔ Relational Algebra Sumedh Pathak | Citus Data | QCon London 2018
  • 21. FROM sharded_table Collect(R1 ,R2 ,...) → R Distributed Relational Algebra R1 R2 C Sumedh Pathak | Citus Data | QCon London 2018
  • 22. Projectx (Collect(R1 ,R2 ,...)) = Collect(Projectx (R1 ), Projectx (R2 )...) Commutative property R1 R2 C R1 R2 C Px Px Px Sumedh Pathak | Citus Data | QCon London 2018
  • 23. Collect(R1 ,R2 ,...) x Collect(S1 ,S2 ,...) = Collect(R1 × S1 ,R2 × S2, ...) Distributive property R1 R2 C × C S1 S2 R1 R2 C × S1 S2 × X = Join Operator
  • 24. SUM(x)(Collect(R1 ,R2 ,...)) = SUM(Collect(SUM(R1 ), SUM(R2 )...)) Associative property R1 R2 C R1 R2 C Sumx Sumx Sumx Sumedh Pathak | Citus Data | QCon London 2018 Sumx
  • 25. SELECT sum(price) FROM orders, nation WHERE orders.nation = nation.name AND orders.date >= '2012-01-01' AND nation.region = 'Asia'; Sumedh Pathak | Citus Data | QCon London 2018
  • 26. Sumedh Pathak | Citus Data | QCon London 2018
  • 27. Sumedh Pathak | Citus Data | QCon London 2018 Volcano style processing Data flows from bottom to top
  • 28. Sumedh Pathak | Citus Data | QCon London 2018
  • 29. Sumedh Pathak | Citus Data | QCon London 2018
  • 30. Sumedh Pathak | Citus Data | QCon London 2018 Parallelize Aggregate Push Joins & Filters below collect. Run in parallel across all nodes Filters & Projections done before Join
  • 31. SELECT sum(intermediate_col) FROM <concatenated results>; SELECT sum(price) FROM orders_2 JOIN nation_2 ON (orders_2.name = nation_2.name) WHERE orders_2.date >= '2017-01-01' AND nation_2.region = 'Asia'; SELECT sum(price) FROM orders_2 JOIN nation_1 ON (orders_2.name = nation_1.name) WHERE orders_2.date >= '2017-01-01' AND nation_2.region = 'Asia'; Sumedh Pathak | Citus Data | QCon London 2018
  • 32. Executing Distributed SQL SQL database orders_1 nation_1 orders nation SELECT sum(price) FROM orders_2 o JOIN nation_1 ON (o.name = n.name) WHERE o.date >= '2017-01-01' AND n.region = 'Asia'; SELECT sum(price) FROM orders_1 o JOIN nation_1 ON (o.name = n.name) WHERE o.date >= '2017-01-01' AND n.region = 'Asia'; SELECT sum(price) FROM <results>; SQL database orders_2 nation_1
  • 33. The key to scaling SQL... - New relational algebra operators for distributed processing - Relational Algebra Properties to optimize tree: Commutativity, Associativity, & Distributivity - Map / Reduce operators
  • 35. Money Transfer, as an example BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; COMMIT; Sumedh Pathak | Citus Data | QCon London 2018
  • 36. A1 A2 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; COMMIT; A3 A4 Coordinator Sumedh Pathak | Citus Data | QCon London 2018
  • 37. A1 A2 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; COMMIT; A3 A4 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; Sumedh Pathak | Citus Data | QCon London 2018 Coordinator
  • 38. A1 A2 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; COMMIT; A3 A4 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; COMMIT; Sumedh Pathak | Citus Data | QCon London 2018 Coordinator
  • 39. A1 A2 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; COMMIT; A3 A4 Coordinator BEGIN; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; Sumedh Pathak | Citus Data | QCon London 2018 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’;
  • 40. A1 A2 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; COMMIT; A3 A4 BEGIN; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; COMMIT Sumedh Pathak | Citus Data | QCon London 2018 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; Coordinator
  • 41. A1 A2 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; COMMIT; A3 A4 PREPARE TRANSACTION ‘citus_...98’; PREPARE TRANSACTION ‘citus_...98’; Sumedh Pathak | Citus Data | QCon London 2018 Coordinator
  • 42. What happens during PREPARE? State of transaction stored on a durable store Locks are maintained &
  • 43. A1 A2 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; COMMIT; A3 A4 Coordinator PREPARE TRANSACTION ‘citus_...98’; ROLLBACK TRANSACTION ‘citus_...98’; Sumedh Pathak | Citus Data | QCon London 2018
  • 44. A1 A2 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; COMMIT; A3 A4 PREPARE TRANSACTION ‘citus_...98’; PREPARE TRANSACTION ‘citus_...98’; Sumedh Pathak | Citus Data | QCon London 2018 Coordinator
  • 45. A1 A2 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; COMMIT; A3 A4 COMMIT PREPARED ‘citus_...98’; COMMIT PREPARED ‘citus_...98’; Sumedh Pathak | Citus Data | QCon London 2018 Coordinator
  • 46. A1 A2 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; COMMIT; A3 A4 COMMIT PREPARED ‘citus_...98’; COMMIT PREPARED ‘citus_...98’; Sumedh Pathak | Citus Data | QCon London 2018 Coordinator
  • 47. A1 A2 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; COMMIT; A3 A4 COMMIT PREPARED ‘citus_...98’; COMMIT PREPARED ‘citus_...98’; Sumedh Pathak | Citus Data | QCon London 2018 Coordinator
  • 49. Example // SESSION 1 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; (LOCK on ROW with id ‘ALICE’) // SESSION 2 Sumedh Pathak | Citus Data | QCon London 2018
  • 50. Example // SESSION 1 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; (LOCK on ROW with id ‘ALICE’) // SESSION 2 BEGIN; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; (LOCK on ROW with id ‘BOB’) Sumedh Pathak | Citus Data | QCon London 2018
  • 51. Example // SESSION 1 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; (LOCK on ROW with id ‘ALICE’) UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; // SESSION 2 BEGIN; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; (LOCK on ROW with id ‘BOB’) Sumedh Pathak | Citus Data | QCon London 2018
  • 52. Example // SESSION 1 BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’; (LOCK on ROW with id ‘ALICE’) UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; // SESSION 2 BEGIN; UPDATE accounts SET balance = balance + 100 WHERE id = ‘BOB’; (LOCK on ROW with id ‘BOB’) UPDATE accounts SET balance = balance - 100 WHERE id = ‘ALICE’ Sumedh Pathak | Citus Data | QCon London 2018
  • 53. How do Relational DB’s solve this? S1 S2 - Construct a Directed Graph - Each node is a session/transaction - Edge represents a wait on a lock Waiting on ‘Bob’ Waiting on ‘Alice’
  • 54. S1 S2 S1 S2 S2 S1 S2 Waits on S1 S1 Waits on S2 Sumedh Pathak | Citus Data | QCon London 2018
  • 55. S1 S2 S1 S2 S2 S1 S2 Waits on S1 S1 Waits on S2 Distributed Deadlock Detector S1 S2 S2 S1 Sumedh Pathak | Citus Data | QCon London 2018
  • 56. keys to scaling transactions - 2PC to ensure atomic transactions across nodes - Deadlock Detection—to scale complex & concurrent transaction workloads - MVCC - Failure Handling 4
  • 57. It’s 2018. Distributed can be Relational - Scale tables—via sharding - Scale SQL—via distributed relational algebra - Scale transactions—via 2PC & Deadlock Detection Sumedh Pathak | Citus Data | QCon London 2018 Now, how do we implement all of this?
  • 58. Postgres Sumedh Pathak | Citus Data | QCon London 2018
  • 59. PostgreSQL Planner Executor Custom scan Commit / abort Extension (.so) Access methods Foreign tables Functions ... ... ... ... ... ... ... CREATE EXTENSION ...
  • 60. PostgreSQL PostgreSQL PostgreSQL shardsshardsshard shardsshardsshard SELECT … FROM distributed_table … SELECT … FROM shard… SELECT … FROM shard… Citus
  • 61. PostgreSQL Citus PostGIS PL/Python JSONB 2PC Replication... Sequences Indexes Full-Text SearchTransactions … dblink Sumedh Pathak | Citus Data | QCon London 2018 Rich ecosystem of tooling, data types, & extensions in PostgreSQL
  • 62. PostgreSQL can be extended into an all-purpose distributed RDBMS
  • 63. I believe the future of distributed databases is relational.
  • 64. Thank you! Sumedh Pathak sumedh@citusdata.com @moss_toss | @citusdata | citusdata.com QCon London 2018 | The Future of Distributed Databases is Relational