By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
create table config_versions(rolling_version_id int , config_id int , note varchar(100))
INSERT INTO config_versions(rolling_version_id, config_id, note)
SELECT coalesce(MAX(rolling_version_id)+1, 1),42,'SomeNote'
FROM config_versions
WHERE config_id=42
1 rows affected
select * from config_versions
rolling_version_id | config_id | note |
---|---|---|
1 | 42 | SomeNote |