SlideShare a Scribd company logo
© 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

More Related Content

PPTX
SharePoint Databases: What you need to know (201512)
Alan Eardley
 
PPTX
Understanding and Configuring an Effective SharePoint 2013 Search
Metanalysis
 
PDF
Show me the Money! Cost & Resource Tracking for Hadoop and Storm
DataWorks Summit/Hadoop Summit
 
PDF
Choosing the Right Database for My Workload: Purpose-Built Databases
AWS Germany
 
PPTX
Customer Feedback Analytics for Starbucks
Nishant Gandhi
 
PDF
Phoenix - A High Performance Open Source SQL Layer over HBase
Salesforce Developers
 
PPTX
Tag based policies using Apache Atlas and Ranger
Vimal Sharma
 
PPTX
Interactive Analytics in Human Time
DataWorks Summit
 
SharePoint Databases: What you need to know (201512)
Alan Eardley
 
Understanding and Configuring an Effective SharePoint 2013 Search
Metanalysis
 
Show me the Money! Cost & Resource Tracking for Hadoop and Storm
DataWorks Summit/Hadoop Summit
 
Choosing the Right Database for My Workload: Purpose-Built Databases
AWS Germany
 
Customer Feedback Analytics for Starbucks
Nishant Gandhi
 
Phoenix - A High Performance Open Source SQL Layer over HBase
Salesforce Developers
 
Tag based policies using Apache Atlas and Ranger
Vimal Sharma
 
Interactive Analytics in Human Time
DataWorks Summit
 

What's hot (19)

PPTX
Apache Atlas: Tracking dataset lineage across Hadoop components
DataWorks Summit/Hadoop Summit
 
PDF
Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019
VMware Tanzu
 
POTX
Addressing Enterprise Customer Pain Points with a Data Driven Architecture
DataWorks Summit
 
PPTX
Heimdall Data: "Increase Application Performance with SQL Auto-Caching; No Co...
Tom Diederich
 
PDF
MongoDB and Hadoop: Driving Business Insights
MongoDB
 
PPTX
Experimentation Platform on Hadoop
DataWorks Summit
 
PDF
Atlas ApacheCon 2017
Vimal Sharma
 
PPTX
Keynote – From MapReduce to Spark: An Ecosystem Evolves by Doug Cutting, Chie...
Cloudera, Inc.
 
PPTX
Insights into Real World Data Management Challenges
DataWorks Summit
 
PDF
Efficient Log Management using Oozie, Parquet and Hive
Gopi Krishnan Nambiar
 
PDF
Model Parallelism in Spark ML Cross-Validation with Nick Pentreath and Bryan ...
Databricks
 
PDF
Activate 2019 - Search and relevance at scale for online classifieds
Roger Rafanell Mas
 
PDF
Text Analysis with SAP HANA
msg systems ag - Custom Development
 
PDF
Learning to Rank Datasets for Search with Oscar Castaneda
Databricks
 
PDF
Idea behind Apache Hivemall
Makoto Yui
 
PPTX
Optimising Queries - Series 1 Query Optimiser Architecture
DAGEOP LTD
 
PDF
Fifth Elephant Apache Atlas Talk
Vimal Sharma
 
PDF
19 09-26 source reconfiguration and august release features
Dede Sabey
 
PDF
Toronto OpenRefine MeetUp Nov 2015
Martin Magdinier
 
Apache Atlas: Tracking dataset lineage across Hadoop components
DataWorks Summit/Hadoop Summit
 
Agile Data Science on Greenplum Using Airflow - Greenplum Summit 2019
VMware Tanzu
 
Addressing Enterprise Customer Pain Points with a Data Driven Architecture
DataWorks Summit
 
Heimdall Data: "Increase Application Performance with SQL Auto-Caching; No Co...
Tom Diederich
 
MongoDB and Hadoop: Driving Business Insights
MongoDB
 
Experimentation Platform on Hadoop
DataWorks Summit
 
Atlas ApacheCon 2017
Vimal Sharma
 
Keynote – From MapReduce to Spark: An Ecosystem Evolves by Doug Cutting, Chie...
Cloudera, Inc.
 
Insights into Real World Data Management Challenges
DataWorks Summit
 
Efficient Log Management using Oozie, Parquet and Hive
Gopi Krishnan Nambiar
 
Model Parallelism in Spark ML Cross-Validation with Nick Pentreath and Bryan ...
Databricks
 
Activate 2019 - Search and relevance at scale for online classifieds
Roger Rafanell Mas
 
Text Analysis with SAP HANA
msg systems ag - Custom Development
 
Learning to Rank Datasets for Search with Oscar Castaneda
Databricks
 
Idea behind Apache Hivemall
Makoto Yui
 
Optimising Queries - Series 1 Query Optimiser Architecture
DAGEOP LTD
 
Fifth Elephant Apache Atlas Talk
Vimal Sharma
 
19 09-26 source reconfiguration and august release features
Dede Sabey
 
Toronto OpenRefine MeetUp Nov 2015
Martin Magdinier
 
Ad

Similar to Elegant database tuning (12)

PDF
16th Athens Big Data Meetup - 1st Talk - An Introduction to Machine Learning ...
Athens Big Data
 
PPTX
An introduction to Machine Learning with scikit-learn (October 2018)
Julien SIMON
 
PPTX
Performance insights twitch
Kyle Hailey
 
PDF
From Data To Insights
Orit Alul
 
PPTX
Petabytes of Data and No Servers: Corteva Scales DNA Analysis to Meet Increas...
Capgemini
 
PPTX
AWS re:Invent 2018 - ENT321 - SageMaker Workshop
Julien SIMON
 
PPTX
The Future of API Management Is Serverless
Chris Munns
 
PDF
Building Applications with Apache MXNet
Apache MXNet
 
PPTX
Quickly and easily build, train, and deploy machine learning models at any scale
AWS Germany
 
PDF
OSDC 2018 | Apache Ignite - the in-memory hammer for your data science toolki...
NETWAYS
 
PDF
Fri benghiat gil-odsc-data-kitchen-data science to dataops
DataKitchen
 
PDF
ODSC data science to DataOps
Christopher Bergh
 
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)
Julien SIMON
 
Performance insights twitch
Kyle Hailey
 
From Data To Insights
Orit Alul
 
Petabytes of Data and No Servers: Corteva Scales DNA Analysis to Meet Increas...
Capgemini
 
AWS re:Invent 2018 - ENT321 - SageMaker Workshop
Julien SIMON
 
The Future of API Management Is Serverless
Chris Munns
 
Building Applications with Apache MXNet
Apache MXNet
 
Quickly and easily build, train, and deploy machine learning models at any scale
AWS Germany
 
OSDC 2018 | Apache Ignite - the in-memory hammer for your data science toolki...
NETWAYS
 
Fri benghiat gil-odsc-data-kitchen-data science to dataops
DataKitchen
 
ODSC data science to DataOps
Christopher Bergh
 
Ad

Recently uploaded (20)

PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Doc9.....................................
SofiaCollazos
 
The Future of Artificial Intelligence (AI)
Mukul
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 

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 [email protected]