SlideShare una empresa de Scribd logo
1 de 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?!?!

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Destacado

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
 

Destacado (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
 

Similar a 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
 

Similar a 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.
 

Último

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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
 
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
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Último (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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...
 
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
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

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?!?!