I have two tables: Order Lines, Orders.
Orders table has a Status column, which is text. It can have values like 'Draft', 'Approved', 'Cancelled' etc. I need a query to return pending order lines for all approved orders. There is an index for pending lines in order Lines table, which performs quickly. When I add index on Status column for Orders, it is used while querying order table. When I join (left outer) Order Lines with Orders, and apply filter of Approved orders, index on Orders wouldn't be used, sequential scan on Orders is used instead.
It appears that the planner uses sequential scan, since most of the Orders have Approved status. This slows down the joined query. What is the best way to speed up this query?