I am having a performance issue with a SQL join query. The database has 50K objects and 15000 relationship objects. Here is the query: select * from table1 t1, table2 t2, relationships t3, table4 t4 WHERE ((t3.id = t4.id1 AND (t1.id = t3.id) ) OR (t1.id = t4.id2 AND (t3.id = 1))) AND t1.id = t2.id ORDER BY t4.id, d1.id The query does not complete even after several minutes. I've determined it has something to do with the OR condition. When creating 2 separate queries from the clauses of the OR condition, they run fine. But when doing UNION of those queries, the performance is still very slow. I tried converting the query to use JOIN/ON syntax but the result is the same. Table 'table1' has all the object data. It will also have some data from the relationship objects. Table 'relationships' has of course relations between objects. Table 'table4' is a 2 column table, each of BIGINT representing an Object Identifier. The first column has Relationship identifiers. The second column has Object identifiers. The goal is to get all the objects and it's relationships based on the objects in table 'table4'. Since objects that are not relationships will not exist in the relationships table, "t3.id = 1" in second clause of 'OR' was added to get back 1 row from join of table1 and relationships, otherwise you would end of up with cartesian product of all 'relationships' rows. Table 'table1' has a clustered index on column 'id'. Table 'relationships' has a non-clustered index on 'id' column. Any information will be appreciated.