Why is DEFAULT much faster than UPDATE?

2022-08-10 Thread André Hänsel
This question is out of curiosity, just to learn more about the internals of PostgreSQL. The goal was to add a not null bool column filled with "false", but with "true" as the default for new rows. The naïve approach would be: ALTER TABLE foo ADD COLUMN slow bool NOT NULL DEFAULT true; UPDATE foo

RE: Issues with upserts

2022-07-13 Thread André Hänsel
Jeremy Smith wrote: It sounds like you aren't adding a WHERE clause to prevent the duplicate rows from being updated. It would help if you could share your query, but in general this could look like this: INSERT INTO my_table (col1, col2) SELECT col1, col2 FROM other_table ON CONFLICT

Issues with upserts

2022-07-13 Thread André Hänsel
The wiki entry https://wiki.postgresql.org/wiki/UPSERT kind of suggests that with the introduction of ON CONFLICT DO UPDATE the problem of upserts is solved. But is it? A common use case for upserts is to keep a table up to date from an external data source. So you might have a cron job that ru

RE: How to use pg_waldump?

2020-05-01 Thread André Hänsel
Paul Förster wrote: > strange. Bug? I don't know. > > What is your PostgreSQL version? Mine is 12.2 compiled from source on the > machine it runs on. 11.7-2.pgdg18

RE: How to use pg_waldump?

2020-05-01 Thread André Hänsel
Paul Förster wrote: > maybe try with another WAL file or files? > > Works for me... Ok, I tried it with all the files in the pg_wal directory and it worked with one: the first one (lexicographically/hex).

RE: How to use pg_waldump?

2020-05-01 Thread André Hänsel
Paul Förster wrote: > try: > > pg_waldump -p /var/lib/postgresql/11/main/pg_wal [] > > where is the name of the WAL file to start and (optionally) > is the WAL file to stop. It reads and shows all information of the > WAL files in this range. Picking a random WAL file and running the comma

How to use pg_waldump?

2020-05-01 Thread André Hänsel
I’m using pgBackRest for incremental backups which, as far as I understand, use the WAL. These backups are relatively large, so I wanted to take a look at my WAL. I understand pg_waldump is the tool for this. However, I struggle with its usage. The --help output suggests all command line paramete