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 t1(id SMALLINT GENERATED ALWAYS AS IDENTITY)
CREATE TABLE
CREATE TABLE t2(id INT GENERATED ALWAYS AS IDENTITY)
CREATE TABLE
CREATE TABLE t3(id BIGINT GENERATED ALWAYS AS IDENTITY)
CREATE TABLE
SELECT table_name, column_name, is_identity, identity_minimum, identity_maximum,*
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME IN('t1','t2','t3')
table_name | column_name | is_identity | identity_minimum | identity_maximum | table_catalog | table_schema | table_name | column_name | ordinal_position | column_default | is_nullable | data_type | character_maximum_length | character_octet_length | numeric_precision | numeric_precision_radix | numeric_scale | datetime_precision | interval_type | interval_precision | character_set_catalog | character_set_schema | character_set_name | collation_catalog | collation_schema | collation_name | domain_catalog | domain_schema | domain_name | udt_catalog | udt_schema | udt_name | scope_catalog | scope_schema | scope_name | maximum_cardinality | dtd_identifier | is_self_referencing | is_identity | identity_generation | identity_start | identity_increment | identity_maximum | identity_minimum | identity_cycle | is_generated | generation_expression | is_updatable |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
t1 | id | YES | 1 | 32767 | db_789773224 | public | t1 | id | 1 | null | NO | smallint | null | null | 16 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | db_789773224 | pg_catalog | int2 | null | null | null | null | 1 | NO | YES | ALWAYS | 1 | 1 | 32767 | 1 | NO | NEVER | null | YES |
t2 | id | YES | 1 | 2147483647 | db_789773224 | public | t2 | id | 1 | null | NO | integer | null | null | 32 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | db_789773224 | pg_catalog | int4 | null | null | null | null | 1 | NO | YES | ALWAYS | 1 | 1 | 2147483647 | 1 | NO | NEVER | null | YES |
t3 | id | YES | 1 | 9223372036854775807 | db_789773224 | public | t3 | id | 1 | null | NO | bigint | null | null | 64 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | db_789773224 | pg_catalog | int8 | null | null | null | null | 1 | NO | YES | ALWAYS | 1 | 1 | 9223372036854775807 | 1 | NO | NEVER | null | YES |
SELECT 3