× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



So if I've got this right, the order/invoice table has the order id, a
salesrep id, and the customer id (among other stuff). The customer table
has the customer id and the territory id. The fast SQL is something
along the lines of:

SELECT * FROM orders WHERE salesrep = 12345

And the "slow" sql is along the lines of:

SELECT orders.* FROM orders
JOIN customer
ON order.customerid = customer.customerid
AND customer.territory = 'EAST'


Do you have an index on customer & territory? I'd love to see the visual
explain of this query. An index on customer by id and territory should
be a covering index preventing the trip to the customer physical (unless
you're getting customer info too)

-Walden


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.