On 28th of March 2022, Alvaro Herrera committed patch:
Add support for MERGE SQL command
MERGE performs actions that modify rows in the target table using a
source table or query. MERGE provides a single SQL statement that can
conditionally INSERT/UPDATE/DELETE rows -- a task that would otherwise
require multiple PL statements. For example,
MERGE INTO target AS t
USING source AS s
ON t.tid = s.sid
WHEN MATCHED AND t.balance > s.delta THEN
UPDATE SET balance = t.balance - s.delta
WHEN MATCHED THEN
WHEN NOT MATCHED AND s.delta > 0 THEN
INSERT VALUES (s.sid, s.delta)
WHEN NOT MATCHED THEN
MERGE works with regular tables, partitioned tables and inheritance
hierarchies, including column and row security enforcement, as well as
support for row and statement triggers and transition tables therein.
MERGE is optimized for OLTP and is parameterizable, though also useful
for large scale ETL/ELT. MERGE is not intended to be used in preference
to existing single SQL commands for INSERT, UPDATE or DELETE since there
is some overhead. MERGE can be used from PL/pgSQL.
MERGE does not support targetting updatable views or foreign tables, and
RETURNING clauses are not allowed either. These limitations are likely
fixable with sufficient effort. Rewrite rules are also not supported,
but it's not clear that we'd want to support them.
Author: Pavan Deolasee <firstname.lastname@example.org>
Author: Álvaro Herrera <email@example.com>
Author: Amit Langote <firstname.lastname@example.org>
Author: Simon Riggs <email@example.com>
Reviewed-by: Peter Eisentraut <firstname.lastname@example.org>
Reviewed-by: Andres Freund <email@example.com> (earlier versions)
Reviewed-by: Peter Geoghegan <firstname.lastname@example.org> (earlier versions)
Reviewed-by: Robert Haas <email@example.com> (earlier versions)
Reviewed-by: Japin Li <firstname.lastname@example.org>
Reviewed-by: Justin Pryzby <email@example.com>
Reviewed-by: Tomas Vondra <firstname.lastname@example.org>
Reviewed-by: Zhihong Yu <email@example.com>
Continue reading Waiting for PostgreSQL 15 – Add support for MERGE SQL command
On 22nd of March 2022, Dean Rasheed committed patch:
Add support for security invoker views.
A security invoker view checks permissions for accessing its
underlying base relations using the privileges of the user of the
view, rather than the privileges of the view owner. Additionally, if
any of the base relations are tables with RLS enabled, the policies of
the user of the view are applied, rather than those of the view owner.
This allows views to be defined without giving away additional
privileges on the underlying base relations, and matches a similar
feature available in other database systems.
It also allows views to operate more naturally with RLS, without
affecting the assignments of policies to users.
Christoph Heiss, with some additional hacking by me. Reviewed by
Laurenz Albe and Wolfgang Walther.
Continue reading Waiting for PostgreSQL 15 – Add support for security invoker views.
Just got information that PGDay.PL is postponed till 4th quarter of 2022. This is due to situation in Ukraine. Figured I'll let you know, given that I previously wrote about it.
Autovacuum was added LONG time ago (in 7.4, as pg_autovacuum). Since then, there were many changes related to it.
These days, hopefully, we no longer see someone saying that they have to disable autovacuum due to performance issues.
But I still see people that say that they have to run daily/weekly vacuum because “autovacuum is not enough". Is it really?
Continue reading Is my autovacuum configured properly?
As of now, explain.depesz.com will provide hints for seq scans with multiple equality conditions joined with AND.
select * from table where proj_type = 'GR14' AND week = 2000 AND pop_flag = '1'
You can see it in action in this plan.
Hope you'll find it useful.
Someone asked recently on Slack, whether one should build tsvector data in a field, and index it, or make index on expression.
We talked about it for a while, and I thought I'll reformat my thoughts into blogpost to avoid retyping it next time.
Continue reading How to index data with tsearch?
Following is text provided by organizers. On my end I can say that I'll be there, and I'm on “Talk selection team" 🙂
The first ever Polish PostgreSQL conference is approaching faster than we think.
On April 22, 2022, we invite you to spend the whole day gaining top technical knowledge and broadening your horizons. PGDayPL 2022 is a great gaining opportunity to talk to the amazing speakers and spend time in the accompaniment of what we are most passionate about.
The conference is held at the POLIN Conference Center in Warsaw's Muranów.
What can you expect?
- fantastic lectures where you will gain technical knowledge – in both Polish and English!
- panels led by people with a passion for PostgreSQL and IT
- gifts for all conference attendees and additional bonuses for our speakers
- delicious catering for guests
- integration meeting after a successful conference
Learn more: https://pgday.pl/.
I just pushed change to explain.depesz.com that allows for processing and displaying hints for plans.
For example, take a look at this plan, and check if you'll notice subtle “HINTS" tab.
In there you will see example hints – one about sort and memory, and the other about missing index.
It is not much, but it's a step in (hopefully) right direction, when the explain tool will also provide, automatically, some ideas on what to do to make the thing faster.
Hope you'll find it useful.
Lately there have been couple of discussions on IRC, Slack, and Reddit that showed that people assume that by using int4/integer they use 4 bytes less than they would in case of int8/bigint. This is not really the case. Let me explain why.
Continue reading How much disk space you can save by using INT4/INT instead of INT8/BIGINT?
On 3rd of February 2022, Robert Haas committed patch:
Allow archiving via loadable modules.
Running a shell command for each file to be archived has a lot of
overhead and may not offer as much error checking as you want, or the
exact semantics that you want. So, offer the option to call a loadable
module for each file to be archived, rather than running a shell command.
Also, add a 'basic_archive' contrib module as an example implementation
that archives to a local directory.
Nathan Bossart, with a little bit of kibitzing by me.
Continue reading Waiting for PostgreSQL 15 – Allow archiving via loadable modules.