Postgres FM

Postgres FM

By Nikolay Samokhvalov and Michael ChristofidesNewsTechnologyTech News
Download on the App Store

All Postgres FM episodes

  • Advanced EXPLAIN

    Nikolay and Michael discuss some more advanced topics around EXPLAIN, including some tips for complex query plans, some recent improvements, and an idea or two that might make it even better.
     
    Here are some links to things they mentioned:

    • Michael’s solo episode on EXPLAIN basics https://postgres.fm/episodes/explain
    • Our episode on auto_explain https://postgres.fm/episodes/auto_explain
    • Which cloud providers support auto_explain? (Blog post by Michael) https://www.pgmustard.com/blog/which-cloud-providers-support-auto-explain
    • psychopg https://www.psycopg.org
    • Our first episode on BUFFERS https://postgres.fm/episodes/buffers-by-default
    • Our second episode on BUFFERS https://postgres.fm/episodes/buffers-ii-the-sequel
    • track_io_timing https://www.postgresql.org/docs/current/runtime-config-statistics.html#GUC-TRACK-IO-TIMING
    • compute_query_id https://www.postgresql.org/docs/current/runtime-config-statistics.html#GUC-COMPUTE-QUERY-ID 
    • EXPLAIN: beyond the basics (talk by Michael) https://www.youtube.com/watch?v=sGkSOvuaPs4


    ~~~

    What did you like or not like? What should we discuss next time? Let us know via a YouTube comment, on social media, or by commenting on our Google doc!


    ~~~

    Postgres FM is produced by:

    • Michael Christofides, founder of pgMustard
    • Nikolay Samokhvalov, founder of Postgres.ai


    With special thanks to:

    • Jessie Draws for the elephant artwork 
    49 min
  • Patroni

    Michael and Nikolay are joined by Alexander Kukushkin, PostgreSQL contributor and maintainer of Patroni, to discuss all things Patroni — what it is, how it works, recent improvements, and more.

    Here are some links to things they mentioned:

    • Alexander Kukushkin https://postgres.fm/people/alexander-kukushkin
    • Patroni https://github.com/patroni/patroni
    • Spilo https://github.com/zalando/spilo 
    • Zalando Postgres Operator https://github.com/zalando/postgres-operator
    • Crunchy Data Postgres Operator https://github.com/CrunchyData/postgres-operator
    • Split-brain https://en.wikipedia.org/wiki/Split-brain_(computing)
    • repmgr https://github.com/EnterpriseDB/repmgr
    • CloudNativePG https://github.com/cloudnative-pg/cloudnative-pg
    • Patroni release notes https://patroni.readthedocs.io/en/latest/releases.html
    • Citus & Patroni talk and demo by Alexander (at Citus Con 2023) https://www.youtube.com/watch?v=Mw8O9d0ez7E


    ~~~

    What did you like or not like? What should we discuss next time? Let us know via a YouTube comment, on social media, or by commenting on our Google doc!


    ~~~

    Postgres FM is produced by:

    • Michael Christofides, founder of pgMustard
    • Nikolay Samokhvalov, founder of Postgres.ai


    With special thanks to:

    • Jessie Draws for the elephant artwork 
    46 min
  • Postgres 17

    Nikolay and Michael discuss the fresh new Postgres 17 release! They cover several performance improvements, favourite new features, and some considerations for upgrading.
     
    Here are some links to things they mentioned:

    • Postgres 17 release notes https://www.postgresql.org/docs/17/release-17.html
    • transaction_timeout episode https://postgres.fm/episodes/transaction_timeout
    • VACUUM improvements discussed towards end of episode with Melanie Plageman https://postgres.fm/episodes/getting-started-with-benchmarking
    • B-tree improvements discussed in episdode with Peter Geoghegan https://postgres.fm/episodes/skip-scan
    • As Rails developers, why we are excited about PostgreSQL 17 (blog post by Benoit Tigeot) https://benoittgt.github.io/blog/postgres_17_rails/ 
    • Real World Performance Gains With Postgres 17 B-tree Bulk Scans (blog post by Brandur Leach) https://www.crunchydata.com/blog/real-world-performance-gains-with-postgres-17-btree-bulk-scans
    • MERGE RETURNING came up towards end of episode with Haki Benita https://postgres.fm/episodes/get-or-create
    • uuid_extract_timestamp and uuid_extract_version functions https://www.postgresql.org/docs/current/functions-uuid.html
    • Episode on UUID https://postgres.fm/episodes/uuid
    • Partitioning by ULID https://postgres.fm/episodes/partitioning-by-ulid
    • Why Upgrade? (site by depesz) https://why-upgrade.depesz.com
    • Why we spent the last month eliminating PostgreSQL subtransactions (GitLab blog post) https://about.gitlab.com/blog/2021/09/29/why-we-spent-the-last-month-eliminating-postgresql-subtransactions
    • Synchronization of sequences to subscriber (patch that needs review!)  https://commitfest.postgresql.org/49/5111


    ~~~

    What did you like or not like? What should we discuss next time? Let us know via a YouTube comment, on social media, or by commenting on our Google doc!


    ~~~

    Postgres FM is produced by:

    • Michael Christofides, founder of pgMustard
    • Nikolay Samokhvalov, founder of Postgres.ai


    With special thanks to:

    • Jessie Draws for the elephant artwork 
    43 min
  • Planning time

    Nikolay and Michael discuss planning time in Postgres — what it is, how to spot issues, its relationship to things like partitioning, and some tips for avoiding issues.
     
    Here are some links to things they mentioned:

    • Query Planning (docs) https://www.postgresql.org/docs/current/runtime-config-query.html
    • Are there limits to partition counts? (Blog post by depesz) https://www.depesz.com/2021/01/17/are-there-limits-to-partition-counts
    • Nikolays recent experiment https://postgres.ai/chats/01920004-a982-7896-b8cb-dfd2406359b0
    • PgBouncer now supports prepared statements https://github.com/pgbouncer/pgbouncer/releases/tag/pgbouncer_1_21_0
    • “The year of the lock manager’s revenge” (from blog post by Jeremy Schneider) https://ardentperf.com/2024/03/03/postgres-indexes-partitioning-and-lwlocklockmanager-scalability
    • pg_stat_statements.track_planning https://www.postgresql.org/docs/current/pgstatstatements.html#id-1.11.7.42.9.2.4.1.3
    • pg_hint_plan https://github.com/ossc-db/pg_hint_plan


    ~~~

    What did you like or not like? What should we discuss next time? Let us know via a YouTube comment, on social media, or by commenting on our Google doc!


    ~~~

    Postgres FM is produced by:

    • Michael Christofides, founder of pgMustard
    • Nikolay Samokhvalov, founder of Postgres.ai


    With special thanks to:

    • Jessie Draws for the elephant artwork 
    43 min
  • Slow count

    Nikolay and Michael discuss why counting can be slow in Postgres, and what the options are for counting things quickly at scale.
     
    Here are some links to things they mentioned:

    • Aggregate functions (docs) https://www.postgresql.org/docs/current/functions-aggregate.html
    • PostgREST https://github.com/PostgREST/postgrest 
    • Get rid of count by default in PostgREST https://github.com/PostgREST/postgrest/issues/273 
    • Faster PostgreSQL Counting (by Joe Nelson on the Citus blog) https://www.citusdata.com/blog/2016/10/12/count-performance 
    • Our episode on Index-Only Scans https://postgres.fm/episodes/index-only-scans
    • Postgres HyperLogLog https://github.com/citusdata/postgresql-hll
    • Our episode on Row estimates https://postgres.fm/episodes/row-estimates 
    • Our episode about dangers of NULLs https://postgres.fm/episodes/nulls-the-good-the-bad-the-ugly-and-the-unknown 
    • Aggregate expressions, including FILTER https://www.postgresql.org/docs/current/sql-expressions.html#SYNTAX-AGGREGATES
    • Spread writes for counter cache (tip from Tobias Petry) https://x.com/tobias_petry/status/1475870220422107137
    • pg_ivm extension (Incremental View Maintenance) https://github.com/sraoss/pg_ivm 
    • pg_duckdb announcement https://motherduck.com/blog/pg_duckdb-postgresql-extension-for-duckdb-motherduck
    • Our episode on Queues in Postgres https://postgres.fm/episodes/queues-in-postgres
    • Our episode on Real-time analytics https://postgres.fm/episodes/real-time-analytics
    • ClickHouse acquired PeerDB https://clickhouse.com/blog/clickhouse-acquires-peerdb-to-boost-real-time-analytics-with-postgres-cdc-integration
    • Timescale Continuous Aggregates https://www.timescale.com/blog/materialized-views-the-timescale-way
    • Timescale editions https://docs.timescale.com/about/latest/timescaledb-editions
    • Loose indexscan https://wiki.postgresql.org/wiki/Loose_indexscan


    ~~~

    What did you like or not like? What should we discuss next time? Let us know via a YouTube comment, on social media, or by commenting on our Google doc!


    ~~~

    Postgres FM is produced by:

    • Michael Christofides, founder of pgMustard
    • Nikolay Samokhvalov, founder of Postgres.ai


    With special thanks to:

    • Jessie Draws for the elephant artwork 
    44 min
  • Skip scan

    Michael and Nikolay are joined by Peter Geoghegan, major contributor and committer to Postgres, to discuss adding skip scan support to PostgreSQL over versions 17 and 18.
     
    Here are some links to things they mentioned:

    • Peter Geoghegan https://postgres.fm/people/peter-geoghegan
    • Peter’s previous (excellent) interview on Postgres TV https://www.youtube.com/watch?v=iAPawr1DxhM
    • Efficient Search of Multidimensional B-Trees (1995 paper by Harry Leslie, Rohit Jain, Dave Birdsall, and Hedieh Yaghmai) https://vldb.org/conf/1995/P710.PDF
    • Index Skip Scanning in Oracle https://oracle-base.com/articles/9i/index-skip-scanning
    • Peter’s introductory email to the hackers mailing list about adding skip scan https://www.postgresql.org/message-id/CAH2-Wzmn1YsLzOGgjAQZdn1STSG_y8qP__vggTaPAYXJP+G4bw@mail.gmail.com
    • Loose Indexscan versus Index Skip Scan (PostgreSQL wiki) https://wiki.postgresql.org/wiki/Loose_indexscan
    • Tom Lane will be on the Talking Postgres podcast on October 9th https://aka.ms/TalkingPostgres-Ep20-cal
    • Benoit Tigeot feedback and repro (originally reported via Slack) https://gist.github.com/benoittgt/ab72dc4cfedea2a0c6a5ee809d16e04d?permalink_comment_id=4597410#gistcomment-4597410
    • Summary video and blog post about the v17 work by Lukas from pganalyze (not mentioned but great) https://pganalyze.com/blog/5mins-postgres-17-faster-btree-index-scans
    • Understanding HNSW + filtering (pgvector repo discussion) https://github.com/pgvector/pgvector/issues/259
    • btree_gin https://www.postgresql.org/docs/current/btree-gin.html


    ~~~

    What did you like or not like? What should we discuss next time? Let us know via a YouTube comment, on social media, or by commenting on our Google doc!


    ~~~

    Postgres FM is produced by:

    • Michael Christofides, founder of pgMustard
    • Nikolay Samokhvalov, founder of Postgres.ai


    With special thanks to:

    • Jessie Draws for the elephant artwork 
    58 min
  • Postgres Emergency Room

    Nikolay and Michael discuss PostgreSQL emergencies — both the psychological side of incident management, and some technical aspects too.
     
    Here are some links to things they mentioned:

    • Site Reliability Engineering resources from Google https://sre.google
    • GitLab Handbook SRE https://handbook.gitlab.com/job-families/engineering/infrastructure/site-reliability-engineer
    • Keeping Customers Streaming — The Centralized Site Reliability Practice at Netflix https://netflixtechblog.com/keeping-customers-streaming-the-centralized-site-reliability-practice-at-netflix-205cc37aa9fb
    • Our monitoring checklist episode https://postgres.fm/episodes/monitoring-checklist
    • Hannu Krosing talk on Postgres TV — Do you vacuum everyday? https://www.youtube.com/watch?v=JcRi8Z7rkPg
    • Our episode on corruption https://postgres.fm/episodes/corruption
    • Nikolay’s episode on stopping and starting Postgres faster https://postgres.fm/episodes/stop-and-start-postgres-faster
    • Our episode on out of disk https://postgres.fm/episodes/out-of-disk
    • The USE method (Brendan Gregg) https://www.brendangregg.com/usemethod.html 
    • Thundering herd problem https://en.wikipedia.org/wiki/Thundering_herd_problem
    • pgwatch2 Postgres AI edition https://gitlab.com/postgres-ai/pgwatch2


    ~~~

    What did you like or not like? What should we discuss next time? Let us know via a YouTube comment, on social media, or by commenting on our Google doc!


    ~~~

    Postgres FM is produced by:

    • Michael Christofides, founder of pgMustard
    • Nikolay Samokhvalov, founder of Postgres.ai


    With special thanks to:

    • Jessie Draws for the elephant artwork 
    46 min
  • Get or Create

    Michael and Nikolay are joined by Haki Benita, a technical lead and database enthusiast who writes an excellent blog and gives popular talks and training sessions too, to discuss the surprisingly complex topic of trying to implement “get or create” in PostgreSQL — handling issues around idempotency, concurrency, and bloat.
     
    Here are some links to things they mentioned:

    • Haki Benita https://hakibenita.com 
    • How to Get or Create in PostgreSQL (blog post by Haki) https://hakibenita.com/postgresql-get-or-create 
    • "Find-or-insert" using a single query (how-to guide by Nikolay) https://gitlab.com/postgres-ai/postgresql-consulting/postgres-howtos/-/blob/main/0036_find-or-insert_using_a_single_query.md?ref_type=heads 
    • Is SELECT or INSERT in a function prone to race conditions? (Answer by Erwin Brandstetter)  https://stackoverflow.com/questions/15939902/is-select-or-insert-in-a-function-prone-to-race-conditions/15950324#15950324 
    • get_or_create() in Django https://docs.djangoproject.com/en/5.1/ref/models/querysets/#get-or-create 
    • Subtransactions Considered Harmful (blog post by Nikolay) https://postgres.ai/blog/20210831-postgresql-subtransactions-considered-harmful 
    • MERGE (Postgres documentation) https://www.postgresql.org/docs/current/sql-merge.html
    • Hidden dangers of duplicate key violations in PostgreSQL and how to avoid them (blog post by Divya Sharma and Shawn McCoy from the RDS team) https://aws.amazon.com/blogs/database/hidden-dangers-of-duplicate-key-violations-in-postgresql-and-how-to-avoid-them/ 
    • One, Two, Skip a Few... (blog post by Pete Hamilton from Incident) https://incident.io/blog/one-two-skip-a-few 


    ~~~

    What did you like or not like? What should we discuss next time? Let us know via a YouTube comment, on social media, or by commenting on our Google doc!


    ~~~

    Postgres FM is produced by:

    • Michael Christofides, founder of pgMustard
    • Nikolay Samokhvalov, founder of Postgres.ai


    With special thanks to:

    • Jessie Draws for the elephant artwork 
    51 min
  • Getting started with benchmarking

    Michael and Nikolay are joined by Melanie Plageman, database internals engineer at Microsoft and major contributor and committer to PostgreSQL, to discuss getting started with benchmarking — how it differs for users and developers of Postgres, how and when it comes up during development, some tools and lessons, as well as what she's working on at the moment.
     
    Here are some links to things they mentioned:

    • Melanie Plageman https://postgres.fm/people/melanie-plageman
    • Meanie’s Introduction to Benchmarking With pgbench talk slides https://postgresql.us/events/pgconfnyc2023/schedule/session/1410-introduction-to-benchmarking-with-pgbench/#slides
    • Melanie’s Visualizing Postgres I/O Performance for Development talk recording https://www.youtube.com/watch?v=CxyPZHG5beI
    • Melanie’s Visualizing Postgres I/O Performance for Development talk slides https://speakerdeck.com/melanieplageman/o-performance-for-development
    • pgbench https://www.postgresql.org/docs/current/pgbench.html
    • Mark Callaghan’s blog https://smalldatum.blogspot.com
    • Some of Tomas Vondra’s blog posts https://www.enterprisedb.com/blog/author/tomas-vondra
    • Some of Andres Freund’s blog posts https://www.citusdata.com/blog/authors/andres-freund/
    • An example of Alexander Lakhin’s work https://www.postgresql.org/message-id/b32bed1b-0746-9b20-1472-4bdc9ca66d52%40gmail.com
    • Simplifying the TPC Benchmark C, an OLTP Workload (talk by Mark Wong) https://www.youtube.com/watch?v=qi0I74urLoY
    • Matplotlib https://matplotlib.org
    • pandas https://pandas.pydata.org
    • pg_stat_io https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-IO-VIEW
    • pg_stat_io commit https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=a9c70b46dbe152e094f137f7e6ba9cd3a638ee25 
    • pg_buffercache https://www.postgresql.org/docs/current/pgbuffercache.html
    • tmpfs https://docs.kernel.org/filesystems/tmpfs.html
    • Eager page freeze criteria mailing list thread https://www.postgresql.org/message-id/CAAKRu_b3tpbdRPUPh1Q5h35gXhY%3DspH2ssNsEsJ9sDfw6%3DPEAg%40mail.gmail.com
    • The path to using AIO in postgres (talk by Andres Freund) https://www.youtube.com/watch?v=qX50xrHwQa4
    • Improve dead tuple storage for lazy vacuum (Masahiko Sawada) https://www.postgresql.org/message-id/flat/CAD21AoAfOZvmfR0j8VmZorZjL7RhTiQdVttNuC4W-Shdc2a-AA@mail.gmail.com


    ~~~

    What did you like or not like? What should we discuss next time? Let us know via a YouTube comment, on social media, or by commenting on our Google doc!


    ~~~

    Postgres FM is produced by:

    • Michael Christofides, founder of pgMustard
    • Nikolay Samokhvalov, founder of Postgres.ai


    With special thanks to:

    • Jessie Draws for the elephant artwork 
    57 min
  • Index-Only Scans

    Nikolay and Michael discuss Index-Only Scans in Postgres — what they are, how they help, some things to look out for, and some advice.
     
    Here are some links to things they mentioned:

    • Index-Only Scans and Covering Indexes (docs) https://www.postgresql.org/docs/current/indexes-index-only-scans.html
    • Discussion on Twitter about JIT and Parallel Query defaults https://x.com/jer_s/status/1819749688184373742
    • Postgres Wiki on Index-Only Scans https://wiki.postgresql.org/wiki/Index-only_scans
    • Heap Fetches https://www.pgmustard.com/docs/explain/heap-fetches
    • Rows Removed By Filter https://www.pgmustard.com/docs/explain/rows-removed-by-filter
    • random_page_cost https://postgresqlco.nf/doc/en/param/random_page_cost/
    • pg_dump docs change https://x.com/samokhvalov/status/1820539826363588755
    • Crunchy Bridge changed random_page_cost to 1.1 for new servers https://docs.crunchybridge.com/changelog#postgres_random_page_cost_1_1
    • Autovacuum Tuning Basics (updated blog post by Tomas Vondra) https://www.enterprisedb.com/blog/autovacuum-tuning-basics
    • Our episode on over-indexing https://postgres.fm/episodes/over-indexing
    • Our episode on HOT updates https://postgres.fm/episodes/hot-updates
    • Our episode on partitioning https://postgres.fm/episodes/partitioning


    ~~~

    What did you like or not like? What should we discuss next time? Let us know via a YouTube comment, on social media, or by commenting on our Google doc!


    ~~~

    Postgres FM is produced by:

    • Michael Christofides, founder of pgMustard
    • Nikolay Samokhvalov, founder of Postgres.ai


    With special thanks to:

    • Jessie Draws for the elephant artwork 
    40 min