SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Your Database
  a story of indifference
Vanity Plate

I’m Rob

Enterprise Data Magistrate (Ego Ridden Stable)

SET twitter = @datachomp

SET blog = datachomp.com

SET app.net = @datachomp, balance = balance-$50
Prelude
Life Imitates Art




DBA         AppDev
Angry Love Making

We are paid to care about different things
Tender Hug Making

  But we have a common goal
First World Problems

What happens when you can’t afford a DBA?


Who is the primary care provider for the DB?


        This is where our story begins
Characters




Your DB      Your App
The Hero   Knuckle Dragger
~Story 1~
You’re not my
 Data Type
ORM As A Service
:mycolumn, :integer

:mydate, :timestamp


ints are 4 bytes for every row - 2B
smallints are 2 bytes for every row - 32K

date = 4 bytes
timestamp = 8 bytes
The Setting
CREATE TABLE thinner
 (id smallserial,
 things smallint,
 CONSTRAINT thinner_pkey PRIMARY KEY (id));

CREATE TABLE bloaty
 (id bigserial,
 things bigint,
 CONSTRAINT bloaty_pkey PRIMARY KEY (id));


                                 Table        Size    Index
          Insert 10K
                                thinner       384kb   240kb
            records
                                bloaty        464kb   240kb
Healthy Diet of Suffering
When they key is added to a larger table
CREAT TABLE smallertime (id serial, fk_numbers smallint, stringers varchar(80), recents timestamp default now())




     And indexes are added                                                                  I need sweat pants

        Table                       Size                       Index

      smaller                      97MB                       113MB

        larger                    111MB                      121MB
Death by 1000 Bytes

Disks are cheap, but good disks are not


Bigger DB = Longer Backups/Recovery


    Don’t waste your buffer cache


    Partitions are free in Postgres
~Story 2~
You’re Making Me Sick
Sipping on Gin and GiST
   B-Tree, Gin, GiST, Partial, Expression, Unique


            Full Text Index / Searching



https://devcenter.heroku.com/articles/postgresql-indexes
Sargability
Indexes are only awesome when you can use them
                    Btree
                      <
                      <=
                      =
                      >=
                      >


WHERE sucks LIKE ‘%tablescan’


WHERE suckyfunc(column) = ‘pain’
So Worthless
    Indexes are not a get out of perf jail free card

             They have to be maintained

               They have to have writes


SELECT * FROM pg_stat_all_indexes WHERE schemaname<>'pg_catalog'
So Worthless
Indexes are not a get out of perf jail free card

                 They have to be maintained

                    They have to have writes

                      There Can Be Dupes!
SELECT pg_size_pretty(sum(pg_relation_size(idx))::bigint) AS size,
       (array_agg(idx))[1] AS idx1, (array_agg(idx))[2] AS idx2,
       (array_agg(idx))[3] AS idx3, (array_agg(idx))[4] AS idx4
FROM (
    SELECT indexrelid::regclass AS idx, (indrelid::text ||E'n'|| indclass::text ||E'n'||
indkey::text ||E'n'||
                                          coalesce(indexprs::text,'')||E'n' ||
coalesce(indpred::text,'')) AS KEY
    FROM pg_index) sub
GROUP BY KEY HAVING count(*)>1
ORDER BY sum(pg_relation_size(idx)) DESC;
~Story 3~
No One Is Listening
            My tuples are
   43    doing the
    5
        Harlem Shake
Do you even add bro?
 R × S = {(r1, r2, ..., rn, s1, s2, ..., sm) | (r1, r2, ..., rn) ∈ R, (s1, s2, ..., sm) ∈ S}




     U := T- R                                 Cartesian Products


Relational Algebra                                R ⟗ S = (R ⟕ S) (R ⟖ S)
                                                  Outer Join


             R φ S = σφ(R × S)
                                                       equijoins
Explain Yourself
The engine can talk:
EXPLAIN SELECT * FROM sites;

  Seq Scan on sites (cost=0.00..1.09 rows=9 width=46)
EXPLAIN (BUFFERS true, ANALYZE true, FORMAT
YAML) SELECT * FROM sites;
   - Plan:
      Node Type: "Seq Scan"
      Relation Name: "sites"
      Alias: "sites"
      Startup Cost: 0.00
      Total Cost: 1.09
      Plan Rows: 9
      Plan Width: 46
     Actual Total Time: 0.011
     Actual Rows: 9
Kind of a big deal

Stats - they are a pretty big deal

SELECT * FROM pg_stat_all_tables

VACUUM ANALYZE <tablename>
Real big deal
     There are lots of helpful tables
 pg_stat_activity         pg_stat_all_indexes
 pg_stat_databse         pg_statio_user_tables
pg_stat_user_tables     pg_stat_user_functions

  Lots of other tools to show you stat info

      Lots of good existing queries
     Don’t have to reinvent the wheel
Set Based Operations
                     Marry me
                    Active Record


 N+1 is a performance death sentence

   RBAR - Row By Agonizing Row


  Always profile your App/ORM
       The App has context
Choose Your Own
        Adventure
Care about your data

So we can all live App’ily ever after

Artsy thank you - @tenderlove and @derekgrape

Thank you - Heroku and other sponsors

Thank you - the person making a difference

Happy Hour?!?!

Weitere ähnliche Inhalte

Was ist angesagt?

Nosql hands on handout 04
Nosql hands on handout 04Nosql hands on handout 04
Nosql hands on handout 04Krishna Sankar
 
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
[Pgday.Seoul 2021] 2. Porting Oracle UDF and OptimizationPgDay.Seoul
 
How to calculate the optimal undo retention in Oracle
How to calculate the optimal undo retention in OracleHow to calculate the optimal undo retention in Oracle
How to calculate the optimal undo retention in OracleJorge Batista
 
Database API, your new friend
Database API, your new friendDatabase API, your new friend
Database API, your new friendkikoalonsob
 
You Don't Need Lodash
You Don't Need Lodash You Don't Need Lodash
You Don't Need Lodash UpsideTravel
 
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스PgDay.Seoul
 
Future of HTTP in CakePHP
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHPmarkstory
 
PostgreSQL (2) by Aswin
PostgreSQL (2) by AswinPostgreSQL (2) by Aswin
PostgreSQL (2) by AswinAgate Studio
 
Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB jhchabran
 
R Brown-bag seminars : Seminar-8
R Brown-bag seminars : Seminar-8R Brown-bag seminars : Seminar-8
R Brown-bag seminars : Seminar-8Muhammad Nabi Ahmad
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)Night Sailer
 
Drush - use full power - DrupalCamp Donetsk 2014
Drush - use full power - DrupalCamp Donetsk 2014Drush - use full power - DrupalCamp Donetsk 2014
Drush - use full power - DrupalCamp Donetsk 2014Alex S
 
groovy databases
groovy databasesgroovy databases
groovy databasesPaul King
 
Database administration commands
Database administration commands Database administration commands
Database administration commands Varsha Ajith
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applicationsSkills Matter
 
Data handling in r
Data handling in rData handling in r
Data handling in rAbhik Seal
 

Was ist angesagt? (20)

Nosql hands on handout 04
Nosql hands on handout 04Nosql hands on handout 04
Nosql hands on handout 04
 
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
 
MySql:Basics
MySql:BasicsMySql:Basics
MySql:Basics
 
MySql:Introduction
MySql:IntroductionMySql:Introduction
MySql:Introduction
 
How to calculate the optimal undo retention in Oracle
How to calculate the optimal undo retention in OracleHow to calculate the optimal undo retention in Oracle
How to calculate the optimal undo retention in Oracle
 
Database API, your new friend
Database API, your new friendDatabase API, your new friend
Database API, your new friend
 
19. CodeIgniter imagini in mysql
19. CodeIgniter imagini in mysql19. CodeIgniter imagini in mysql
19. CodeIgniter imagini in mysql
 
Save game function
Save game functionSave game function
Save game function
 
You Don't Need Lodash
You Don't Need Lodash You Don't Need Lodash
You Don't Need Lodash
 
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
 
Future of HTTP in CakePHP
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHP
 
PostgreSQL (2) by Aswin
PostgreSQL (2) by AswinPostgreSQL (2) by Aswin
PostgreSQL (2) by Aswin
 
Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB
 
R Brown-bag seminars : Seminar-8
R Brown-bag seminars : Seminar-8R Brown-bag seminars : Seminar-8
R Brown-bag seminars : Seminar-8
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
 
Drush - use full power - DrupalCamp Donetsk 2014
Drush - use full power - DrupalCamp Donetsk 2014Drush - use full power - DrupalCamp Donetsk 2014
Drush - use full power - DrupalCamp Donetsk 2014
 
groovy databases
groovy databasesgroovy databases
groovy databases
 
Database administration commands
Database administration commands Database administration commands
Database administration commands
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applications
 
Data handling in r
Data handling in rData handling in r
Data handling in r
 

Andere mochten auch

Kirby Ferguson at Heroku's Waza 2013
Kirby Ferguson at Heroku's Waza 2013Kirby Ferguson at Heroku's Waza 2013
Kirby Ferguson at Heroku's Waza 2013Heroku
 
Rdio's Alex Gaynor at Heroku's Waza 2013: Why Python, Ruby and Javascript are...
Rdio's Alex Gaynor at Heroku's Waza 2013: Why Python, Ruby and Javascript are...Rdio's Alex Gaynor at Heroku's Waza 2013: Why Python, Ruby and Javascript are...
Rdio's Alex Gaynor at Heroku's Waza 2013: Why Python, Ruby and Javascript are...Heroku
 
Codeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's Business
Codeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's BusinessCodeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's Business
Codeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's BusinessHeroku
 
Heroku webcastdeck+20130828
Heroku webcastdeck+20130828Heroku webcastdeck+20130828
Heroku webcastdeck+20130828Heroku
 
Heroku Connect: The New Way to Build Connected Customer Applications
Heroku Connect: The New Way to Build Connected Customer ApplicationsHeroku Connect: The New Way to Build Connected Customer Applications
Heroku Connect: The New Way to Build Connected Customer ApplicationsHeroku
 
Heroku 101 py con 2015 - David Gouldin
Heroku 101   py con 2015 - David GouldinHeroku 101   py con 2015 - David Gouldin
Heroku 101 py con 2015 - David GouldinHeroku
 

Andere mochten auch (6)

Kirby Ferguson at Heroku's Waza 2013
Kirby Ferguson at Heroku's Waza 2013Kirby Ferguson at Heroku's Waza 2013
Kirby Ferguson at Heroku's Waza 2013
 
Rdio's Alex Gaynor at Heroku's Waza 2013: Why Python, Ruby and Javascript are...
Rdio's Alex Gaynor at Heroku's Waza 2013: Why Python, Ruby and Javascript are...Rdio's Alex Gaynor at Heroku's Waza 2013: Why Python, Ruby and Javascript are...
Rdio's Alex Gaynor at Heroku's Waza 2013: Why Python, Ruby and Javascript are...
 
Codeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's Business
Codeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's BusinessCodeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's Business
Codeacademy's Linda Liukas at Heroku's Waza 2013: Code is Everyone's Business
 
Heroku webcastdeck+20130828
Heroku webcastdeck+20130828Heroku webcastdeck+20130828
Heroku webcastdeck+20130828
 
Heroku Connect: The New Way to Build Connected Customer Applications
Heroku Connect: The New Way to Build Connected Customer ApplicationsHeroku Connect: The New Way to Build Connected Customer Applications
Heroku Connect: The New Way to Build Connected Customer Applications
 
Heroku 101 py con 2015 - David Gouldin
Heroku 101   py con 2015 - David GouldinHeroku 101   py con 2015 - David Gouldin
Heroku 101 py con 2015 - David Gouldin
 

Ähnlich wie Rob Sullivan at Heroku's Waza 2013: Your Database -- A Story of Indifference

クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介Masayuki Matsushita
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeWim Godden
 
PerlApp2Postgresql (2)
PerlApp2Postgresql (2)PerlApp2Postgresql (2)
PerlApp2Postgresql (2)Jerome Eteve
 
Everyday I'm Shuffling - Tips for Writing Better Spark Programs, Strata San J...
Everyday I'm Shuffling - Tips for Writing Better Spark Programs, Strata San J...Everyday I'm Shuffling - Tips for Writing Better Spark Programs, Strata San J...
Everyday I'm Shuffling - Tips for Writing Better Spark Programs, Strata San J...Databricks
 
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016DataStax
 
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)Serban Tanasa
 
It's Not You. It's Your Data Model.
It's Not You. It's Your Data Model.It's Not You. It's Your Data Model.
It's Not You. It's Your Data Model.Alex Powers
 
Data profiling in Apache Calcite
Data profiling in Apache CalciteData profiling in Apache Calcite
Data profiling in Apache CalciteDataWorks Summit
 
Data profiling with Apache Calcite
Data profiling with Apache CalciteData profiling with Apache Calcite
Data profiling with Apache CalciteJulian Hyde
 
Advanced SQL For Data Scientists
Advanced SQL For Data ScientistsAdvanced SQL For Data Scientists
Advanced SQL For Data ScientistsDatabricks
 
Data Profiling in Apache Calcite
Data Profiling in Apache CalciteData Profiling in Apache Calcite
Data Profiling in Apache CalciteJulian Hyde
 
Lazy beats Smart and Fast
Lazy beats Smart and FastLazy beats Smart and Fast
Lazy beats Smart and FastJulian Hyde
 
String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?Jeremy Schneider
 
Postgres can do THAT?
Postgres can do THAT?Postgres can do THAT?
Postgres can do THAT?alexbrasetvik
 
PERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsPERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsSunil Kumar Gunasekaran
 
R programming & Machine Learning
R programming & Machine LearningR programming & Machine Learning
R programming & Machine LearningAmanBhalla14
 
Perl at SkyCon'12
Perl at SkyCon'12Perl at SkyCon'12
Perl at SkyCon'12Tim Bunce
 
Advanced Int->Bigint Conversions
Advanced Int->Bigint ConversionsAdvanced Int->Bigint Conversions
Advanced Int->Bigint ConversionsRobert Treat
 
Data Science for Folks Without (or With!) a Ph.D.
Data Science for Folks Without (or With!) a Ph.D.Data Science for Folks Without (or With!) a Ph.D.
Data Science for Folks Without (or With!) a Ph.D.Douglas Starnes
 

Ähnlich wie Rob Sullivan at Heroku's Waza 2013: Your Database -- A Story of Indifference (20)

クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the code
 
PerlApp2Postgresql (2)
PerlApp2Postgresql (2)PerlApp2Postgresql (2)
PerlApp2Postgresql (2)
 
Everyday I'm Shuffling - Tips for Writing Better Spark Programs, Strata San J...
Everyday I'm Shuffling - Tips for Writing Better Spark Programs, Strata San J...Everyday I'm Shuffling - Tips for Writing Better Spark Programs, Strata San J...
Everyday I'm Shuffling - Tips for Writing Better Spark Programs, Strata San J...
 
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
From Postgres to Cassandra (Rimas Silkaitis, Heroku) | C* Summit 2016
 
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
 
It's Not You. It's Your Data Model.
It's Not You. It's Your Data Model.It's Not You. It's Your Data Model.
It's Not You. It's Your Data Model.
 
Data profiling in Apache Calcite
Data profiling in Apache CalciteData profiling in Apache Calcite
Data profiling in Apache Calcite
 
Data profiling with Apache Calcite
Data profiling with Apache CalciteData profiling with Apache Calcite
Data profiling with Apache Calcite
 
Advanced SQL For Data Scientists
Advanced SQL For Data ScientistsAdvanced SQL For Data Scientists
Advanced SQL For Data Scientists
 
Data Profiling in Apache Calcite
Data Profiling in Apache CalciteData Profiling in Apache Calcite
Data Profiling in Apache Calcite
 
Lazy beats Smart and Fast
Lazy beats Smart and FastLazy beats Smart and Fast
Lazy beats Smart and Fast
 
String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?
 
Postgres can do THAT?
Postgres can do THAT?Postgres can do THAT?
Postgres can do THAT?
 
PERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsPERL for QA - Important Commands and applications
PERL for QA - Important Commands and applications
 
R programming & Machine Learning
R programming & Machine LearningR programming & Machine Learning
R programming & Machine Learning
 
Perl at SkyCon'12
Perl at SkyCon'12Perl at SkyCon'12
Perl at SkyCon'12
 
Decision Tree.pptx
Decision Tree.pptxDecision Tree.pptx
Decision Tree.pptx
 
Advanced Int->Bigint Conversions
Advanced Int->Bigint ConversionsAdvanced Int->Bigint Conversions
Advanced Int->Bigint Conversions
 
Data Science for Folks Without (or With!) a Ph.D.
Data Science for Folks Without (or With!) a Ph.D.Data Science for Folks Without (or With!) a Ph.D.
Data Science for Folks Without (or With!) a Ph.D.
 

Kürzlich hochgeladen

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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
 
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
 

Kürzlich hochgeladen (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
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
 

Rob Sullivan at Heroku's Waza 2013: Your Database -- A Story of Indifference

  • 1. Your Database a story of indifference
  • 2. Vanity Plate I’m Rob Enterprise Data Magistrate (Ego Ridden Stable) SET twitter = @datachomp SET blog = datachomp.com SET app.net = @datachomp, balance = balance-$50
  • 4. Angry Love Making We are paid to care about different things
  • 5. Tender Hug Making But we have a common goal
  • 6. First World Problems What happens when you can’t afford a DBA? Who is the primary care provider for the DB? This is where our story begins
  • 7. Characters Your DB Your App The Hero Knuckle Dragger
  • 8. ~Story 1~ You’re not my Data Type
  • 9. ORM As A Service :mycolumn, :integer :mydate, :timestamp ints are 4 bytes for every row - 2B smallints are 2 bytes for every row - 32K date = 4 bytes timestamp = 8 bytes
  • 10. The Setting CREATE TABLE thinner (id smallserial, things smallint, CONSTRAINT thinner_pkey PRIMARY KEY (id)); CREATE TABLE bloaty (id bigserial, things bigint, CONSTRAINT bloaty_pkey PRIMARY KEY (id)); Table Size Index Insert 10K thinner 384kb 240kb records bloaty 464kb 240kb
  • 11. Healthy Diet of Suffering When they key is added to a larger table CREAT TABLE smallertime (id serial, fk_numbers smallint, stringers varchar(80), recents timestamp default now()) And indexes are added I need sweat pants Table Size Index smaller 97MB 113MB larger 111MB 121MB
  • 12. Death by 1000 Bytes Disks are cheap, but good disks are not Bigger DB = Longer Backups/Recovery Don’t waste your buffer cache Partitions are free in Postgres
  • 14. Sipping on Gin and GiST B-Tree, Gin, GiST, Partial, Expression, Unique Full Text Index / Searching https://devcenter.heroku.com/articles/postgresql-indexes
  • 15. Sargability Indexes are only awesome when you can use them Btree < <= = >= > WHERE sucks LIKE ‘%tablescan’ WHERE suckyfunc(column) = ‘pain’
  • 16. So Worthless Indexes are not a get out of perf jail free card They have to be maintained They have to have writes SELECT * FROM pg_stat_all_indexes WHERE schemaname<>'pg_catalog'
  • 17. So Worthless Indexes are not a get out of perf jail free card They have to be maintained They have to have writes There Can Be Dupes! SELECT pg_size_pretty(sum(pg_relation_size(idx))::bigint) AS size, (array_agg(idx))[1] AS idx1, (array_agg(idx))[2] AS idx2, (array_agg(idx))[3] AS idx3, (array_agg(idx))[4] AS idx4 FROM ( SELECT indexrelid::regclass AS idx, (indrelid::text ||E'n'|| indclass::text ||E'n'|| indkey::text ||E'n'|| coalesce(indexprs::text,'')||E'n' || coalesce(indpred::text,'')) AS KEY FROM pg_index) sub GROUP BY KEY HAVING count(*)>1 ORDER BY sum(pg_relation_size(idx)) DESC;
  • 18. ~Story 3~ No One Is Listening My tuples are 43 doing the 5  Harlem Shake
  • 19. Do you even add bro? R × S = {(r1, r2, ..., rn, s1, s2, ..., sm) | (r1, r2, ..., rn) ∈ R, (s1, s2, ..., sm) ∈ S} U := T- R Cartesian Products Relational Algebra R ⟗ S = (R ⟕ S) (R ⟖ S) Outer Join R φ S = σφ(R × S) equijoins
  • 20. Explain Yourself The engine can talk: EXPLAIN SELECT * FROM sites; Seq Scan on sites (cost=0.00..1.09 rows=9 width=46) EXPLAIN (BUFFERS true, ANALYZE true, FORMAT YAML) SELECT * FROM sites; - Plan: Node Type: "Seq Scan" Relation Name: "sites" Alias: "sites" Startup Cost: 0.00 Total Cost: 1.09 Plan Rows: 9 Plan Width: 46 Actual Total Time: 0.011 Actual Rows: 9
  • 21. Kind of a big deal Stats - they are a pretty big deal SELECT * FROM pg_stat_all_tables VACUUM ANALYZE <tablename>
  • 22. Real big deal There are lots of helpful tables pg_stat_activity pg_stat_all_indexes pg_stat_databse pg_statio_user_tables pg_stat_user_tables pg_stat_user_functions Lots of other tools to show you stat info Lots of good existing queries Don’t have to reinvent the wheel
  • 23. Set Based Operations Marry me Active Record N+1 is a performance death sentence RBAR - Row By Agonizing Row Always profile your App/ORM The App has context
  • 24. Choose Your Own Adventure Care about your data So we can all live App’ily ever after Artsy thank you - @tenderlove and @derekgrape Thank you - Heroku and other sponsors Thank you - the person making a difference Happy Hour?!?!