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 Prix (rank integer primary key, value bigint unique);
CREATE TABLE
create table Pris (rank integer primary key, value bigint unique);
CREATE TABLE
INSERT INTO Prix
("rank", "value")
VALUES
(1, 1229),
(2, 1993)
;
INSERT 0 2
INSERT INTO Pris
("rank", "value")
VALUES
(1, 2719),
(2, 3547)
;
INSERT 0 2
INSERT INTO Prix
SELECT
ROW_NUMBER() OVER(ORDER BY "rank") + ( SELECT MAX("rank") FROM Prix),
"value"
FROM Pris ON CONFLICT DO NOTHING;
INSERT 0 2
SELECT * FROM Prix
rank | value |
---|---|
1 | 1229 |
2 | 1993 |
3 | 2719 |
4 | 3547 |
SELECT 4