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 tablea (
id serial,
type_m text
);
CREATE TABLE tableb (
id serial,
type character varying(256),
string character varying(256)
);
-- This is done via view which basecally CAST tableb.type + tableb.string onto this type_m column
INSERT INTO tablea (type_m) VALUES ('image/jpg');
INSERT INTO tablea (type_m) VALUES ('image/jpeg');
INSERT INTO tablea (type_m) VALUES ('image/png');
INSERT INTO tablea (type_m) VALUES ('video/avi');
INSERT INTO tablea (type_m) VALUES ('video/avi');
INSERT INTO tableb (type,string) VALUES ('image','jpg');
INSERT INTO tableb (type,string) VALUES ('image','jpeg');
INSERT INTO tableb (type,string) VALUES ('image','png');
INSERT INTO tableb (type,string) VALUES ('video','avi');
INSERT INTO tableb (type,string) VALUES ('video','avi');
SELECT * FROM tablea;
1 rows affected
1 rows affected
1 rows affected
1 rows affected
1 rows affected
1 rows affected
1 rows affected
1 rows affected
1 rows affected
1 rows affected
id | type_m |
---|---|
1 | image/jpg |
2 | image/jpeg |
3 | image/png |
4 | video/avi |
5 | video/avi |