I have two tables: orders and order_lines. I need a fast, inexpensive way to display a count for orders that are going to be shipping today.
The order_lines table is associated with the orders table view a foreign key based on order id. A line is shippable if the shipped field > 0.
An order is "shippable" if any of its lines have a qty of shipped.
Right now I basically have a query that reads through the orders, then through the lines (via sqlalchemy in python), and then if any of the lines can be shipped a counter is incremented. This works but it is very slow.
Is there some way on the database side or can create something to speed this up?