SlideShare a Scribd company logo
1 of 38
Download to read offline
CREATE STATISTICS
Peter Eisentraut
Webinar März 2021
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
2
Agenda
• Überblick Planer und Schätzungen
• Schätzungen mit korrelierten Spalten
• CREATE STATISTICS zur Rettung!
• funktionale Abhängigkeiten
• ndistinct
• MCV-Listen
• Ausblick
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
3
• PostgreSQL hat einen kostenbasierten Planer.
• Kosten = Kardinalitätsschätzung × Plankostenfaktor
• schlechte Schätzungen, schlechter Plan
Worum geht es?
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
4
-- http://download.geonames.org/export/zip/DE.zip
CREATE TABLE orte (
staat text,
plz char(5),
ort text,
land text,
regbez text,
kreis text,
...
);
copy orte from 'DE.txt'
Testdaten
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
5
EXPLAIN (ANALYZE, TIMING off)
SELECT * FROM orte WHERE ort = 'Berlin';
QUERY PLAN
-------------------------------------------------------------------------
Seq Scan on orte (cost=0.00..467.98 rows=182 width=85)
(actual rows=182 loops=1)
Filter: (ort = 'Berlin'::text)
Rows Removed by Filter: 16296
Planning Time: 0.680 ms
Execution Time: 2.744 ms
EXPLAIN
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
6
SELECT reltuples, relpages FROM pg_class WHERE relname = 'orte';
reltuples | relpages
-----------+----------
16478 | 262
reltuples, relpages
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
7
SELECT * FROM pg_stats WHERE tablename = 'orte' AND attname = 'ort';
------------------+-----------------------------------------------
schemaname | public
tablename | orte
attname | ort
...
most_common_vals | {Berlin,Hamburg,München,Köln,...}
most_common_freqs | {0.0110450,0.00612938,0.0044908,0.0027309,...}
...
pg_stats
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
8
EXPLAIN (ANALYZE, TIMING off) SELECT * FROM orte WHERE ort = 'Berlin';
QUERY PLAN
-------------------------------------------------------------------------
Seq Scan on orte (cost=0.00..467.98 rows=182 width=85)
(actual rows=182 loops=1)
reltuples | 16478
most_common_vals | {Berlin,...}
most_common_freqs | {0.0110450,...}
16478 * 0.0110450 = 181.99951
Berechnung der Zeilenschätzung
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
9
EXPLAIN (ANALYZE, TIMING off)
SELECT * FROM orte WHERE ort = 'Berlin' AND land = 'Berlin';
QUERY PLAN
-----------------------------------------------------------------------
Seq Scan on orte (cost=0.00..509.17 rows=2 width=85)
(actual rows=182 loops=1)
Filter: ((ort = 'Berlin'::text) AND (land = 'Berlin'::text))
Rows Removed by Filter: 16296
Planning Time: 0.127 ms
Execution Time: 2.190 ms
Unterschätzung
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
10
P(A ∩ B) = P(A) × P(B)
Wahrscheinlichkeit mehrerer Ereignisse
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
11
SELECT * FROM orte WHERE ort = 'Berlin' AND land = 'Berlin';
P(ort = 'Berlin' & land = 'Berlin')
= P(ort = 'Berlin') * P(land = 'Berlin')
= 0.01105 * 0.01177
= 0.00013
16478 * 0.00013 = 2.14214
Berechnung der Zeilenschätzung
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
12
EXPLAIN (ANALYZE, TIMING off)
SELECT * FROM orte WHERE ort = 'Berlin' AND land <> 'Berlin';
QUERY PLAN
-----------------------------------------------------------------------
Seq Scan on orte (cost=0.00..509.17 rows=180 width=85)
(actual rows=0 loops=1)
Filter: ((land <> 'Berlin'::text) AND (ort = 'Berlin'::text))
Rows Removed by Filter: 16478
Planning Time: 0.060 ms
Execution Time: 2.163 ms
Überschätzung
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
13
• Es wird angenommen, dass Spaltenwerte unabhängig voneinander sind.
• falsche Schätzungen
• Unter- und Überschätzungen
• Konsequenzen:
• schlechte Scan-Wahl (Seq Scan vs. Index Scan)
• schlechte Join-Wahl (Nested Loop)
Korrelierte Spalten
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
14
Index Scan using orders_city_idx on orders
(cost=0.28..185.10 rows=90 width=36)
(actual rows=12248237 loops=1)
Seq Scan using orders
(cost=0.13..129385.10 rows=12248237 width=36)
(actual rows=90 loops=1)
Schlechte Scan-Wahl
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
15
-> Nested Loop (... rows=90 ...) (... rows=12248237 ...)
-> Nested Loop (... rows=90 ...) (... rows=12248237 ...)
-> Index Scan using orders_city_idx on orders
(cost=0.28..185.10 rows=90 width=36)
(actual rows=12248237 loops=1)
...
-> Index Scan ... (... loops=12248237)
-> Index Scan ... (... loops=12248237)
-> Index Scan ... (... loops=12248237)
Schlechte Join-Wahl
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
16
Funktionale Abhängigkeiten (WHERE)
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
17
• Wert in Spalte A bestimmt Wert in Spalte B
• Beispiel: Primärschlüssel bestimmt alles
• plz -> {ort, kreis, land}
• 89346 -> {Bibertal, Landkreis Günzburg, Bayern}
• andere Abhängigkeiten:
• Ort -> Kreis
• Kreis -> Land
• Land -> Staat
Funktionale Abhängigkeiten
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
18
CREATE STATISTICS s1 (dependencies)
ON ort, kreis, land FROM orte;
-- 3 8 4
ANALYZE orte;
SELECT dependencies FROM pg_stats_ext WHERE statistics_name = 's1';
dependencies
--------------------------------------------------------------
{"3 => 4": 0.918073, "3 => 8": 0.895254, "4 => 3": 0.000061,
"4 => 8": 0.035866, "8 => 3": 0.053647, "8 => 4": 1.000000,
"3, 4 => 8": 0.965105, "3, 8 => 4": 1.000000,
"4, 8 => 3": 0.053647}
CREATE STATISTICS
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
19
ort -> land: d = 0.918073
P(ort = 'Berlin' & land = 'Berlin')
= P(ort = 'Berlin') * [d + (1-d) * P(land = 'Berlin')]
= 0.01105 * [0.918073 + (1-0.918073) * 0.01177]
= 0.01016
16478 * 0.01016 = 167.4
Berechnung der Zeilenschätzung
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
20
EXPLAIN (ANALYZE, TIMING off)
SELECT * FROM orte WHERE ort = 'Berlin' AND land = 'Berlin';
QUERY PLAN
-------------------------------------------------------------------------
Seq Scan on orte (cost=0.00..509.17 rows=167 width=85)
(actual rows=182 loops=1)
Filter: ((ort = 'Berlin'::text) AND (land = 'Berlin'::text))
Rows Removed by Filter: 16296
Planning Time: 0.362 ms
Execution Time: 2.167 ms
Unterschätzung: berichtigt
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
21
EXPLAIN (ANALYZE, TIMING off)
SELECT * FROM orte WHERE ort = 'Berlin' AND land <> 'Berlin';
QUERY PLAN
-----------------------------------------------------------------------
Seq Scan on orte (cost=0.00..509.17 rows=180 width=85)
(actual rows=0 loops=1)
Filter: ((land <> 'Berlin'::text) AND (ort = 'Berlin'::text))
Rows Removed by Filter: 16478
Planning Time: 0.077 ms
Execution Time: 2.356 ms
Funktionale Abhängigkeiten funktionieren nur mit "=".
Überschätzung Nr. 1: nicht berichtigt :-(
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
22
EXPLAIN (ANALYZE, TIMING off)
SELECT * FROM orte WHERE ort = 'Berlin' AND land = 'Bayern';
QUERY PLAN
-----------------------------------------------------------------------
Seq Scan on orte (cost=0.00..509.17 rows=169 width=85)
(actual rows=0 loops=1)
Filter: ((ort = 'Berlin'::text) AND (land = 'Bayern'::text))
Rows Removed by Filter: 16478
Planning Time: 0.082 ms
Execution Time: 2.204 ms
Die Anfrage muss die funktionalen Abhängigkeiten "respektieren".
Überschätzung Nr. 2: nicht berichtigt :-(
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
23
ndistinct (GROUP BY)
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
24
EXPLAIN (ANALYZE, TIMING off)
SELECT count(*) FROM places GROUP BY community;
QUERY PLAN
-------------------------------------------------------------------------
HashAggregate (cost=56576.56..56580.14 rows=358 width=27)
(actual rows=359 loops=1)
Group Key: community
-> Seq Scan on places (cost=0.00..47731.71 rows=1768971 width=19)
(actual rows=1768982 loops=1)
Planning Time: 0.043 ms
Execution Time: 361.663 ms
EXPLAIN
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
25
SELECT attname, n_distinct FROM pg_stats WHERE tablename = 'places';
attname | n_distinct
-------------+-------------
community | 358
country | 1
county | 92
place | 6544
postcode | -1
state | 5
... |
pg_stats
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
26
EXPLAIN (ANALYZE, TIMING off)
SELECT count(*) FROM places GROUP BY state, county, community;
QUERY PLAN
-----------------------------------------------------------------------
HashAggregate (cost=211361.53..240648.50 rows=164680 width=46)
(actual rows=420 loops=1)
Group Key: state, county, community
-> Seq Scan on places (cost=0.00..47731.71 rows=1768971 width=38)
(actual rows=1768982 loops=1)
Planning Time: 0.079 ms
Execution Time: 484.140 ms
Falsche Schätzung
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
27
ndistinct(state, county, community)
=
ndistinct(state) × ndistinct(county) × ndistinct(community)
5 × 92 × 358 = 164680
Zeilenschätzung
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
28
CREATE STATISTICS s2 (ndistinct)
ON state, county, community
-- 4 6 8
FROM places;
ANALYZE places;
SELECT n_distinct FROM pg_stats_ext WHERE statistics_name = 's2';
n_distinct
--------------------------------------------------------
{"4, 6": 93, "4, 8": 362, "6, 8": 384, "4, 6, 8": 385}
CREATE STATISTICS
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
29
EXPLAIN (ANALYZE, TIMING off)
SELECT count(*) FROM places GROUP BY state, county, community;
QUERY PLAN
-----------------------------------------------------------------------
HashAggregate (cost=65422.20..65426.05 rows=385 width=47)
(actual rows=420 loops=1)
Group Key: state, county, community
-> Seq Scan on places (cost=0.00..47732.10 rows=1769010 width=39)
(actual rows=1768982 loops=1)
Planning Time: 0.214 ms
Execution Time: 482.752 ms
Schätzung berichtigt
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
30
• Das alte Verhalten war defensiv.
• unzuverlässige Schätzungen mit mehreren Spalten
• HashAggregate kann nicht auf Festplatte auslagern (bis PG12) (OOM)
• statt Crash lieber Sort+GroupAggregate (langsam)
• ndistinct-Koeffizienten
• machen Schätzungen verlässlicher
• weniger Gefahr von OOM
• für große Tabellen + GROUP BY mehrere Spalten
ndistinct
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
31
MCV-Listen
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
32
EXPLAIN (ANALYZE, TIMING off)
SELECT * FROM orte WHERE kreis = 'Landkreis Günzburg' AND land = 'Bayern';
QUERY PLAN
----------------------------------------------------------------------
Seq Scan on orte (cost=0.00..509.17 rows=5 width=85)
(actual rows=34 loops=1)
Filter: ((kreis = 'Landkreis Günzburg'::text) AND (land =
'Bayern'::text))
Rows Removed by Filter: 16444
Planning Time: 0.117 ms
Execution Time: 2.692 ms
Unterschätzung
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
33
CREATE STATISTICS s3 (mcv) ON kreis, land FROM orte;
SET default_statistics_target = 10000;
ANALYZE orte;
SELECT most_common_vals, most_common_freqs FROM pg_stats_ext WHERE
statistics_name = 's3';
most_common_vals | {{Hamburg,"Hamburg, Freie und Hansestadt"},
{Rheinland-Pfalz,"Eifelkreis Bitburg-Prüm"},...
most_common_freqs | {0.02403204272363151,0.014200752518509527,...
CREATE STATISTICS
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
34
EXPLAIN (ANALYZE, TIMING off)
SELECT * FROM orte WHERE kreis = 'Landkreis Günzburg' AND land = 'Bayern';
QUERY PLAN
-----------------------------------------------------------------------
Seq Scan on orte (cost=0.00..509.17 rows=34 width=85)
(actual rows=34 loops=1)
Filter: ((kreis = 'Landkreis Günzburg'::text) AND (land =
'Bayern'::text))
Rows Removed by Filter: 16444
Planning Time: 0.518 ms
Execution Time: 2.286 ms
Unterschätzung berichtigt
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
35
EXPLAIN (ANALYZE, TIMING off)
SELECT * FROM places WHERE place <> 'London' AND county = 'Greater
London';
QUERY PLAN
-----------------------------------------------------------------------
Seq Scan on places (cost=0.00..56577.15 rows=157198 width=97)
(actual rows=1782 loops=1)
Filter: ((place <> 'London'::text) AND (county = 'Greater
London'::text))
Rows Removed by Filter: 1767200
Planning Time: 0.284 ms
Execution Time: 201.311 ms
Überschätzung Nr. 1
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
36
EXPLAIN (ANALYZE, TIMING off)
SELECT * FROM places WHERE place <> 'London' AND county = 'Greater
London';
QUERY PLAN
-----------------------------------------------------------------------
Seq Scan on places (cost=0.00..56576.73 rows=39789 width=96)
(actual rows=1782 loops=1)
Filter: ((place <> 'London'::text) AND (county = 'Greater
London'::text))
Rows Removed by Filter: 1767200
Planning Time: 3.533 ms
Execution Time: 228.332 ms
Überschätzung Nr. 1 mit MCV
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
37
• mehr Arten von Statistiken
• Histogramme?
• Statistiken für Ausdrücke
• Verwendung für Joins
• Verwendung von MCV-Listen
• Statistiken über mehrere Tabellen
Ausblick
© Copyright EnterpriseDB Corporation, 2020. All rights reserved.
38
Zusammenfassung
• CREATE STATISTICS
• als Ergänzung zu CREATE INDEX
• dependencies, ndistinct, mcv
• Verbesserungen in jeder Release

More Related Content

What's hot

15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performanceguest9912e5
 
Drill / SQL / Optiq
Drill / SQL / OptiqDrill / SQL / Optiq
Drill / SQL / OptiqJulian Hyde
 
Tactical data engineering
Tactical data engineeringTactical data engineering
Tactical data engineeringJulian Hyde
 
N1QL New Features in couchbase 7.0
N1QL New Features in couchbase 7.0N1QL New Features in couchbase 7.0
N1QL New Features in couchbase 7.0Keshav Murthy
 
Don't optimize my queries, organize my data!
Don't optimize my queries, organize my data!Don't optimize my queries, organize my data!
Don't optimize my queries, organize my data!Julian Hyde
 
Apache Calcite: A Foundational Framework for Optimized Query Processing Over ...
Apache Calcite: A Foundational Framework for Optimized Query Processing Over ...Apache Calcite: A Foundational Framework for Optimized Query Processing Over ...
Apache Calcite: A Foundational Framework for Optimized Query Processing Over ...Julian Hyde
 
Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Couchbase Tutorial: Big data Open Source Systems: VLDB2018Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Couchbase Tutorial: Big data Open Source Systems: VLDB2018Keshav Murthy
 
Couchbase N1QL: Language & Architecture Overview.
Couchbase N1QL: Language & Architecture Overview.Couchbase N1QL: Language & Architecture Overview.
Couchbase N1QL: Language & Architecture Overview.Keshav Murthy
 
R + 15 minutes = Hadoop cluster
R + 15 minutes = Hadoop clusterR + 15 minutes = Hadoop cluster
R + 15 minutes = Hadoop clusterJeffrey Breen
 
Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Scott Leberknight
 
Overview of running R in the Oracle Database
Overview of running R in the Oracle DatabaseOverview of running R in the Oracle Database
Overview of running R in the Oracle DatabaseBrendan Tierney
 
Updates from Cassandra Summit 2016 & SASI Indexes
Updates from Cassandra Summit 2016 & SASI IndexesUpdates from Cassandra Summit 2016 & SASI Indexes
Updates from Cassandra Summit 2016 & SASI IndexesJim Hatcher
 
PostgreSQL 9.4 JSON Types and Operators
PostgreSQL 9.4 JSON Types and OperatorsPostgreSQL 9.4 JSON Types and Operators
PostgreSQL 9.4 JSON Types and OperatorsNicholas Kiraly
 
Using Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into CassandraUsing Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into CassandraJim Hatcher
 
Next Top Data Model by Ian Plosker
Next Top Data Model by Ian PloskerNext Top Data Model by Ian Plosker
Next Top Data Model by Ian PloskerSyncConf
 
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEOClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEOAltinity Ltd
 
OrientDB vs Neo4j - Comparison of query/speed/functionality
OrientDB vs Neo4j - Comparison of query/speed/functionalityOrientDB vs Neo4j - Comparison of query/speed/functionality
OrientDB vs Neo4j - Comparison of query/speed/functionalityCurtis Mosters
 
Hadoop World 2011: Building Web Analytics Processing on Hadoop at CBS Interac...
Hadoop World 2011: Building Web Analytics Processing on Hadoop at CBS Interac...Hadoop World 2011: Building Web Analytics Processing on Hadoop at CBS Interac...
Hadoop World 2011: Building Web Analytics Processing on Hadoop at CBS Interac...Cloudera, Inc.
 

What's hot (20)

15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance
 
Drill / SQL / Optiq
Drill / SQL / OptiqDrill / SQL / Optiq
Drill / SQL / Optiq
 
Tactical data engineering
Tactical data engineeringTactical data engineering
Tactical data engineering
 
N1QL New Features in couchbase 7.0
N1QL New Features in couchbase 7.0N1QL New Features in couchbase 7.0
N1QL New Features in couchbase 7.0
 
Don't optimize my queries, organize my data!
Don't optimize my queries, organize my data!Don't optimize my queries, organize my data!
Don't optimize my queries, organize my data!
 
Apache Calcite: A Foundational Framework for Optimized Query Processing Over ...
Apache Calcite: A Foundational Framework for Optimized Query Processing Over ...Apache Calcite: A Foundational Framework for Optimized Query Processing Over ...
Apache Calcite: A Foundational Framework for Optimized Query Processing Over ...
 
Polyglot Persistence
Polyglot PersistencePolyglot Persistence
Polyglot Persistence
 
Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Couchbase Tutorial: Big data Open Source Systems: VLDB2018Couchbase Tutorial: Big data Open Source Systems: VLDB2018
Couchbase Tutorial: Big data Open Source Systems: VLDB2018
 
Couchbase N1QL: Language & Architecture Overview.
Couchbase N1QL: Language & Architecture Overview.Couchbase N1QL: Language & Architecture Overview.
Couchbase N1QL: Language & Architecture Overview.
 
R + 15 minutes = Hadoop cluster
R + 15 minutes = Hadoop clusterR + 15 minutes = Hadoop cluster
R + 15 minutes = Hadoop cluster
 
Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0
 
Overview of running R in the Oracle Database
Overview of running R in the Oracle DatabaseOverview of running R in the Oracle Database
Overview of running R in the Oracle Database
 
Streaming SQL
Streaming SQLStreaming SQL
Streaming SQL
 
Updates from Cassandra Summit 2016 & SASI Indexes
Updates from Cassandra Summit 2016 & SASI IndexesUpdates from Cassandra Summit 2016 & SASI Indexes
Updates from Cassandra Summit 2016 & SASI Indexes
 
PostgreSQL 9.4 JSON Types and Operators
PostgreSQL 9.4 JSON Types and OperatorsPostgreSQL 9.4 JSON Types and Operators
PostgreSQL 9.4 JSON Types and Operators
 
Using Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into CassandraUsing Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into Cassandra
 
Next Top Data Model by Ian Plosker
Next Top Data Model by Ian PloskerNext Top Data Model by Ian Plosker
Next Top Data Model by Ian Plosker
 
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEOClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
 
OrientDB vs Neo4j - Comparison of query/speed/functionality
OrientDB vs Neo4j - Comparison of query/speed/functionalityOrientDB vs Neo4j - Comparison of query/speed/functionality
OrientDB vs Neo4j - Comparison of query/speed/functionality
 
Hadoop World 2011: Building Web Analytics Processing on Hadoop at CBS Interac...
Hadoop World 2011: Building Web Analytics Processing on Hadoop at CBS Interac...Hadoop World 2011: Building Web Analytics Processing on Hadoop at CBS Interac...
Hadoop World 2011: Building Web Analytics Processing on Hadoop at CBS Interac...
 

Similar to All you need to know about CREATE STATISTICS

Understand the Query Plan to Optimize Performance with EXPLAIN and EXPLAIN AN...
Understand the Query Plan to Optimize Performance with EXPLAIN and EXPLAIN AN...Understand the Query Plan to Optimize Performance with EXPLAIN and EXPLAIN AN...
Understand the Query Plan to Optimize Performance with EXPLAIN and EXPLAIN AN...EDB
 
New Tuning Features in Oracle 11g - How to make your database as boring as po...
New Tuning Features in Oracle 11g - How to make your database as boring as po...New Tuning Features in Oracle 11g - How to make your database as boring as po...
New Tuning Features in Oracle 11g - How to make your database as boring as po...Sage Computing Services
 
Care and Feeding of Catalyst Optimizer
Care and Feeding of Catalyst OptimizerCare and Feeding of Catalyst Optimizer
Care and Feeding of Catalyst OptimizerDatabricks
 
Введение в современную PostgreSQL. Часть 2
Введение в современную PostgreSQL. Часть 2Введение в современную PostgreSQL. Часть 2
Введение в современную PostgreSQL. Часть 2Dzianis Pirshtuk
 
Postgres Performance for Humans
Postgres Performance for HumansPostgres Performance for Humans
Postgres Performance for HumansCitus Data
 
Dublin Ireland Spark Meetup October 15, 2015
Dublin Ireland Spark Meetup October 15, 2015Dublin Ireland Spark Meetup October 15, 2015
Dublin Ireland Spark Meetup October 15, 2015eddiebaggott
 
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스PgDay.Seoul
 
Informix Warehouse Accelerator (IWA) features in version 12.1
Informix Warehouse Accelerator (IWA) features in version 12.1Informix Warehouse Accelerator (IWA) features in version 12.1
Informix Warehouse Accelerator (IWA) features in version 12.1Keshav Murthy
 
Non-Relational Postgres
Non-Relational PostgresNon-Relational Postgres
Non-Relational PostgresEDB
 
Indexes From the Concept to Internals
Indexes From the Concept to InternalsIndexes From the Concept to Internals
Indexes From the Concept to InternalsDeiby Gómez
 
Oracle 122 partitioning_in_action_slide_share
Oracle 122 partitioning_in_action_slide_shareOracle 122 partitioning_in_action_slide_share
Oracle 122 partitioning_in_action_slide_shareThomas Teske
 
Deep dive to PostgreSQL Indexes
Deep dive to PostgreSQL IndexesDeep dive to PostgreSQL Indexes
Deep dive to PostgreSQL IndexesIbrar Ahmed
 
Top 10 tips for Oracle performance
Top 10 tips for Oracle performanceTop 10 tips for Oracle performance
Top 10 tips for Oracle performanceGuy Harrison
 
Développer avec un Simple Object Mapping Toolkit pour SQL Server
Développer avec un Simple Object Mapping Toolkit pour SQL ServerDévelopper avec un Simple Object Mapping Toolkit pour SQL Server
Développer avec un Simple Object Mapping Toolkit pour SQL ServerDenis Voituron
 
Basic Query Tuning Primer - Pg West 2009
Basic Query Tuning Primer - Pg West 2009Basic Query Tuning Primer - Pg West 2009
Basic Query Tuning Primer - Pg West 2009mattsmiley
 
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介Masayuki Matsushita
 

Similar to All you need to know about CREATE STATISTICS (20)

Understand the Query Plan to Optimize Performance with EXPLAIN and EXPLAIN AN...
Understand the Query Plan to Optimize Performance with EXPLAIN and EXPLAIN AN...Understand the Query Plan to Optimize Performance with EXPLAIN and EXPLAIN AN...
Understand the Query Plan to Optimize Performance with EXPLAIN and EXPLAIN AN...
 
New Tuning Features in Oracle 11g - How to make your database as boring as po...
New Tuning Features in Oracle 11g - How to make your database as boring as po...New Tuning Features in Oracle 11g - How to make your database as boring as po...
New Tuning Features in Oracle 11g - How to make your database as boring as po...
 
Care and Feeding of Catalyst Optimizer
Care and Feeding of Catalyst OptimizerCare and Feeding of Catalyst Optimizer
Care and Feeding of Catalyst Optimizer
 
Введение в современную PostgreSQL. Часть 2
Введение в современную PostgreSQL. Часть 2Введение в современную PostgreSQL. Часть 2
Введение в современную PostgreSQL. Часть 2
 
Postgres Performance for Humans
Postgres Performance for HumansPostgres Performance for Humans
Postgres Performance for Humans
 
5 Cool Things About SQL
5 Cool Things About SQL5 Cool Things About SQL
5 Cool Things About SQL
 
Dublin Ireland Spark Meetup October 15, 2015
Dublin Ireland Spark Meetup October 15, 2015Dublin Ireland Spark Meetup October 15, 2015
Dublin Ireland Spark Meetup October 15, 2015
 
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
 
Informix Warehouse Accelerator (IWA) features in version 12.1
Informix Warehouse Accelerator (IWA) features in version 12.1Informix Warehouse Accelerator (IWA) features in version 12.1
Informix Warehouse Accelerator (IWA) features in version 12.1
 
Non-Relational Postgres
Non-Relational PostgresNon-Relational Postgres
Non-Relational Postgres
 
The Cost Based Optimiser in 11gR2
The Cost Based Optimiser in 11gR2The Cost Based Optimiser in 11gR2
The Cost Based Optimiser in 11gR2
 
Indexes From the Concept to Internals
Indexes From the Concept to InternalsIndexes From the Concept to Internals
Indexes From the Concept to Internals
 
Oracle 122 partitioning_in_action_slide_share
Oracle 122 partitioning_in_action_slide_shareOracle 122 partitioning_in_action_slide_share
Oracle 122 partitioning_in_action_slide_share
 
Deep dive to PostgreSQL Indexes
Deep dive to PostgreSQL IndexesDeep dive to PostgreSQL Indexes
Deep dive to PostgreSQL Indexes
 
Top 10 tips for Oracle performance
Top 10 tips for Oracle performanceTop 10 tips for Oracle performance
Top 10 tips for Oracle performance
 
C++ Programs
C++ ProgramsC++ Programs
C++ Programs
 
Développer avec un Simple Object Mapping Toolkit pour SQL Server
Développer avec un Simple Object Mapping Toolkit pour SQL ServerDévelopper avec un Simple Object Mapping Toolkit pour SQL Server
Développer avec un Simple Object Mapping Toolkit pour SQL Server
 
Basic Query Tuning Primer
Basic Query Tuning PrimerBasic Query Tuning Primer
Basic Query Tuning Primer
 
Basic Query Tuning Primer - Pg West 2009
Basic Query Tuning Primer - Pg West 2009Basic Query Tuning Primer - Pg West 2009
Basic Query Tuning Primer - Pg West 2009
 
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
クラウドDWHとしても進化を続けるPivotal Greenplumご紹介
 

More from EDB

Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaSCloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaSEDB
 
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr UnternehmenDie 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr UnternehmenEDB
 
Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube EDB
 
EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021EDB
 
Benchmarking Cloud Native PostgreSQL
Benchmarking Cloud Native PostgreSQLBenchmarking Cloud Native PostgreSQL
Benchmarking Cloud Native PostgreSQLEDB
 
Las Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQLLas Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQLEDB
 
NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLEDB
 
Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?EDB
 
Data Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQLData Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQLEDB
 
Practical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresPractical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresEDB
 
A Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINA Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINEDB
 
IOT with PostgreSQL
IOT with PostgreSQLIOT with PostgreSQL
IOT with PostgreSQLEDB
 
A Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQLA Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQLEDB
 
Psql is awesome!
Psql is awesome!Psql is awesome!
Psql is awesome!EDB
 
EDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJEDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJEDB
 
Comment sauvegarder correctement vos données
Comment sauvegarder correctement vos donnéesComment sauvegarder correctement vos données
Comment sauvegarder correctement vos donnéesEDB
 
Cloud Native PostgreSQL - Italiano
Cloud Native PostgreSQL - ItalianoCloud Native PostgreSQL - Italiano
Cloud Native PostgreSQL - ItalianoEDB
 
New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13EDB
 
Best Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLBest Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLEDB
 
Cloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJCloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJEDB
 

More from EDB (20)

Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaSCloud Migration Paths: Kubernetes, IaaS, or DBaaS
Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
 
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr UnternehmenDie 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
 
Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube Migre sus bases de datos Oracle a la nube
Migre sus bases de datos Oracle a la nube
 
EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021EFM Office Hours - APJ - July 29, 2021
EFM Office Hours - APJ - July 29, 2021
 
Benchmarking Cloud Native PostgreSQL
Benchmarking Cloud Native PostgreSQLBenchmarking Cloud Native PostgreSQL
Benchmarking Cloud Native PostgreSQL
 
Las Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQLLas Variaciones de la Replicación de PostgreSQL
Las Variaciones de la Replicación de PostgreSQL
 
NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQL
 
Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?Is There Anything PgBouncer Can’t Do?
Is There Anything PgBouncer Can’t Do?
 
Data Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQLData Analysis with TensorFlow in PostgreSQL
Data Analysis with TensorFlow in PostgreSQL
 
Practical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresPractical Partitioning in Production with Postgres
Practical Partitioning in Production with Postgres
 
A Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAINA Deeper Dive into EXPLAIN
A Deeper Dive into EXPLAIN
 
IOT with PostgreSQL
IOT with PostgreSQLIOT with PostgreSQL
IOT with PostgreSQL
 
A Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQLA Journey from Oracle to PostgreSQL
A Journey from Oracle to PostgreSQL
 
Psql is awesome!
Psql is awesome!Psql is awesome!
Psql is awesome!
 
EDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJEDB 13 - New Enhancements for Security and Usability - APJ
EDB 13 - New Enhancements for Security and Usability - APJ
 
Comment sauvegarder correctement vos données
Comment sauvegarder correctement vos donnéesComment sauvegarder correctement vos données
Comment sauvegarder correctement vos données
 
Cloud Native PostgreSQL - Italiano
Cloud Native PostgreSQL - ItalianoCloud Native PostgreSQL - Italiano
Cloud Native PostgreSQL - Italiano
 
New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13New enhancements for security and usability in EDB 13
New enhancements for security and usability in EDB 13
 
Best Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQLBest Practices in Security with PostgreSQL
Best Practices in Security with PostgreSQL
 
Cloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJCloud Native PostgreSQL - APJ
Cloud Native PostgreSQL - APJ
 

Recently uploaded

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

All you need to know about CREATE STATISTICS

  • 2. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 2 Agenda • Überblick Planer und Schätzungen • Schätzungen mit korrelierten Spalten • CREATE STATISTICS zur Rettung! • funktionale Abhängigkeiten • ndistinct • MCV-Listen • Ausblick
  • 3. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 3 • PostgreSQL hat einen kostenbasierten Planer. • Kosten = Kardinalitätsschätzung × Plankostenfaktor • schlechte Schätzungen, schlechter Plan Worum geht es?
  • 4. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 4 -- http://download.geonames.org/export/zip/DE.zip CREATE TABLE orte ( staat text, plz char(5), ort text, land text, regbez text, kreis text, ... ); copy orte from 'DE.txt' Testdaten
  • 5. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 5 EXPLAIN (ANALYZE, TIMING off) SELECT * FROM orte WHERE ort = 'Berlin'; QUERY PLAN ------------------------------------------------------------------------- Seq Scan on orte (cost=0.00..467.98 rows=182 width=85) (actual rows=182 loops=1) Filter: (ort = 'Berlin'::text) Rows Removed by Filter: 16296 Planning Time: 0.680 ms Execution Time: 2.744 ms EXPLAIN
  • 6. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 6 SELECT reltuples, relpages FROM pg_class WHERE relname = 'orte'; reltuples | relpages -----------+---------- 16478 | 262 reltuples, relpages
  • 7. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 7 SELECT * FROM pg_stats WHERE tablename = 'orte' AND attname = 'ort'; ------------------+----------------------------------------------- schemaname | public tablename | orte attname | ort ... most_common_vals | {Berlin,Hamburg,München,Köln,...} most_common_freqs | {0.0110450,0.00612938,0.0044908,0.0027309,...} ... pg_stats
  • 8. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 8 EXPLAIN (ANALYZE, TIMING off) SELECT * FROM orte WHERE ort = 'Berlin'; QUERY PLAN ------------------------------------------------------------------------- Seq Scan on orte (cost=0.00..467.98 rows=182 width=85) (actual rows=182 loops=1) reltuples | 16478 most_common_vals | {Berlin,...} most_common_freqs | {0.0110450,...} 16478 * 0.0110450 = 181.99951 Berechnung der Zeilenschätzung
  • 9. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 9 EXPLAIN (ANALYZE, TIMING off) SELECT * FROM orte WHERE ort = 'Berlin' AND land = 'Berlin'; QUERY PLAN ----------------------------------------------------------------------- Seq Scan on orte (cost=0.00..509.17 rows=2 width=85) (actual rows=182 loops=1) Filter: ((ort = 'Berlin'::text) AND (land = 'Berlin'::text)) Rows Removed by Filter: 16296 Planning Time: 0.127 ms Execution Time: 2.190 ms Unterschätzung
  • 10. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 10 P(A ∩ B) = P(A) × P(B) Wahrscheinlichkeit mehrerer Ereignisse
  • 11. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 11 SELECT * FROM orte WHERE ort = 'Berlin' AND land = 'Berlin'; P(ort = 'Berlin' & land = 'Berlin') = P(ort = 'Berlin') * P(land = 'Berlin') = 0.01105 * 0.01177 = 0.00013 16478 * 0.00013 = 2.14214 Berechnung der Zeilenschätzung
  • 12. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 12 EXPLAIN (ANALYZE, TIMING off) SELECT * FROM orte WHERE ort = 'Berlin' AND land <> 'Berlin'; QUERY PLAN ----------------------------------------------------------------------- Seq Scan on orte (cost=0.00..509.17 rows=180 width=85) (actual rows=0 loops=1) Filter: ((land <> 'Berlin'::text) AND (ort = 'Berlin'::text)) Rows Removed by Filter: 16478 Planning Time: 0.060 ms Execution Time: 2.163 ms Überschätzung
  • 13. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 13 • Es wird angenommen, dass Spaltenwerte unabhängig voneinander sind. • falsche Schätzungen • Unter- und Überschätzungen • Konsequenzen: • schlechte Scan-Wahl (Seq Scan vs. Index Scan) • schlechte Join-Wahl (Nested Loop) Korrelierte Spalten
  • 14. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 14 Index Scan using orders_city_idx on orders (cost=0.28..185.10 rows=90 width=36) (actual rows=12248237 loops=1) Seq Scan using orders (cost=0.13..129385.10 rows=12248237 width=36) (actual rows=90 loops=1) Schlechte Scan-Wahl
  • 15. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 15 -> Nested Loop (... rows=90 ...) (... rows=12248237 ...) -> Nested Loop (... rows=90 ...) (... rows=12248237 ...) -> Index Scan using orders_city_idx on orders (cost=0.28..185.10 rows=90 width=36) (actual rows=12248237 loops=1) ... -> Index Scan ... (... loops=12248237) -> Index Scan ... (... loops=12248237) -> Index Scan ... (... loops=12248237) Schlechte Join-Wahl
  • 16. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 16 Funktionale Abhängigkeiten (WHERE)
  • 17. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 17 • Wert in Spalte A bestimmt Wert in Spalte B • Beispiel: Primärschlüssel bestimmt alles • plz -> {ort, kreis, land} • 89346 -> {Bibertal, Landkreis Günzburg, Bayern} • andere Abhängigkeiten: • Ort -> Kreis • Kreis -> Land • Land -> Staat Funktionale Abhängigkeiten
  • 18. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 18 CREATE STATISTICS s1 (dependencies) ON ort, kreis, land FROM orte; -- 3 8 4 ANALYZE orte; SELECT dependencies FROM pg_stats_ext WHERE statistics_name = 's1'; dependencies -------------------------------------------------------------- {"3 => 4": 0.918073, "3 => 8": 0.895254, "4 => 3": 0.000061, "4 => 8": 0.035866, "8 => 3": 0.053647, "8 => 4": 1.000000, "3, 4 => 8": 0.965105, "3, 8 => 4": 1.000000, "4, 8 => 3": 0.053647} CREATE STATISTICS
  • 19. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 19 ort -> land: d = 0.918073 P(ort = 'Berlin' & land = 'Berlin') = P(ort = 'Berlin') * [d + (1-d) * P(land = 'Berlin')] = 0.01105 * [0.918073 + (1-0.918073) * 0.01177] = 0.01016 16478 * 0.01016 = 167.4 Berechnung der Zeilenschätzung
  • 20. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 20 EXPLAIN (ANALYZE, TIMING off) SELECT * FROM orte WHERE ort = 'Berlin' AND land = 'Berlin'; QUERY PLAN ------------------------------------------------------------------------- Seq Scan on orte (cost=0.00..509.17 rows=167 width=85) (actual rows=182 loops=1) Filter: ((ort = 'Berlin'::text) AND (land = 'Berlin'::text)) Rows Removed by Filter: 16296 Planning Time: 0.362 ms Execution Time: 2.167 ms Unterschätzung: berichtigt
  • 21. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 21 EXPLAIN (ANALYZE, TIMING off) SELECT * FROM orte WHERE ort = 'Berlin' AND land <> 'Berlin'; QUERY PLAN ----------------------------------------------------------------------- Seq Scan on orte (cost=0.00..509.17 rows=180 width=85) (actual rows=0 loops=1) Filter: ((land <> 'Berlin'::text) AND (ort = 'Berlin'::text)) Rows Removed by Filter: 16478 Planning Time: 0.077 ms Execution Time: 2.356 ms Funktionale Abhängigkeiten funktionieren nur mit "=". Überschätzung Nr. 1: nicht berichtigt :-(
  • 22. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 22 EXPLAIN (ANALYZE, TIMING off) SELECT * FROM orte WHERE ort = 'Berlin' AND land = 'Bayern'; QUERY PLAN ----------------------------------------------------------------------- Seq Scan on orte (cost=0.00..509.17 rows=169 width=85) (actual rows=0 loops=1) Filter: ((ort = 'Berlin'::text) AND (land = 'Bayern'::text)) Rows Removed by Filter: 16478 Planning Time: 0.082 ms Execution Time: 2.204 ms Die Anfrage muss die funktionalen Abhängigkeiten "respektieren". Überschätzung Nr. 2: nicht berichtigt :-(
  • 23. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 23 ndistinct (GROUP BY)
  • 24. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 24 EXPLAIN (ANALYZE, TIMING off) SELECT count(*) FROM places GROUP BY community; QUERY PLAN ------------------------------------------------------------------------- HashAggregate (cost=56576.56..56580.14 rows=358 width=27) (actual rows=359 loops=1) Group Key: community -> Seq Scan on places (cost=0.00..47731.71 rows=1768971 width=19) (actual rows=1768982 loops=1) Planning Time: 0.043 ms Execution Time: 361.663 ms EXPLAIN
  • 25. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 25 SELECT attname, n_distinct FROM pg_stats WHERE tablename = 'places'; attname | n_distinct -------------+------------- community | 358 country | 1 county | 92 place | 6544 postcode | -1 state | 5 ... | pg_stats
  • 26. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 26 EXPLAIN (ANALYZE, TIMING off) SELECT count(*) FROM places GROUP BY state, county, community; QUERY PLAN ----------------------------------------------------------------------- HashAggregate (cost=211361.53..240648.50 rows=164680 width=46) (actual rows=420 loops=1) Group Key: state, county, community -> Seq Scan on places (cost=0.00..47731.71 rows=1768971 width=38) (actual rows=1768982 loops=1) Planning Time: 0.079 ms Execution Time: 484.140 ms Falsche Schätzung
  • 27. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 27 ndistinct(state, county, community) = ndistinct(state) × ndistinct(county) × ndistinct(community) 5 × 92 × 358 = 164680 Zeilenschätzung
  • 28. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 28 CREATE STATISTICS s2 (ndistinct) ON state, county, community -- 4 6 8 FROM places; ANALYZE places; SELECT n_distinct FROM pg_stats_ext WHERE statistics_name = 's2'; n_distinct -------------------------------------------------------- {"4, 6": 93, "4, 8": 362, "6, 8": 384, "4, 6, 8": 385} CREATE STATISTICS
  • 29. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 29 EXPLAIN (ANALYZE, TIMING off) SELECT count(*) FROM places GROUP BY state, county, community; QUERY PLAN ----------------------------------------------------------------------- HashAggregate (cost=65422.20..65426.05 rows=385 width=47) (actual rows=420 loops=1) Group Key: state, county, community -> Seq Scan on places (cost=0.00..47732.10 rows=1769010 width=39) (actual rows=1768982 loops=1) Planning Time: 0.214 ms Execution Time: 482.752 ms Schätzung berichtigt
  • 30. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 30 • Das alte Verhalten war defensiv. • unzuverlässige Schätzungen mit mehreren Spalten • HashAggregate kann nicht auf Festplatte auslagern (bis PG12) (OOM) • statt Crash lieber Sort+GroupAggregate (langsam) • ndistinct-Koeffizienten • machen Schätzungen verlässlicher • weniger Gefahr von OOM • für große Tabellen + GROUP BY mehrere Spalten ndistinct
  • 31. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 31 MCV-Listen
  • 32. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 32 EXPLAIN (ANALYZE, TIMING off) SELECT * FROM orte WHERE kreis = 'Landkreis Günzburg' AND land = 'Bayern'; QUERY PLAN ---------------------------------------------------------------------- Seq Scan on orte (cost=0.00..509.17 rows=5 width=85) (actual rows=34 loops=1) Filter: ((kreis = 'Landkreis Günzburg'::text) AND (land = 'Bayern'::text)) Rows Removed by Filter: 16444 Planning Time: 0.117 ms Execution Time: 2.692 ms Unterschätzung
  • 33. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 33 CREATE STATISTICS s3 (mcv) ON kreis, land FROM orte; SET default_statistics_target = 10000; ANALYZE orte; SELECT most_common_vals, most_common_freqs FROM pg_stats_ext WHERE statistics_name = 's3'; most_common_vals | {{Hamburg,"Hamburg, Freie und Hansestadt"}, {Rheinland-Pfalz,"Eifelkreis Bitburg-Prüm"},... most_common_freqs | {0.02403204272363151,0.014200752518509527,... CREATE STATISTICS
  • 34. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 34 EXPLAIN (ANALYZE, TIMING off) SELECT * FROM orte WHERE kreis = 'Landkreis Günzburg' AND land = 'Bayern'; QUERY PLAN ----------------------------------------------------------------------- Seq Scan on orte (cost=0.00..509.17 rows=34 width=85) (actual rows=34 loops=1) Filter: ((kreis = 'Landkreis Günzburg'::text) AND (land = 'Bayern'::text)) Rows Removed by Filter: 16444 Planning Time: 0.518 ms Execution Time: 2.286 ms Unterschätzung berichtigt
  • 35. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 35 EXPLAIN (ANALYZE, TIMING off) SELECT * FROM places WHERE place <> 'London' AND county = 'Greater London'; QUERY PLAN ----------------------------------------------------------------------- Seq Scan on places (cost=0.00..56577.15 rows=157198 width=97) (actual rows=1782 loops=1) Filter: ((place <> 'London'::text) AND (county = 'Greater London'::text)) Rows Removed by Filter: 1767200 Planning Time: 0.284 ms Execution Time: 201.311 ms Überschätzung Nr. 1
  • 36. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 36 EXPLAIN (ANALYZE, TIMING off) SELECT * FROM places WHERE place <> 'London' AND county = 'Greater London'; QUERY PLAN ----------------------------------------------------------------------- Seq Scan on places (cost=0.00..56576.73 rows=39789 width=96) (actual rows=1782 loops=1) Filter: ((place <> 'London'::text) AND (county = 'Greater London'::text)) Rows Removed by Filter: 1767200 Planning Time: 3.533 ms Execution Time: 228.332 ms Überschätzung Nr. 1 mit MCV
  • 37. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 37 • mehr Arten von Statistiken • Histogramme? • Statistiken für Ausdrücke • Verwendung für Joins • Verwendung von MCV-Listen • Statistiken über mehrere Tabellen Ausblick
  • 38. © Copyright EnterpriseDB Corporation, 2020. All rights reserved. 38 Zusammenfassung • CREATE STATISTICS • als Ergänzung zu CREATE INDEX • dependencies, ndistinct, mcv • Verbesserungen in jeder Release