2025 PostgresProfessional - DEV1 of p21 https://www.youtube.com/playlist?list=PLaFqU3KCWw6IkaSNjSLshxbwbeeM_M2jj PostgresProfessional - DEV2 for PG16 of p21 https://www.youtube.com/playlist?list=PLaFqU3KCWw6LVproqLXM8AyD0c2gTKa7a PostgresProfessional - DBA1 for PG16 of p17 https://www.youtube.com/playlist?list=PLaFqU3KCWw6JXh-J35QSK47B6xi3nYEwn 2023 PostgresProfessional - DBA2 Administration of 18 parts https://www.youtube.com/playlist?list=PLaFqU3KCWw6L72nIqJ-l-pscc6WxtW4G1 PostgresProfessional - RogovLuzanovTolmachyov - QPT13 - Query Optimization of p12 https://postgrespro.ru/education/courses/QPT https://www.youtube.com/playlist?list=PLaFqU3KCWw6JW80WBHPOe-SMJD2NOjmge p11 - Optimization Tricks of 1:06:08 https://www.youtube.com/watch?v=AsaGNjJtrR4 ! 6:00 vacuum cfg ! autovacuum_max_workers, autovacuum_analyze_scale_factor ! 11:00 io cfg ! seq_page_cost = 1.0 ! random_page_cost = 4.0 # for ssd recommended to set 1.1 ! effective_io_concurrency = 1 ! 12:00 cpu cfg ! cpu_tuple_cost = 0.01 ! cpu_index_tuple_cost = 0.005 ! cpu_operator_cost = 0.0025 ! CREATE FUNCTION ... COST # 1 for c-function, 100 - for user-defined ! 14:00 parallel cfg ! parallel_setup_cost = 1000 ! parallel_tuple_cost = 0.1 ! ... ! cursor_tuple_fraction = 0.1 ! 18:00 ram settings ! work_mem = 4MB # pretty low, need to increase ! hash_mem_multiplier = 1 ! maintanance_work_mem = 64MB ! effective_cache_size = 4GB ! 20:00 some cfg can be set at tablespace/db/role/routine/session/transaction level ! ALTER TABLESPACE SET ... ! ALTER DATABASE SET ... ! ALTER ROLE [IN DATABASE ...] SET ... ! ALTER ROUTINE SET ... ! SET [LOCAL] ... ! 24:00 debug cfg ! enable_seqscan ! enable_indexscan, enable_bitmapscan, enable_indexonlyscan ! enable_nestloop, enable_hashjoin, enable_mergejoin ! enable_hashagg, enable_sort, enable_incremental_sort ! force_parallel_mode ! 39:00 manual join order control ! join_collapse_limit # 1 - for manual ! from_collapse_limit ! !!! move parts of query to CTE (in order to reduce number of joins and make planner work easier) ! 42:00 ... with b as materialized (....) ! first calc CTE (marked with b at plan) - not effective, but good for debug/trace purposes p10 - profiling of 37:49 https://www.youtube.com/watch?v=o5T0ApVFcDc ! 16:00 log_min_duration_statements=0 # time and text of all queries ! log_line_prefix # identity info ! # analyse via pgBadger tool ! 19:00 pg_stat_statements ext ! 22:00 set pg_stat_statements.track = 'all'; # store all queries info, including compound ones ! p9 - Statistics of 46:28 https://www.youtube.com/watch?v=I4cedjshRrs ! pg_class - num of tuples/pages (reltuples/relpages) for tables ! setting default_statistics_target = 100 ! "selection size" for table analysis ! pg_stats - n_distinct, null_tract - ration of uniq vals ! most_common_vals, most_common_freqs ! pg_statistics_ext, pg_statistics_ext_data, pg_stats_ext view (for dependent column values) p8 - Merge Join of 24:26 https://www.youtube.com/watch?v=urerHBMGc14 ! set should be sorted first (either from downstream node of plan or from idx) ! Merge Join: ... ! Merge Cond: ... ! 18:00 Sort: ! Sort Key: ! Sort Method: ! Buffers: ... ! 20:00 Agg... ! Gather Merge:... p7 - Hash Join of 29:03 https://www.youtube.com/watch?v=zH_LJAsYvcU ! can be in a single (Batches: 1) or double-batches (when can't feet into RAM) ! 3:00 work_mem * hash_mem_multiplier ! 5:00 Hash Join ! Hash Cond: (... = ...) ! -> Seq Scan on alias ! -> Hash ! -> Seq Scan on ... ! Hash Full Join ! 7:00 hash joing can be used for DISTINCT ! Hash Aggregate ... ! Group Key ... ! explain (analyze, settings - to show all non-std param-values, ... ) ! ! hash-table need to be build my lower set of rows (to decrease RAM usage) ! 12:00 ! Hash Cond: ! Join Filter: ... ! 13:00 - double-batches (not feet into RAM, use tmp-files) ! 17:00 Hash (...) ! Buckets: ... Batches: 4 ... ! Buffers: ..., temp written=5217 p6 - Inner Loop Join of 20:35 https://www.youtube.com/watch?v=VeGJAQo9ogM ! Bitmap Index Scan ! Heap Blocks: exact=4413 (we have enough RAM) ! ... lossy=3989 (non-precise fragments, contains links to table segments for re-check) ! !! set/reset workmem ! 4:00 select a.title, s.name ! from albums a join songs s on a.id = s.a_id; ! Nested Loop - node of plan ! 12:00 select * from aircrafts a left join seats s on (a.aircraft_code = s.aircraft_code) where a.model like '...'; ! Nested Loop Left Join - node of plan ! 19:00 nested-loop-join is effective on middle/sized cardinality only (for big ones need index) ! + join can be done on anly condition p5 - Bitmap Scan 0:00 of 25:57 https://www.youtube.com/watch?v=j7e7EANyJhE p4 - Inex Scan of 41:10 https://www.youtube.com/watch?v=iu35dYTchu4 ! 8:00 select current_setting('random_page_cost'); -> 4 ! !!! need to decrease in case of ssd-disks ! current_setting ! 'random_page_cost' ! 'seq_page_cost' ! 'cpu_tuple_cost' ! 'cpu_index_tuple_cost' ! 'cpu_operator_cost' ! 18:00 - other params ! min_parallel_index_scan_size ! ...per_... ! 26:00 - create index ... include(...) ! 33:00 - duplicate index records ! 34:30 - pg has dup-idx-records exclusion mechanism (works only upon index-page-split) ! create index ... with(deduplicate_items=off) -- to switchi it off ! 37:00 - set enable_seqscan = off; -- to temporary disable seqscan p3 - Sequential Scan of 47:06 https://www.youtube.com/watch?v=X2DOIf0DfJ0 ! parallel processing is not-efficitent for full seq-load, but is effective for the case of agg-n ! "Parallel Seq Scan" -> "Partial Aggregate" -> "Gather" ! 34:00 set max_parallel_workers_per_gather = 5; ! 46:00 "post_parallel_mode" - allows to check whether query can be paral-d in principle p2 - Query Execution of 43:14 https://www.youtube.com/watch?v=_6ce4YFFScc ! 26:00 - set jit = off; ! prepare model(varchar) as select model from aircrafts where iircraft_code = $1; ! select * from pg_prepared_systems; ! deallocate ... (or just close session) ! 27:00 - declare c cursor for select * from aircrafts; ! fetch c; ... close c; p1 - Air Demobase of 30:07 https://www.youtube.com/watch?v=k9cloEiIPC0 p0 - Intro of 8:49 https://www.youtube.com/watch?v=2-UmottNWWk 2022 PostgresProfessional - Hacking PostgreSQL of p8 https://www.youtube.com/playlist?list=PLaFqU3KCWw6Jfb8IBNk3hZ07dxMxjfGtv ! need to look 2021 PostgresProfessional - Rogov - DEV2 of 21 videos https://www.youtube.com/playlist?list=PLaFqU3KCWw6K3AyBVcZGdXMtM2xvjHA1N https://postgrespro.ru/education/courses/DEV2 PostgresProfessional - Rogov - Luzanov - Bashtaev - DBA1 Administration of 19 parts https://www.youtube.com/playlist?list=PLaFqU3KCWw6LPcuYVymLcXl3muC45mu3e https://postgrespro.ru/education/courses/DBA1 2019 PostgresProfessional - DBA3 Administration of 9 parts https://www.youtube.com/playlist?list=PLaFqU3KCWw6KEakTSrRWrekNI-z9U1ypF https://postgrespro.ru/education/courses/DBA3 PostgresProfessional - DBA2 Administration of 18 parts https://www.youtube.com/playlist?list=PLaFqU3KCWw6KycrRthIC6mESoLLQen1k6 https://postgrespro.ru/education/courses/DBA2 PostgresProfessional - DBA1 Administration of 19 parts https://www.youtube.com/playlist?list=PLaFqU3KCWw6KycrRthIC6mESoLLQen1k6 PostgresProfessional - Rogov - Luzanov - DBA1 Administration of 19 parts https://www.youtube.com/playlist?list=PLaFqU3KCWw6JhHBp07QSu9uE8zahhKnTn https://postgrespro.ru/education/courses/DBA1 Morgunov - sqlprimer https://www.youtube.com/playlist?list=PLaFqU3KCWw6J1NEI8hjYlvGnD4Y7Sxx4r https://postgrespro.ru/education/university/sqlprimer https://edu.postgrespro.ru/sqlprimer/sqlprimer-2019-msu-03.pdf https://edu.postgrespro.ru/sqlprimer/sqlprimer-2019-msu-04.pdf Novikov https://edu.postgrespro.ru/dbtech/ https://www.youtube.com/playlist?list=PLaFqU3KCWw6K5maTyTF2NdcbpNsPHRecu 2018 PostgresProfessional - Rogov - Luzanov - DEV1 of 21 videos https://www.youtube.com/playlist?list=PLaFqU3KCWw6LNR1IZ814whJe89J1tRQ3t https://postgrespro.ru/education/courses/DEV1