Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Half a dozen exciting new features in PostgreSQL

Half a dozen exciting new features in PostgreSQL

Avatar for Thomas Munro

Thomas Munro

October 17, 2025
Tweet

More Decks by Thomas Munro

Other Decks in Programming

Transcript

  1. Half a dozen exciting new PostgreSQL features PGDU.org 2025 Sydney

    Thomas Munro — Open source developer at Microsoft
  2. PostgreSQL 18 is out! 507 people are listed as developers

    for this release: Abhishek Chanda Adam Guo Adam Rauch Aidar Imamov Ajin Cherian Alastair Turner Alec Cozens Aleksander Alekseev Alena Rybakina Alex Friedman Alex Richman Alexander Alehin Alexander Borisov Alexander Korotkov Alexander Kozhemyakin Alexander Kukushkin Alexander Kuzmenkov Alexander Kuznetsov Alexander Lakhin Alexander Pyhalov Alexandra Wang Alexey Dvoichenkov Alexey Makhmutov Alexey Shishkin Ali Akbar Álvaro Herrera Álvaro Mongil Amit Kapila Amit Langote Amul Sul Andreas Karlsson Andreas Scherbaum Andreas Ulbrich Andrei Lepikhov Andres Freund Andrew Andrew Bille Andrew Dunstan Andrew Jackson Andrew Kane Andrew Watkins Andrey Borodin Andrey Chudnovsky Andrey Rachitskiy Andrey Rudometov Andy Alsup Andy Fan Anthonin Bonnefoy Anthony Hsu Anthony Leung Anton Melnikov Anton Voloshin Antonin Houska Antti Lampinen Arseniy Mukin Artur Zakirov Arun Thirupathi Ashutosh Bapat Asphator Atsushi Torikoshi Avi Weinberg Aya Iwata Ayush Tiwari Ayush Vatsa Bastien Roucariès Ben Peachey Higdon Benoit Lobréau Bernd Helmle Bernd Reiß Bernhard Wiedemann Bertrand Drouvot Bertrand Mamasam Bharath Rupireddy Bogdan Grigorenko Boyu Yang Braulio Fdo Gonzalez Bruce Momjian Bykov Ivan Cameron Vogt Cary Huang Cédric Villemain Cees van Zeeland ChangAo Chen Chao Li Chapman Flack Charles Samborski Chengwen Wu Chengxi Sun Chiranmoy Bhattacharya Chris Gooch Christian Charukiewicz Christoph Berg Christophe Courtois Christopher Inokuchi Clemens Ruck Corey Huinker Craig Milhiser Crisp Lee Dag fi nn Ilmari Mannsåker Daniel Elishakov Daniel Gustafsson Daniel Vérité Daniel Westermann Daniele Varrazzo Daniil Davydov Daria Shanina Dave Cramer Dave Page David Benjamin David Christensen David Fiedler David G. Johnston David Geier David Rowley David Steele David Wheeler David Zhang Davinder Singh Dean Rasheed Devanga Susmitha Devrim Gündüz Dian Fay Dilip Kumar Dimitrios Apostolou Dipesh Dhameliya Dmitrii Bondar Dmitry Dolgov Dmitry Koval Dmitry Kovalenko Dmitry Yurichev Dominique Devienne Donghang Lin Dorjpalam Batbaatar Drew Callahan Duncan Sands Dwayne Towell Dzmitry Jachnik Egor Chindyaskin Egor Rogov Emanuel Ionescu Emanuele Musella Emre Hasegeli Eric Cyr Erica Zhang Erik Nordström Erik Rijkers Erik Wienhold Erki Eessaar Ethan Mertz Etienne LAFARGE Etsuro Fujita Euler Taveira Evan Si Evgeniy Gorbanev Fabio R. Sluzala Fabrízio de Royes Mello Feike Steenbergen Feliphe Pozzer Felix Fire Emerald Florents Tselai Francesco Degrassi Frank Streitzig Frédéric Yhuel Fredrik Widlert Gabriele Bartolini Gavin Panella Geo ff Winkless George MacKerron Gilles Darold Grant Gryczan Greg Burd Greg Sabino Mullane Greg Stark Grigory Kryachko Guillaume Lelarge Gunnar Morling Gunnar Wagner Gurjeet Singh Haifang Wang Hajime Matsunaga Hamid Akhtar Hannu Krosing Hari Krishna Sunder Haruka Takatsuka Hayato Kuroda Heikki Linnakangas Hironobu Suzuki Holger Jakobs Hubert Lubaczewski Hugo Dubois Hugo Zhang Hunaid Sohail Hywel Carver Ian Barwick Ibrar Ahmed Igor Gnatyuk Igor Korot Ilia Evdokimov Ilya Gladyshev Ilyasov Ian Imran Zaheer Isaac Morland Israel Barth Rubio Ivan Kush Jacob Brazeal Jacob Champion Jaime Casanova Jakob Egger Jakub Wartak James Coleman James Hunter Jan Behrens Japin Li Jason Smith Jayesh Dehankar Jeevan Chalke Je ff Davis Jehan-Guillaume de Rorthais Jelte Fennema-Nio Jian He Jianghua Yang Jiao Shuntian Jim Jones Jim Nasby Jingtang Zhang Jingzhou Fu Joe Conway Joel Jacobson John Hutchins John Naylor Jonathan Katz Jorge Solórzano José Villanova Josef Šimánek Joseph Koshakow Julien Rouhaud Junwang Zhao Justin Pryzby Kaido Vaikla Kaimeh Karina Litskevich Karthik S Kartyshov Ivan Kashif Zeeshan Keisuke Kuroda Kevin Hale Boyes Kevin K Biju Kirill Reshke Kirill Zdornyy Koen De Groote Koichi Suzuki Koki Nakamura Konstantin Knizhnik Kouhei Sutou Kuntal Ghosh Kyotaro Horiguchi Lakshmi Narayana Velayudam Lars Kanis Laurence Parry Laurenz Albe Lele Gaifax Li Yong Lilian Ontowhee Lingbin Meng Luboslav Špilák Luca Vallisa Lukas Fittl Maciek Sakrejda Magnus Hagander Mahendra Singh Thalor Mahendrakar Srinivasarao Maiquel Grassi Maksim Korotkov Maksim Melnikov Man Zeng Marat Buharov Marc Balmer Marco Nenciarini Marcos Pegoraro Marina Polyakova Mark Callaghan Mark Dilger Marlene Brandstaetter Marlene Reiterer Martin Rakhmanov Masahiko Sawada Masahiro Ikeda Masao Fujii Mason Mackaman Mat Arye Matheus Alcantara Mats Kindahl Matthew Gabeler-Lee Matthew Kim Matthew Sterrett Matthew Woodcraft Matthias van de Meent Matthieu Denais Maurizio Boriani Max Johnson Max Madden Maxim Boguk Maxim Orlov Maximilian Chrzan Melanie Plageman Melih Mutlu Mert Alev Michael Banck Michael Bondarenko Michael Christo fi des Michael Guissine Michael Harris Michaël Paquier Michail Nikolaev Michal Kleczek Michel Pelletier Mikaël Gourlaouen Mikhail Gribkov Mikhail Kot Milosz Chmura Muralikrishna Bandaru Murat Efendioglu Mutaamba Maasha Naeem Akhter Nat Makarevitch Nathan Bossart Navneet Kumar Nazir Bilal Yavuz Neil Conway Niccolò Fei Nick Davies Nicolas Maus Niek Brasa Nikhil Raj Nikita Nikita Kalinin Nikita Malakhov Nikolay Samokhvalov Nikolay Shaplov Nisha Moond Nitin Jadhav Nitin Motiani Noah Misch Noboru Saito Noriyoshi Shinoda Ole Peder Brandtzæg Oleg Sibiryakov Oleg Tselebrovskiy Olleg Samoylov Onder Kalaci Ondrej Navratil Patrick Stählin Paul Amonson Paul Jungwirth Paul Ramsey Pavel Borisov Pavel Luzanov Pavel Nekrasov Pavel Stehule Peter Eisentraut Peter Geoghegan Peter Mittere Peter Smith Phil Eaton Philipp Salvisberg Philippe Beaudoin Pierre Giraud Pixian Shi Polina Bungina Przemyslaw Sztoch Quynh Tran Ra fi a Sabih Raghuveer Devulapalli Rahila Syed Rama Malladi Ran Benita Ranier Vilela Renan Alves Fonseca Richard Guo Richard Neill Rintaro Ikeda Robert Haas Robert Treat Robins Tharakan Roman Zharkov Ronald Cruz Ronan Dunklau Rui Zhao Rushabh Lathia Rustam Allakov Ryo Kanbayashi Ryohei Takahashi RyotaK Sagar Dilip Shedge Salvatore Dipietro Sam Gabrielsson Sam James Sameer Kumar Sami Imseih Samuel Thibault Satyanarayana Narlapuram Sebastian Skalacki Senglee Choi Sergei Kornilov Sergey Belyashov Sergey Dudoladov Sergey Prokhorenko Sergey Sargsyan Sergey Soloviev Sergey Tatarintsev Shaik Mohammad Mujeeb Shawn McCoy Shenhao Wang Shihao Zhong Shinya Kato Shlok Kyal Shubham Khanna Shveta Malik Simon Riggs Smolkin Grigory So fi a Kopikova Song Hongyu Song Jinzhou Soumyadeep Chakraborty Sravan Kumar Srinath Reddy Stan Hu Stepan Neretin Stephen Fewer Stephen Frost Steve Chavez Steven Niu Suraj Kharage Sven Klemm Takamichi Osumi Takeshi Ideriha Tatsuo Ishii Ted Yu Tels Tender Wang Teodor Sigaev Thom Brown Thomas Baehler Thomas Krennwallner Thomas Munro Tim Wood Timur Magomedov Tobias Wendor ff Todd Cook To fi g Aliev Tom Lane Tomas Vondra Tomasz Rybak Tomasz Szypowski Torsten Foertsch Toshi Harada Tristan Partin Triveni N Umar Hayat Vallimaharajan G Vasya Boytsov Victor Yegorov Vignesh C Viktor Holmberg Vinícius Abrahão Vinod Sridharan Virender Singla Vitaly Davydov Vladlen Popolitov Vladyslav Nebozhyn Walid Ibrahim Webbo Han Wenhui Qiu Will Mortensen Will Storey Wolfgang Walther Xin Zhang Xing Guo Xuneng Zhou Yan Chengpen Yang Lei Yaroslav Saburov Yaroslav Syrytsia Yasir Hussain Yasuo Honda Yogesh Sharma Yonghao Lee Yoran Heling Yu Liang Yugo Nagata Yuhang Qiu Yuki Seino Yura Sokolov Yurii Rashkovskii Yushi Ogiwara Yusuke Sugie Yuta Katsuragi Yuto Sasaki Yuuki Fujii Yuya Watari Zane Du ff i eld Zeyuan Hu Zhang Mingli Zhihong Yu Zhijie Hou Zsolt Parragi •
  3. Talk • Part I: Themes in recent releases • Part

    II: Three selected user-facing improvements • Part III: Three selected internal improvements
  4. The SQL standard • MERGE statements — v15 • SQL/JSON

    — standardisation of JSON v12, v16, v17 • Elements of temporal support, small steps — v18 • Much more
 • WIP: SQL/PGQ for graphs (SQL:2023) • Opportunities: MATCH_RECOGNIZE, DECFLOAT
  5. Planner evolution (As always) • Giving the planner more ways

    to consider executing your queries • Being a heuristic system, new plans can sometimes turn out to be slower for a given query, requiring investigation
  6. Indexes • Btree — workhorse index AM • Parallel index

    build — v11 • Duplicate compression — v12 • E ffi cient IN scan — v17 • Skip scan — v18 • Faster build by skipping bu ff er pool and writing directly to disk • Equivalent GIN, Gist, BRIN, Hash index performance improvements tend to follow later (where appropriate)
  7. Observability • Overhauled cumulative statistics subsystem • New I/O statistics

    views: pg_stat_io — v16 • EXPLAIN improved to show information about bu ff ers, WAL, caching, etc
  8. I/O performance • V16: Allocating disk space in bulk during

    large data insertions (XFS, EXT4) • Baby steps in optimal data exchange between storage and memory • V16: Experimental direct I/O mode to skip kernel page cache • V17: Streaming I/O, combined I/O; limited usage but it’s fast • V18: Asynchronous I/O • Various ways to take advantage of re fl inks (XFS, EXT4, …), block sharing (XFS, BTRFS, ZFS) and copy push-down (network fi le systems, …), CREATE DATABASE, pg_upgrade, pg_combinebackup (—> see later)
  9. Recovery and replication • Physical replication and crash recovery •

    V14 — performance improvements • V15 — basic prefetching of data pages during crash recovery and binary replication (work ongoing) • Logical replication • Parallelisation, completeness, failover, maintenance improvements
  10. Modernisation • Migration from GNU con fi gure + make

    build system to meson build system, making building testing faster and the same across Unix and Windows systems • Dropping support for OSes, compilers, library versions that have reached the end of the line, don’t have active maintainers, aren’t keeping up with the modern standards we need for our plans • V19: Moving to C11, requiring recent POSIX features and recent Windows versions • V15: CI
  11. Low level optimisation “Mechanical sympathy” • Removing false sharing, unnecessary

    writes, lock contention • Vectorising, autovectorising, • Specialising in C • Specialising with JIT • Detecting and using special hardware instructions • Batching • Tuning layout • Baby steps in understanding NUMA
  12. Many more areas • Performance of partitioned tables • Better

    support for collations: fexibility and stability • Certainly many things I’m forgetting!
  13. SQL/JSON • Alignment with SQL:2016, SQL:2023 standardised JSON support •

    JSON_TABLE() — query JSON like a table in a query • JSON_QUERY() — standardised JPath queries
  14. New options for locales • New built-in locale provider allowing

    for fast Unicode text without unstable sort order determined by system libraries • Changes to glibc, ICU de fi nitions can cause indexes to become corrupt • Only C was completely stable in the past • Historically even C.UTF8 had surprising instability • Many data sets don’t need cultural text sorting rules, and users may not realize they are being used until something breaks 1-1 11 < ?
  15. Incremental backups — v17 pg_basebackup, pg_combinebackup Full backup Incremental backup

    Incremental backup } Full backup pg_combinebackup fl attens a stack of incremental backups into a new full backup Combined backup can even share disk blocks on COW
  16. Shared memory cumulative stats system pg_stat_* views, pg_statio_* views, etc

    /path/to/bin/postgres -D pgdata ├─ postgres: checkpointer ├─ postgres: background writer ├─ postgres: walwriter ├─ postgres: autovacuum launcher ├─ postgres: logical replication launcher ├─ postgres: stats collector ├─ postgres: myuser mydb [local] idle ├─ postgres: myuser mydb [local] idle └─ postgres: myuser mydb [local] idle Receives updates via a UDP packet, writes total set of statistics to a fi le /path/to/bin/postgres -D pgdata ├─ postgres: checkpointer ├─ postgres: background writer ├─ postgres: walwriter ├─ postgres: autovacuum launcher ├─ postgres: logical replication launcher ├─ postgres: myuser mydb [local] idle ├─ postgres: myuser mydb [local] idle └─ postgres: myuser mydb [local] idle } Backends would would read a copy of the statistics fi le into memory } Backends now share a single set of statistics in shared memory, persisted to disk periodically V14 V15
  17. Skip scan for btree indexes CREATE TABLE address (id int

    primary key, state text, city text, …); CREATE INDEX ON address (state, city); SELECT … FROM address WHERE state = ? AND city = ? SELECT … FROM address WHERE city = ? WHERE clause matches index keys WHERE clause lacks initial index key, but planner considers skipping to each state value, which might be cheap enough for low
  18. Disk I/O Reading data in v16 with ReadBu ff er()

    8KB pread() system call: PostgreSQL bu ff er pool: Kernel page cache: Storage device: DMA transfer: Memory wasted on two copies of cached data Best case: accessing data already in buffer pool Second best case: it’s in the page cache, so pread() copies it out Worst case: pread() has to sleep waiting for transfer to fi nish Relying on kernel to detect patterns and generate larger physical I/Os
  19. Disk I/O Reading data in v17 using a “read stream”

    Large pread() system call: PostgreSQL bu ff er pool: Kernel page cache: Storage device: DMA transfer: Memory still wasted on two copies of cached data Stream collects adjacent fi le blocks into larger system calls, up to io_combine_limit Stream provides systematic fadvise() hints to arrange for blocks to feed cache, hoping to avoid stalls
  20. Disk I/O Reading data in v17 using a “read stream”

    Large pread() system call: PostgreSQL bu ff er pool: Kernel page cache: Storage device: DMA transfer: With experimental direct I/O mode enabled: No more double buffering, transfer is done by DMA hardware, but… now we always stall waiting for it! Direct I/O is an optimisation AND a pessimisation! Unless…
  21. Disk I/O Reading data in v18 with AIO Large asynchronous

    reads: PostgreSQL bu ff er pool: Kernel page cache: Storage device: DMA transfers: With experimental direct I/O mode enabled: Stream drives N background reads ahead of time, avoiding stalls ahead of time Stream drives multiple background reads ahead of time to avoidi stalls
  22. Disk I/O Executor avoids stalls and copying DMA SELECT COUNT(*)

    bu ff er pool Video credit: Wallace & Gromit “The Wrong Trousers”, 1993, by Aardman
 Cycle loop from giphy.com /path/to/bin/postgres -D pgdata ├─ postgres: io worker worker: 0 ├─ postgres: io worker worker: 1 ├─ postgres: io worker worker: 2 ├─ postgres: checkpointer ├─ postgres: background writer ├─ postgres: walwriter ├─ postgres: autovacuum launcher ├─ postgres: logical replication launcher └─ postgres: myuser mydb [local] SELECT io_method=worker io_method=io_uring /path/to/bin/postgres -D pgdata ├─ postgres: checkpointer ├─ postgres: background writer ├─ postgres: walwriter ├─ postgres: autovacuum launcher ├─ postgres: logical replication launcher └─ postgres: myuser mydb [local] SELECT } Running synchronous I/Os Queues up I/O requests for workers Queues up I/O requests in kernel
  23. Disk I/O Progress converting parts of PostgreSQL to the new

    I/O APIs • V17 • Sequential scans • ANALYZE • pg_prewarm • V18 • VACUUM • CREATE DATABASE • Bitmap Heap Scan • WIP • Index scans (many) • Writes… • WAL… • Network…?
  24. EOF