Yes they are querried so the db narrows down the results as fast as possible and pulls as many from one query as possible.
Here is an example of the 30 second query
Code:
$sql = "SELECT orders_id FROM ".TABLE_ORDERS." WHERE date_purchased < NOW() AND orders_status IN (" . implode(',',$statuses) . ") ORDER BY orders_id ASC";
Limit by date purchased first because that eliminates the majority of the table. Then limit by status.
Here is another one and yes I plan on changing the * to more specifics in the near future.
Code:
$sql = 'select * from ' . TABLE_ORDERS . ' o left join ' . TABLE_HTA . ' h ON o.orders_id = h.order_id WHERE o.date_purchased < NOW() AND o.shipping_module_code LIKE "%Flat%" AND h.status = "MADE" ORDER BY o.orders_id ASC';
This one again limits by date. Then limits by shipping module which cuts out 60% of the orders. Then the made is the lowest percentage of finds.
Bookmarks