Given a table of stores (~10k records) and a table of schedules(~200k records), I am trying to create and index for the planner to use, but it ignores it so far.
select * from stores str
inner join schedule sch on sch.store_id = str.store_id
where sch.open is true and sch.tables > 0
create index sch_open_tables_idx on schedule(open, tables) where open is true and tables > 0
Is there a correct way of doing this?
opencolumn in the index (it will always betrue), butstore_idmay be helpful (as the first column in that index). -- Also, you could just usewhere sch.openin both your query and index,is trueis not necessary (but won't hurt either, nullability doesn't change things here; it just feels noise).