-
Notifications
You must be signed in to change notification settings - Fork 6
extra_Indexing
Andrei Lepikhov edited this page Jan 8, 2026
·
2 revisions
To reflect the high volume of filtered tuples, it makes sense to add indexes:
================================================================================
CREATE INDEX STATEMENTS
================================================================================
CREATE INDEX aka_name_idx_1 ON aka_name (info);
CREATE INDEX aka_name_idx_2 ON aka_name (name);
CREATE INDEX movie_info_idx_idx_1 ON movie_info_idx (info);
CREATE INDEX title_idx_1 ON title (production_year);
CREATE INDEX movie_companies_idx_1 ON movie_companies (country_code);
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE INDEX idx_movie_companies ON movie_companies USING gin (note gin_trgm_ops);
CREATE INDEX cast_info_idx_1 ON cast_info USING gin (note gin_trgm_ops);
CREATE INDEX idx_movie_info ON movie_info USING gin (info gin_trgm_ops);
CREATE INDEX keyword_idx_1 ON keyword USING gin (keyword gin_trgm_ops);
CREATE INDEX info_type_idx_1 ON info_type USING gin (info gin_trgm_ops);
CREATE INDEX company_name_idx_1 ON company_name USING gin (country_code gin_trgm_ops);
================================================================================
Total: 20 CREATE INDEX statements
================================================================================
/*
-- Suspicious cases:
-> Parallel Seq Scan on aka_name an (cost=0.00..14212.70 rows=170114 width=4) (actual time=0.035..54.332 rows=134938 loops=5)
Filter: (name ~~ '%a%'::text)
*/