I received a query with five joins on some fairly large tables (the largest table is 10 million records), and I want to know if rows exist. So far, I have been doing this to check if strings exist:
SELECT TOP 1 tbl.Id
FROM table tbl
INNER JOIN ... ON ... = ... (x5)
WHERE tbl.xxx = ...
Using this query, the stored procedure takes 22 seconds, and I would like it to be close to instant. Is it possible? What can I do to speed it up?
I have the indexes of the fields I am joining and the fields in the WHERE clause.
Any ideas?
source
share