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 public."Booking"(
"Id" int generated by default as identity primary key);
insert into public."Booking" values (default),(default),(default)
returning *;
CREATE TABLE
Id |
---|
1 |
2 |
3 |
INSERT 0 3
alter table public."Booking" drop column if exists "LinkedBookings";
alter table public."Booking" add column "LinkedBookings" int[];
update public."Booking" b set "LinkedBookings" = ('{'||"Id"::text||'}')::int[]
returning *,pg_typeof("LinkedBookings");
ALTER TABLE
ALTER TABLE
Id | LinkedBookings | pg_typeof |
---|---|---|
1 | {1} | integer[] |
2 | {2} | integer[] |
3 | {3} | integer[] |
UPDATE 3
update public."Booking" b set "LinkedBookings" = (ARRAY["Id"])::int[]
returning *,pg_typeof("LinkedBookings");
Id | LinkedBookings | pg_typeof |
---|---|---|
1 | {1} | integer[] |
2 | {2} | integer[] |
3 | {3} | integer[] |
UPDATE 3
alter table public."Booking" drop column if exists "LinkedBookings";
alter table public."Booking" add column "LinkedBookings" int[]
generated always as ((ARRAY["Id"])::int[]) stored;
--no update necessary
select *,pg_typeof("LinkedBookings") from public."Booking";
ALTER TABLE
ALTER TABLE
Id | LinkedBookings | pg_typeof |
---|---|---|
1 | {1} | integer[] |
2 | {2} | integer[] |
3 | {3} | integer[] |
SELECT 3