Migliorare le prestazioni delle query in PostgreSQL
Amy McCarty
Instructor
Archiviazione per colonne
| 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 |
Memorizzata come

Proprietà dell’archiviazione per colonne
Focus analitico
Memorizzata come

Relazioni per riga mantenute
Focus transazionale
Memorizzata come

| Postgres | Citus Data, Greenplum, Amazon Redshift |
| MySQL | MariaDB |
| Oracle | Oracle In-Memory Cloud Store |
| Clickhouse, Apache Druid, CrateDB |
Ridurre le colonne
SELECT * con parsimoniaSELECT column_name, data_type
FROM information_schema.columns
WHERE table_catalog = 'schema_name'
AND table_name = 'zoo_animals'
| column_name | data_type |
|---|---|
| id | integer |
| name | text |
| species | text |
Ridurre le colonne
SELECT * con parsimoniaSELECT column_name, data_type
FROM information_schema.columns
WHERE table_catalog = 'schema_name'
AND table_name = 'zoo_animals'
| column_name | data_type |
|---|---|
| id | integer |
| name | text |
| species | text |
| 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 |
-- Struttura per archiviazione per colonne
SELECT MIN(age), MAX(age)
FROM zoo_animals
WHERE species = 'zebra'
-- Struttura per archiviazione per righe
SELECT *
FROM zoo_animals
WHERE species = 'zebra'
ORDER BY age
Migliorare le prestazioni delle query in PostgreSQL