I have a SQL query like the one below. The database tables are not indexed and unfortunately I cannot do anything about it. In the application using this query I have experienced sporadic SQL timeouts.
When such a timeout was happening I used LinqPad to execute the exact same query with the same parameters
and it also timed out. Although tableA and tableB were accessible and when I removed one of the output columns the query worked fine.
What can cause this behavior and what can I do about it? Thanks.
SELECT 
    a.ID, 
    a.NAME,
    b.VALUE 
FROM 
    tableA as a
INNER JOIN 
    tableB bb 
ON 
    bb.OWNER = a.ID
INNER JOIN 
    tableB as b 
ON 
    b.OWNER = bb.ID 
WHERE
    a.OWNER = '1234567890' 
    AND b.NAME = 'XYZ' 
ORDER BY
    b.VALUE
 
    