
Bruce Momjian Postgres Blog
133 FOLLOWERS
Bruce Momjian Postgres Blog
2w ago
I delivered my presentation Databases in the AI Trenches today as part of a tutorial at Prague PostgreSQL Developer Day, so I have placed my slides online. It focuses on semantic search, generative AI, and RAG, and builds on my discriminative AI talk, Postgres and the Artificial Intelligence Landscape. I will also be giving this talk on Saturday and the Tuesday after that ..read more
Bruce Momjian Postgres Blog
4M ago
I recently created a presentation about what I think are the most important areas of improvement in Postgres 17:
Incremental backup
Improved data manipulation
Improved optimizer handling
Improved logical replicas
Peter Eisentraut and I also did a webinar about this, and a recording is now available ..read more
Bruce Momjian Postgres Blog
4M ago
Over the years, we occasionally get requests for more detail on release note items, particularly for the major release notes. Historically, our only response was to tell people to view the SGML/XML file used to generate the web and PDF versions of the release notes. In the file, above each release note item, is a comment block which contains the commit headers responsible for the item, e.g.:
<!--
Author: David Rowley <drowley(at)postgresql(dot)org>
2024-01-23 [b262ad440] Add better handling of redundant IS [NOT] NULL quals
Author: David Rowley <drowley(at)postgresql(dot)org>
2 ..read more
Bruce Momjian Postgres Blog
10M ago
I have just completed the first draft of the Postgres 17 release notes. It includes developer community feedback but still needs more XML markup and links.
The release note feature count is 188. The most pleasant surprise for me was the large number of optimizer improvements. Postgres 17 Beta 1 should be released soon. The final Postgres 17 release is planned for September/October of this year ..read more
Bruce Momjian Postgres Blog
1y ago
C compilers do a great job of converting C to assembly language (optionally) and then to primitive CPU instructions. However, some CPU instructions are too specialized or too complex to map to the C language. For example, Postgres has used test and set assembly language CPU instructions for decades to provide good performance for high concurrency workloads. We have such CPU instructions for:
i386
x86_64/AMD64
ARM
S/390
Sparc, Sparc v7
PowerPC
MIPS
HP PA-RISC
Since 2014, Postgres has supported atomics, which provides test and set, compare and exchange, and atomic addition. We also use compile ..read more
Bruce Momjian Postgres Blog
1y ago
TIMESTAMPs are very precise and flexible in Postgres, but sometimes users want to do index lookups of TIMESTAMP values with less precision, i.e., by date. To illustrate this, let's create a sample table with 100k TIMESTAMP values:
CREATE TEMPORARY TABLE date_test (event_time TIMESTAMP WITH TIME ZONE);
INSERT INTO date_test
SELECT
(
SELECT '2023-03-01 00:00:00'::timestamptz +
(floor(random() *
(extract(EPOCH FROM '2023-04-01'::timestamptz) -
extract(EPOCH FROM '2023-03-01'::timestamptz)) +
b * 0)::integer || 'seconds')::interval
)
FROM gen ..read more
Bruce Momjian Postgres Blog
1y ago
The Postgres mailing lists are full of practical discussions, but two years ago there was a 77-email thread titled "The tragedy of SQL" that questioned the utility of the SQL query language; t is worth a review. While opening with "A fun philosophical discussion," it states:
The world's economic output would be substantially higher (5%?) if our industry had settled on almost anything other than SQL for relational databases.
It disparages object-relational mappers and suggests Datalog as an alternative query language ..read more
Bruce Momjian Postgres Blog
1y ago
When a single query is run outside of a transaction block, it is clear how transaction visibility should behave — only transactions committed before the query started should be visible. Changes made by other sessions during the query, even if committed during the query, should not be visible. Slide 11 of my MVCC Unmasked presentation illustrates this.
For queries run in transaction blocks, the ideal behavior is less clear, so Postgres supports three options for controlling transaction block behavior. The default, READ COMMITTED, causes each new query in a transaction block to get a new visibil ..read more
Bruce Momjian Postgres Blog
1y ago
LATERAL is a powerful SQL feature that allows virtual tables to be created in FROM clauses that reference real or virtual tables that appeared previously in the same FROM clause. Here is a simple example:
CREATE TABLE test (x) AS SELECT generate_series(1,3);
SELECT * FROM test AS test1 (x) JOIN LATERAL (SELECT test1.x + 1) AS test2 (x) ON (true);
xx
---+---
12
23
34 ..read more
Bruce Momjian Postgres Blog
1y ago
My common table expression (CTE) talk shows how CTEs can be used to combine individual queries into a single CTE query. This explores the downsides of such combinations, and when combining is unreasonable. Its conclusions are:
Queries combined into a CTE behave as though they were in a REPEATABLE READ transaction block
Changes made to table rows are not visible to other parts of the CTE
The most glowing report of CTE combining is from this saying, "I have yet to regret replacing a transaction with a CTE over the past decade ..read more