here is the query I am stuck with:
SELECT *
FROM customers
WHERE salesmanid = @salesrep
OR telephonenum IN (SELECT telephonenum
FROM salesmancustomers
WHERE salesmanname = @salesrepname)
ORDER BY customernum
It is SLOW and crushing my CPU at 99%. I know an index would help but not sure what kind or if it should be 2 indexes or 1 with both columns included.
Three indexes probably each on a single column. This is assuming that your queries are all quite selective relative to the size of the tables.
It would help if you told us what your table schemas are along with details of existing indexes (Your PKs will get a clustered index by default if you don’t specify otherwise) and some details about size of tables / selectivity.
Customers
SalesmanCustomers