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 DEMO1(n integer);
CREATE TABLE
create table DEMO2(n integer);
CREATE TABLE
insert into DEMO1 values(42);
INSERT 0 1
alter table DEMO1 add unique(n);
ALTER TABLE
select * from DEMO1;
n |
---|
42 |
SELECT 1
select * from DEMO2;
n |
---|
SELECT 0
do $$
begin
insert into DEMO1 (n) values (1);
insert into DEMO1 (n) values (42);
exception when others then
insert into DEMO2 select * from DEMO1;
end;
$$ language plpgsql;
DO
select * from DEMO2;
n |
---|
42 |
SELECT 1