version ------------------------------------------------------------------------------------------------------------------ PostgreSQL 13.4 (Debian 13.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit (1 row) CREATE TYPE CREATE TABLE CREATE INDEX INSERT 0 1000 INSERT 0 1000 INSERT 0 1000 INSERT 0 1 VACUUM QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------- Index Only Scan using table_test_enum_val_idx on public.table_test_enum (cost=0.12..4.14 rows=1 width=4) (actual time=0.014..0.016 rows=1 loops=1) Output: val Heap Fetches: 0 Planning Time: 0.436 ms Execution Time: 0.048 ms (5 rows) PREPARE PREPARE PREPARE QUERY PLAN ----------------------------------------------------------------------------------------------------------------- Seq Scan on public.table_test_enum (cost=0.00..66.52 rows=1 width=4) (actual time=1.131..1.133 rows=1 loops=1) Output: val Filter: ((table_test_enum.dat IS NULL) AND (table_test_enum.val = ('Ole'::cstring)::type_table_test_enum)) Rows Removed by Filter: 3000 Planning Time: 0.261 ms Execution Time: 1.162 ms (6 rows) QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------- Index Only Scan using table_test_enum_val_idx on public.table_test_enum (cost=0.12..4.14 rows=1 width=4) (actual time=0.023..0.026 rows=1 loops=1) Output: val Heap Fetches: 0 Planning Time: 0.256 ms Execution Time: 0.054 ms (5 rows) QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------- Index Only Scan using table_test_enum_val_idx on public.table_test_enum (cost=0.12..4.14 rows=1 width=4) (actual time=0.019..0.023 rows=1 loops=1) Output: val Heap Fetches: 0 Planning Time: 0.259 ms Execution Time: 0.051 ms (5 rows) DEALLOCATE DEALLOCATE DEALLOCATE DROP TABLE DROP TYPE