SlideShare une entreprise Scribd logo
1  sur  31
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Postgres Conf US - April, 2018
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Database Tuning
• Application
• Data Lifecycle
• Database configuration
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Tuning Methodology
1. Run unit tests
2. Track database statistics
3. Baseline Config
4. Run Load
5. Track database statistics
6. Update config
7. GOTO 4
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What should we track?
• Activity
• Database Utilization
• Table Utilization
• Index Utilization
• Locking
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How do we track it?
• PG Catalog
• Schema in every postgres db (pg_catalog)
• Appended to search_path
• “Data Dictionary”
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
pg_catalog
SELECT pn.nspname, pc.relkind, count(1)
FROM pg_namespace pn, pg_class pc
WHERE pn.oid = pc.relnamespace
AND pn.nspname = 'pg_catalog'
GROUP BY pn.nspname, pc.relkind
ORDER BY 1 DESC;
nspname | relkind | count
------------+---------+-------
pg_catalog | i | 115
pg_catalog | r | 62
pg_catalog | v | 59
i = indexes
r = tables
v = views
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
pg_catalog functions
select count(1)
FROM (
select pn.nspname, pp.proname
FROM pg_namespace pn, pg_proc pp
WHERE pn.oid = pp.pronamespace
AND pn.nspname = 'pg_catalog'
) foo;
count
-----
2882
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
pg_catalog functions
SELECT pn.nspname, pp.proname
FROM pg_namespace pn, pg_proc pp
WHERE pn.oid = pp.pronamespace
AND pn.nspname = 'pg_catalog’;
nspname | proname
------------+--------------
pg_catalog | boolin
pg_catalog | boolout
pg_catalog | byteain
pg_catalog | byteaout
pg_catalog | charin
pg_catalog | charout
pg_catalog | namein
pg_catalog | nameout
...
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
pg_catalog
• Structural
• Performance
• Informational
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
pg_catalog – translation!
• Relation = table, index, sequence, etc…
• Attribute = column
• Namespace = schema
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
pg_catalog - oid
• Object Identifier datatype
• 4 byte unsigned int
• Hidden column on catalog tables
• Primary / Foreign keys throughout pg_catalog schema
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
pg_catalog - oid
postgres=# select * from pg_namespace;
nspname | nspowner | nspacl
--------------------+----------+----------------------------
pg_toast | 10 |
pg_temp_1 | 10 |
pg_toast_temp_1 | 10 |
pg_catalog | 10 | {meads=UC/meads,=U/meads}
public | 10 | {meads=UC/meads,=UC/meads}
information_schema | 10 | {meads=UC/meads,=U/meads}
(6 rows)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
pg_catalog - oid
postgres=# select oid, * from pg_namespace;
oid | nspname | nspowner | nspacl
-------+--------------------+----------+----------------------------
99 | pg_toast | 10 |
11816 | pg_temp_1 | 10 |
11817 | pg_toast_temp_1 | 10 |
11 | pg_catalog | 10 | {meads=UC/meads,=U/meads}
2200 | public | 10 | {meads=UC/meads,=UC/meads}
12349 | information_schema | 10 | {meads=UC/meads,=U/meads}
(6 rows)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
pg_catalog – List all tables in a schema
SELECT pn.nspname, pc.relkind, count(1)
FROM pg_namespace pn, pg_class pc
WHERE pn.oid = pc.relnamespace
AND pn.nspname = 'pg_catalog'
GROUP BY pn.nspname, pc.relkind
ORDER BY 1 DESC;
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What’s this have to do with tuning??
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Tuning Methodology
1. Run unit tests
2. Track database statistics
3. Baseline Config
4. Run Load
5. Track database statistics
6. Update config
7. GOTO 4
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What should we track?
• Activity
• Database Utilization
• Table Utilization
• Index Utilization
• Locking
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Where is the data?
• pg_stat_activity
• pg_stat_database
• pg_stat_all_tables / pg_stat_user_tables
• pg_stat_all_indexes / pg_stat_user_indexes
• pg_locks
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Activity
• pg_stat_activity
• Current activity in the database
• Snapshot of that instant
• Starting point for tuning
• State
• Idle
• Active
• Idle in transaction
select datname, usename,
client_addr,
wait_event,
now() - state_change as runtime,
state, query
from pg_stat_activity ;
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Activity - Tuning
• Application
• Connections
• Concurrency
• Data Lifecycle
• Query runtimes
• WAL
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Activity - Tuning
• Server configuration
• max_connections
• shared_buffers
• work_mem
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Database Statistics
• pg_stat_database
• Utilization stats for each DB in an instance
• Global view of all DBs
select datname, numbackends, xact_commit,
tup_returned, tup_fetched, tup_inserted,
tup_updated, tup_deleted,
pg_database_size(datname),
pg_size_pretty(pg_database_size(datname))
FROM pg_stat_database;
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Table Statistics
• pg_stat_all_tables / pg_stat_user_tables
• Cumulative view of table-level stats
• Basis for workload profile
• pg_stat_all_indexes / pg_stat_user_indexes
• Cumulative view of index-level stats
• Index utilization stats
select schemaname, relname,
n_tup_ins,
n_tup_upd, n_tup_del,
idx_scan, seq_scan
FROM pg_stat_user_tables;
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Where are my hot-spots?
• What’s the most modified (INS / UPD / DEL)?
• What’s the most read ?
• What’s the largest?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Table Stats -Tuning
• Application
• Partitioning
• SQL
• Stored Procedures
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Table Stats - Tuning
• Data Lifecycle
• Datamodel
• Indexing
• Workflow (Truncate vs Delete)
• Database configuration
• Vacuum
• Shared_buffers
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Locking
• pg_locks
• Status of all locks in a given database
• Look for conflicting locks WHERE granted = ‘f’
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Locking - Tuning
• Application
• Workflow
• Data Lifecycle
• Data Model
• Normalization
• ETL
• Maintenance
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Tracking vs Storing
• Cloud Watch
• Performance Insights
• POWA
• PGWatch2
• Snapshot scripts
• Grafana
• ELK
Max CPU
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Learn more..
aws.amazon.com/rds
aws.amazon.com/rds/aurora
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank you!
Scott Mead
meads@amazon.com

Contenu connexe

Tendances

Interactive Analytics in Human Time
Interactive Analytics in Human TimeInteractive Analytics in Human Time
Interactive Analytics in Human TimeDataWorks Summit
 
Apache Atlas: Tracking dataset lineage across Hadoop components
Apache Atlas: Tracking dataset lineage across Hadoop componentsApache Atlas: Tracking dataset lineage across Hadoop components
Apache Atlas: Tracking dataset lineage across Hadoop componentsDataWorks Summit/Hadoop Summit
 
Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019
Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019
Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019VMware Tanzu
 
Addressing Enterprise Customer Pain Points with a Data Driven Architecture
Addressing Enterprise Customer Pain Points with a Data Driven ArchitectureAddressing Enterprise Customer Pain Points with a Data Driven Architecture
Addressing Enterprise Customer Pain Points with a Data Driven ArchitectureDataWorks Summit
 
Heimdall Data: "Increase Application Performance with SQL Auto-Caching; No Co...
Heimdall Data: "Increase Application Performance with SQL Auto-Caching; No Co...Heimdall Data: "Increase Application Performance with SQL Auto-Caching; No Co...
Heimdall Data: "Increase Application Performance with SQL Auto-Caching; No Co...Tom Diederich
 
MongoDB and Hadoop: Driving Business Insights
MongoDB and Hadoop: Driving Business InsightsMongoDB and Hadoop: Driving Business Insights
MongoDB and Hadoop: Driving Business InsightsMongoDB
 
Experimentation Platform on Hadoop
Experimentation Platform on HadoopExperimentation Platform on Hadoop
Experimentation Platform on HadoopDataWorks Summit
 
Atlas ApacheCon 2017
Atlas ApacheCon 2017Atlas ApacheCon 2017
Atlas ApacheCon 2017Vimal Sharma
 
Keynote – From MapReduce to Spark: An Ecosystem Evolves by Doug Cutting, Chie...
Keynote – From MapReduce to Spark: An Ecosystem Evolves by Doug Cutting, Chie...Keynote – From MapReduce to Spark: An Ecosystem Evolves by Doug Cutting, Chie...
Keynote – From MapReduce to Spark: An Ecosystem Evolves by Doug Cutting, Chie...Cloudera, Inc.
 
Insights into Real World Data Management Challenges
Insights into Real World Data Management ChallengesInsights into Real World Data Management Challenges
Insights into Real World Data Management ChallengesDataWorks Summit
 
Efficient Log Management using Oozie, Parquet and Hive
Efficient Log Management using Oozie, Parquet and HiveEfficient Log Management using Oozie, Parquet and Hive
Efficient Log Management using Oozie, Parquet and HiveGopi Krishnan Nambiar
 
Model Parallelism in Spark ML Cross-Validation with Nick Pentreath and Bryan ...
Model Parallelism in Spark ML Cross-Validation with Nick Pentreath and Bryan ...Model Parallelism in Spark ML Cross-Validation with Nick Pentreath and Bryan ...
Model Parallelism in Spark ML Cross-Validation with Nick Pentreath and Bryan ...Databricks
 
Activate 2019 - Search and relevance at scale for online classifieds
Activate 2019 - Search and relevance at scale for online classifiedsActivate 2019 - Search and relevance at scale for online classifieds
Activate 2019 - Search and relevance at scale for online classifiedsRoger Rafanell Mas
 
Learning to Rank Datasets for Search with Oscar Castaneda
Learning to Rank Datasets for Search with Oscar CastanedaLearning to Rank Datasets for Search with Oscar Castaneda
Learning to Rank Datasets for Search with Oscar CastanedaDatabricks
 
Idea behind Apache Hivemall
Idea behind Apache HivemallIdea behind Apache Hivemall
Idea behind Apache HivemallMakoto Yui
 
Optimising Queries - Series 1 Query Optimiser Architecture
Optimising Queries - Series 1 Query Optimiser ArchitectureOptimising Queries - Series 1 Query Optimiser Architecture
Optimising Queries - Series 1 Query Optimiser ArchitectureDAGEOP LTD
 
Fifth Elephant Apache Atlas Talk
Fifth Elephant Apache Atlas TalkFifth Elephant Apache Atlas Talk
Fifth Elephant Apache Atlas TalkVimal Sharma
 
19 09-26 source reconfiguration and august release features
19 09-26 source reconfiguration and august release features19 09-26 source reconfiguration and august release features
19 09-26 source reconfiguration and august release featuresDede Sabey
 

Tendances (20)

Interactive Analytics in Human Time
Interactive Analytics in Human TimeInteractive Analytics in Human Time
Interactive Analytics in Human Time
 
Big Data@Scale
 Big Data@Scale Big Data@Scale
Big Data@Scale
 
Apache Atlas: Tracking dataset lineage across Hadoop components
Apache Atlas: Tracking dataset lineage across Hadoop componentsApache Atlas: Tracking dataset lineage across Hadoop components
Apache Atlas: Tracking dataset lineage across Hadoop components
 
Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019
Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019
Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019
 
Addressing Enterprise Customer Pain Points with a Data Driven Architecture
Addressing Enterprise Customer Pain Points with a Data Driven ArchitectureAddressing Enterprise Customer Pain Points with a Data Driven Architecture
Addressing Enterprise Customer Pain Points with a Data Driven Architecture
 
Heimdall Data: "Increase Application Performance with SQL Auto-Caching; No Co...
Heimdall Data: "Increase Application Performance with SQL Auto-Caching; No Co...Heimdall Data: "Increase Application Performance with SQL Auto-Caching; No Co...
Heimdall Data: "Increase Application Performance with SQL Auto-Caching; No Co...
 
MongoDB and Hadoop: Driving Business Insights
MongoDB and Hadoop: Driving Business InsightsMongoDB and Hadoop: Driving Business Insights
MongoDB and Hadoop: Driving Business Insights
 
Experimentation Platform on Hadoop
Experimentation Platform on HadoopExperimentation Platform on Hadoop
Experimentation Platform on Hadoop
 
Atlas ApacheCon 2017
Atlas ApacheCon 2017Atlas ApacheCon 2017
Atlas ApacheCon 2017
 
Keynote – From MapReduce to Spark: An Ecosystem Evolves by Doug Cutting, Chie...
Keynote – From MapReduce to Spark: An Ecosystem Evolves by Doug Cutting, Chie...Keynote – From MapReduce to Spark: An Ecosystem Evolves by Doug Cutting, Chie...
Keynote – From MapReduce to Spark: An Ecosystem Evolves by Doug Cutting, Chie...
 
Insights into Real World Data Management Challenges
Insights into Real World Data Management ChallengesInsights into Real World Data Management Challenges
Insights into Real World Data Management Challenges
 
Efficient Log Management using Oozie, Parquet and Hive
Efficient Log Management using Oozie, Parquet and HiveEfficient Log Management using Oozie, Parquet and Hive
Efficient Log Management using Oozie, Parquet and Hive
 
Model Parallelism in Spark ML Cross-Validation with Nick Pentreath and Bryan ...
Model Parallelism in Spark ML Cross-Validation with Nick Pentreath and Bryan ...Model Parallelism in Spark ML Cross-Validation with Nick Pentreath and Bryan ...
Model Parallelism in Spark ML Cross-Validation with Nick Pentreath and Bryan ...
 
Activate 2019 - Search and relevance at scale for online classifieds
Activate 2019 - Search and relevance at scale for online classifiedsActivate 2019 - Search and relevance at scale for online classifieds
Activate 2019 - Search and relevance at scale for online classifieds
 
Text Analysis with SAP HANA
Text Analysis with SAP HANAText Analysis with SAP HANA
Text Analysis with SAP HANA
 
Learning to Rank Datasets for Search with Oscar Castaneda
Learning to Rank Datasets for Search with Oscar CastanedaLearning to Rank Datasets for Search with Oscar Castaneda
Learning to Rank Datasets for Search with Oscar Castaneda
 
Idea behind Apache Hivemall
Idea behind Apache HivemallIdea behind Apache Hivemall
Idea behind Apache Hivemall
 
Optimising Queries - Series 1 Query Optimiser Architecture
Optimising Queries - Series 1 Query Optimiser ArchitectureOptimising Queries - Series 1 Query Optimiser Architecture
Optimising Queries - Series 1 Query Optimiser Architecture
 
Fifth Elephant Apache Atlas Talk
Fifth Elephant Apache Atlas TalkFifth Elephant Apache Atlas Talk
Fifth Elephant Apache Atlas Talk
 
19 09-26 source reconfiguration and august release features
19 09-26 source reconfiguration and august release features19 09-26 source reconfiguration and august release features
19 09-26 source reconfiguration and august release features
 

Similaire à Elegant database tuning

Get the Most out of Your Amazon Elasticsearch Service Domain (ANT334-R1) - AW...
Get the Most out of Your Amazon Elasticsearch Service Domain (ANT334-R1) - AW...Get the Most out of Your Amazon Elasticsearch Service Domain (ANT334-R1) - AW...
Get the Most out of Your Amazon Elasticsearch Service Domain (ANT334-R1) - AW...Amazon Web Services
 
Building a Recommender System on AWS
Building a Recommender System on AWSBuilding a Recommender System on AWS
Building a Recommender System on AWSAmazon Web Services
 
16th Athens Big Data Meetup - 1st Talk - An Introduction to Machine Learning ...
16th Athens Big Data Meetup - 1st Talk - An Introduction to Machine Learning ...16th Athens Big Data Meetup - 1st Talk - An Introduction to Machine Learning ...
16th Athens Big Data Meetup - 1st Talk - An Introduction to Machine Learning ...Athens Big Data
 
An introduction to Machine Learning with scikit-learn (October 2018)
An introduction to Machine Learning with scikit-learn (October 2018)An introduction to Machine Learning with scikit-learn (October 2018)
An introduction to Machine Learning with scikit-learn (October 2018)Julien SIMON
 
Introducing Performance Insights - Cloud-Based Database Performance Monitorin...
Introducing Performance Insights - Cloud-Based Database Performance Monitorin...Introducing Performance Insights - Cloud-Based Database Performance Monitorin...
Introducing Performance Insights - Cloud-Based Database Performance Monitorin...Amazon Web Services
 
Performance insights twitch
Performance insights twitchPerformance insights twitch
Performance insights twitchKyle Hailey
 
Workshop: Architecting a Serverless Data Lake
Workshop: Architecting a Serverless Data LakeWorkshop: Architecting a Serverless Data Lake
Workshop: Architecting a Serverless Data LakeAmazon Web Services
 
Petabytes of Data & No Servers: Corteva Scales DNA Analysis to Meet Increasin...
Petabytes of Data & No Servers: Corteva Scales DNA Analysis to Meet Increasin...Petabytes of Data & No Servers: Corteva Scales DNA Analysis to Meet Increasin...
Petabytes of Data & No Servers: Corteva Scales DNA Analysis to Meet Increasin...Amazon Web Services
 
From Data To Insights
From Data To Insights From Data To Insights
From Data To Insights Orit Alul
 
Using Performance Insights to Optimize Database Performance (DAT402) - AWS re...
Using Performance Insights to Optimize Database Performance (DAT402) - AWS re...Using Performance Insights to Optimize Database Performance (DAT402) - AWS re...
Using Performance Insights to Optimize Database Performance (DAT402) - AWS re...Amazon Web Services
 
How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...
How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...
How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...Amazon Web Services
 
Accelerate Your Analytic Queries with Amazon Aurora Parallel Query (DAT362) -...
Accelerate Your Analytic Queries with Amazon Aurora Parallel Query (DAT362) -...Accelerate Your Analytic Queries with Amazon Aurora Parallel Query (DAT362) -...
Accelerate Your Analytic Queries with Amazon Aurora Parallel Query (DAT362) -...Amazon Web Services
 
How Trek10 Uses Datadog's Distributed Tracing to Improve AWS Lambda Projects ...
How Trek10 Uses Datadog's Distributed Tracing to Improve AWS Lambda Projects ...How Trek10 Uses Datadog's Distributed Tracing to Improve AWS Lambda Projects ...
How Trek10 Uses Datadog's Distributed Tracing to Improve AWS Lambda Projects ...Amazon Web Services
 
Choose the right DB for the Job - Builders Day Israel
Choose the right DB for the Job - Builders Day IsraelChoose the right DB for the Job - Builders Day Israel
Choose the right DB for the Job - Builders Day IsraelAmazon Web Services
 
Driving Machine Learning and Analytics Use Cases with AWS Storage (STG302) - ...
Driving Machine Learning and Analytics Use Cases with AWS Storage (STG302) - ...Driving Machine Learning and Analytics Use Cases with AWS Storage (STG302) - ...
Driving Machine Learning and Analytics Use Cases with AWS Storage (STG302) - ...Amazon Web Services
 
Petabytes of Data and No Servers: Corteva Scales DNA Analysis to Meet Increas...
Petabytes of Data and No Servers: Corteva Scales DNA Analysis to Meet Increas...Petabytes of Data and No Servers: Corteva Scales DNA Analysis to Meet Increas...
Petabytes of Data and No Servers: Corteva Scales DNA Analysis to Meet Increas...Capgemini
 
Amazon DynamoDB Deep Dive Advanced Design Patterns for DynamoDB (DAT401) - AW...
Amazon DynamoDB Deep Dive Advanced Design Patterns for DynamoDB (DAT401) - AW...Amazon DynamoDB Deep Dive Advanced Design Patterns for DynamoDB (DAT401) - AW...
Amazon DynamoDB Deep Dive Advanced Design Patterns for DynamoDB (DAT401) - AW...Amazon Web Services
 
AWS re:Invent 2018 - ENT321 - SageMaker Workshop
AWS re:Invent 2018 - ENT321 - SageMaker WorkshopAWS re:Invent 2018 - ENT321 - SageMaker Workshop
AWS re:Invent 2018 - ENT321 - SageMaker WorkshopJulien SIMON
 
The Future of API Management Is Serverless
The Future of API Management Is ServerlessThe Future of API Management Is Serverless
The Future of API Management Is ServerlessChris Munns
 
Data Transformation Patterns in AWS - AWS Online Tech Talks
Data Transformation Patterns in AWS - AWS Online Tech TalksData Transformation Patterns in AWS - AWS Online Tech Talks
Data Transformation Patterns in AWS - AWS Online Tech TalksAmazon Web Services
 

Similaire à Elegant database tuning (20)

Get the Most out of Your Amazon Elasticsearch Service Domain (ANT334-R1) - AW...
Get the Most out of Your Amazon Elasticsearch Service Domain (ANT334-R1) - AW...Get the Most out of Your Amazon Elasticsearch Service Domain (ANT334-R1) - AW...
Get the Most out of Your Amazon Elasticsearch Service Domain (ANT334-R1) - AW...
 
Building a Recommender System on AWS
Building a Recommender System on AWSBuilding a Recommender System on AWS
Building a Recommender System on AWS
 
16th Athens Big Data Meetup - 1st Talk - An Introduction to Machine Learning ...
16th Athens Big Data Meetup - 1st Talk - An Introduction to Machine Learning ...16th Athens Big Data Meetup - 1st Talk - An Introduction to Machine Learning ...
16th Athens Big Data Meetup - 1st Talk - An Introduction to Machine Learning ...
 
An introduction to Machine Learning with scikit-learn (October 2018)
An introduction to Machine Learning with scikit-learn (October 2018)An introduction to Machine Learning with scikit-learn (October 2018)
An introduction to Machine Learning with scikit-learn (October 2018)
 
Introducing Performance Insights - Cloud-Based Database Performance Monitorin...
Introducing Performance Insights - Cloud-Based Database Performance Monitorin...Introducing Performance Insights - Cloud-Based Database Performance Monitorin...
Introducing Performance Insights - Cloud-Based Database Performance Monitorin...
 
Performance insights twitch
Performance insights twitchPerformance insights twitch
Performance insights twitch
 
Workshop: Architecting a Serverless Data Lake
Workshop: Architecting a Serverless Data LakeWorkshop: Architecting a Serverless Data Lake
Workshop: Architecting a Serverless Data Lake
 
Petabytes of Data & No Servers: Corteva Scales DNA Analysis to Meet Increasin...
Petabytes of Data & No Servers: Corteva Scales DNA Analysis to Meet Increasin...Petabytes of Data & No Servers: Corteva Scales DNA Analysis to Meet Increasin...
Petabytes of Data & No Servers: Corteva Scales DNA Analysis to Meet Increasin...
 
From Data To Insights
From Data To Insights From Data To Insights
From Data To Insights
 
Using Performance Insights to Optimize Database Performance (DAT402) - AWS re...
Using Performance Insights to Optimize Database Performance (DAT402) - AWS re...Using Performance Insights to Optimize Database Performance (DAT402) - AWS re...
Using Performance Insights to Optimize Database Performance (DAT402) - AWS re...
 
How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...
How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...
How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...
 
Accelerate Your Analytic Queries with Amazon Aurora Parallel Query (DAT362) -...
Accelerate Your Analytic Queries with Amazon Aurora Parallel Query (DAT362) -...Accelerate Your Analytic Queries with Amazon Aurora Parallel Query (DAT362) -...
Accelerate Your Analytic Queries with Amazon Aurora Parallel Query (DAT362) -...
 
How Trek10 Uses Datadog's Distributed Tracing to Improve AWS Lambda Projects ...
How Trek10 Uses Datadog's Distributed Tracing to Improve AWS Lambda Projects ...How Trek10 Uses Datadog's Distributed Tracing to Improve AWS Lambda Projects ...
How Trek10 Uses Datadog's Distributed Tracing to Improve AWS Lambda Projects ...
 
Choose the right DB for the Job - Builders Day Israel
Choose the right DB for the Job - Builders Day IsraelChoose the right DB for the Job - Builders Day Israel
Choose the right DB for the Job - Builders Day Israel
 
Driving Machine Learning and Analytics Use Cases with AWS Storage (STG302) - ...
Driving Machine Learning and Analytics Use Cases with AWS Storage (STG302) - ...Driving Machine Learning and Analytics Use Cases with AWS Storage (STG302) - ...
Driving Machine Learning and Analytics Use Cases with AWS Storage (STG302) - ...
 
Petabytes of Data and No Servers: Corteva Scales DNA Analysis to Meet Increas...
Petabytes of Data and No Servers: Corteva Scales DNA Analysis to Meet Increas...Petabytes of Data and No Servers: Corteva Scales DNA Analysis to Meet Increas...
Petabytes of Data and No Servers: Corteva Scales DNA Analysis to Meet Increas...
 
Amazon DynamoDB Deep Dive Advanced Design Patterns for DynamoDB (DAT401) - AW...
Amazon DynamoDB Deep Dive Advanced Design Patterns for DynamoDB (DAT401) - AW...Amazon DynamoDB Deep Dive Advanced Design Patterns for DynamoDB (DAT401) - AW...
Amazon DynamoDB Deep Dive Advanced Design Patterns for DynamoDB (DAT401) - AW...
 
AWS re:Invent 2018 - ENT321 - SageMaker Workshop
AWS re:Invent 2018 - ENT321 - SageMaker WorkshopAWS re:Invent 2018 - ENT321 - SageMaker Workshop
AWS re:Invent 2018 - ENT321 - SageMaker Workshop
 
The Future of API Management Is Serverless
The Future of API Management Is ServerlessThe Future of API Management Is Serverless
The Future of API Management Is Serverless
 
Data Transformation Patterns in AWS - AWS Online Tech Talks
Data Transformation Patterns in AWS - AWS Online Tech TalksData Transformation Patterns in AWS - AWS Online Tech Talks
Data Transformation Patterns in AWS - AWS Online Tech Talks
 

Dernier

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dashnarutouzumaki53779
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 

Dernier (20)

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dash
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 

Elegant database tuning

  • 1. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Postgres Conf US - April, 2018
  • 2. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Database Tuning • Application • Data Lifecycle • Database configuration
  • 3. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Tuning Methodology 1. Run unit tests 2. Track database statistics 3. Baseline Config 4. Run Load 5. Track database statistics 6. Update config 7. GOTO 4
  • 4. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What should we track? • Activity • Database Utilization • Table Utilization • Index Utilization • Locking
  • 5. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. How do we track it? • PG Catalog • Schema in every postgres db (pg_catalog) • Appended to search_path • “Data Dictionary”
  • 6. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. pg_catalog SELECT pn.nspname, pc.relkind, count(1) FROM pg_namespace pn, pg_class pc WHERE pn.oid = pc.relnamespace AND pn.nspname = 'pg_catalog' GROUP BY pn.nspname, pc.relkind ORDER BY 1 DESC; nspname | relkind | count ------------+---------+------- pg_catalog | i | 115 pg_catalog | r | 62 pg_catalog | v | 59 i = indexes r = tables v = views
  • 7. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. pg_catalog functions select count(1) FROM ( select pn.nspname, pp.proname FROM pg_namespace pn, pg_proc pp WHERE pn.oid = pp.pronamespace AND pn.nspname = 'pg_catalog' ) foo; count ----- 2882
  • 8. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. pg_catalog functions SELECT pn.nspname, pp.proname FROM pg_namespace pn, pg_proc pp WHERE pn.oid = pp.pronamespace AND pn.nspname = 'pg_catalog’; nspname | proname ------------+-------------- pg_catalog | boolin pg_catalog | boolout pg_catalog | byteain pg_catalog | byteaout pg_catalog | charin pg_catalog | charout pg_catalog | namein pg_catalog | nameout ...
  • 9. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. pg_catalog • Structural • Performance • Informational
  • 10. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. pg_catalog – translation! • Relation = table, index, sequence, etc… • Attribute = column • Namespace = schema
  • 11. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. pg_catalog - oid • Object Identifier datatype • 4 byte unsigned int • Hidden column on catalog tables • Primary / Foreign keys throughout pg_catalog schema
  • 12. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. pg_catalog - oid postgres=# select * from pg_namespace; nspname | nspowner | nspacl --------------------+----------+---------------------------- pg_toast | 10 | pg_temp_1 | 10 | pg_toast_temp_1 | 10 | pg_catalog | 10 | {meads=UC/meads,=U/meads} public | 10 | {meads=UC/meads,=UC/meads} information_schema | 10 | {meads=UC/meads,=U/meads} (6 rows)
  • 13. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. pg_catalog - oid postgres=# select oid, * from pg_namespace; oid | nspname | nspowner | nspacl -------+--------------------+----------+---------------------------- 99 | pg_toast | 10 | 11816 | pg_temp_1 | 10 | 11817 | pg_toast_temp_1 | 10 | 11 | pg_catalog | 10 | {meads=UC/meads,=U/meads} 2200 | public | 10 | {meads=UC/meads,=UC/meads} 12349 | information_schema | 10 | {meads=UC/meads,=U/meads} (6 rows)
  • 14. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. pg_catalog – List all tables in a schema SELECT pn.nspname, pc.relkind, count(1) FROM pg_namespace pn, pg_class pc WHERE pn.oid = pc.relnamespace AND pn.nspname = 'pg_catalog' GROUP BY pn.nspname, pc.relkind ORDER BY 1 DESC;
  • 15. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What’s this have to do with tuning??
  • 16. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Tuning Methodology 1. Run unit tests 2. Track database statistics 3. Baseline Config 4. Run Load 5. Track database statistics 6. Update config 7. GOTO 4
  • 17. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What should we track? • Activity • Database Utilization • Table Utilization • Index Utilization • Locking
  • 18. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Where is the data? • pg_stat_activity • pg_stat_database • pg_stat_all_tables / pg_stat_user_tables • pg_stat_all_indexes / pg_stat_user_indexes • pg_locks
  • 19. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Activity • pg_stat_activity • Current activity in the database • Snapshot of that instant • Starting point for tuning • State • Idle • Active • Idle in transaction select datname, usename, client_addr, wait_event, now() - state_change as runtime, state, query from pg_stat_activity ;
  • 20. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Activity - Tuning • Application • Connections • Concurrency • Data Lifecycle • Query runtimes • WAL
  • 21. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Activity - Tuning • Server configuration • max_connections • shared_buffers • work_mem
  • 22. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Database Statistics • pg_stat_database • Utilization stats for each DB in an instance • Global view of all DBs select datname, numbackends, xact_commit, tup_returned, tup_fetched, tup_inserted, tup_updated, tup_deleted, pg_database_size(datname), pg_size_pretty(pg_database_size(datname)) FROM pg_stat_database;
  • 23. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Table Statistics • pg_stat_all_tables / pg_stat_user_tables • Cumulative view of table-level stats • Basis for workload profile • pg_stat_all_indexes / pg_stat_user_indexes • Cumulative view of index-level stats • Index utilization stats select schemaname, relname, n_tup_ins, n_tup_upd, n_tup_del, idx_scan, seq_scan FROM pg_stat_user_tables;
  • 24. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Where are my hot-spots? • What’s the most modified (INS / UPD / DEL)? • What’s the most read ? • What’s the largest?
  • 25. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Table Stats -Tuning • Application • Partitioning • SQL • Stored Procedures
  • 26. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Table Stats - Tuning • Data Lifecycle • Datamodel • Indexing • Workflow (Truncate vs Delete) • Database configuration • Vacuum • Shared_buffers
  • 27. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Locking • pg_locks • Status of all locks in a given database • Look for conflicting locks WHERE granted = ‘f’
  • 28. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Locking - Tuning • Application • Workflow • Data Lifecycle • Data Model • Normalization • ETL • Maintenance
  • 29. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Tracking vs Storing • Cloud Watch • Performance Insights • POWA • PGWatch2 • Snapshot scripts • Grafana • ELK Max CPU
  • 30. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Learn more.. aws.amazon.com/rds aws.amazon.com/rds/aurora
  • 31. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank you! Scott Mead meads@amazon.com