SELECT customer_id FROM customers WHERE cust_balance != (select coalesce(sum(balance_due), 0) FROM invoice WHERE status='Active' AND invoice.customer_id = customers.customer_id)
The above query is used to determine if any stored balances are out of date. It works very well but is *really* slow when the customer and invoice tables get into the thousands of rows. Is there a better way to accomplish the same thing, or some combination of indexes I can create to help speed that query up? Currently indexes are on the customer_id columns of both tables as well as the cust_balance field in customers. Thanks! -- - Mitchell _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users