Query taking too long to execute My query takes a lot of time, 22 seconds and above. After 22 seconds, we get more than 900 000 records. We have created indexes on the table which are used in the query:

select * from ContactMaster 
where ContactId in (
    select  ContactId 
    from ListContactMaster 
    where ListMasterID in (816,975,945) 
    and ContactId not in (
        select  ContactId 
        from ListContactMaster 
        where ListMasterID in (0)
    ) and (
        isactive='true' 
        or isactive is null
    )
) 
and isactive = 'true' 
and (
    isdeleted='false' 
    or isdeleted is null
) 
and emailaddress not in (
    select emailaddress 
    from supresscontacts
)
and ContactMaster.ContactId not in (
    select DomineSupress.contactid 
    from DomineSupress 
    where DomineSupress.CampaignId=1186 
)


Indexes: 


IX_ListContactMaster_ContactId, 
IX_ListContactMaster_IsActive_ContactId, 
IX_ListContactMaster_ListMasterID, 
IX_ListContactMaster_ListMasterID_ContactId,
IX_ContactMaster_ContactId_IsActive_IsDeleted


The ContactMaster table has more than 50 fields.
You should use joins to reduce lookups between tables and to make better using of indexes during query the data. As expecting your query on relational tables I suggest a pattern as follows.

SELECT CM.* from ContactMaster CM 
INNER JOIN ListContactMaster LCM ON CM.ContactId=LCM.ContactId
LEFT JOIN supresscontacts SC ON CM.ContactId=SC.ContactId
LEFT JOIN DomineSupress DS ON CM.ContactId=DS.ContactId
WHERE SC.emailaddress IS NULL AND DS.contactid IS NULL AND DS.CampaignId=1186 AND LCM.ListMasterID IN (816,975,945)
AND LCM.ListMasterID &lt;&gt; 0 AND (LCM.isactive='true' OR LCM.isactive IS NULL)
AND CM.isactive = 'true' AND (CM.isdeleted='false' or CM.isdeleted is null)


Hope it will help you to make your query better.