Improving Query Performance in PostgreSQL
Amy McCarty
Instructor
Row oriented storage
Column-oriented storage
id | name | species | age | habitat | received |
---|---|---|---|---|---|
01 | Bob | panda | 2 | Asia | 2018 |
02 | Sunny | zebra | 3 | Africa | 2018 |
03 | Beco | zebra | 10 | Africa | 2017 |
04 | Coco | koala | 5 | Australia | 2016 |
Row-oriented storage
id | name | species | age | habitat | received |
---|---|---|---|---|---|
01 | Bob | panda | 2 | Asia | 2018 |
Column-oriented storage
Reduce the number of rows
WHERE
filterINNER JOIN
DISTINCT
LIMIT
Partitions
Indexes
Using partitions and indexes
SELECT species
FROM zoo_animals
WHERE habitat = 'Africa'
What
Why
Where
Query planner
EXPLAIN
SELECT species
FROM zoo_animals
WHERE habitat = 'Africa'
Query Plan
Seq Scan on zoo_animals (cost=0.00..
17.70 rows=2 width=182)
Filter: (state_code = 15)
Improving Query Performance in PostgreSQL