Query timing out

I have the below query to load my csv

Blockquote
query = “MERGE (dns:DNSAddress {name: “%s”, category_id: %d, id: %d})
MERGE (p:Policy {name:”%s"})
MERGE (dns)-[:HAS {id:dns.id}]->(p)
WITH p, dns, split("%s", ‘,’) as rules
UNWIND rules as rule
MERGE (r:Rule {name:rule})
MERGE (p)-[r1:WITH {id: dns.id, risk_level: %d, reputation: %d, confidence: %d}]->(r)"
% (dnsaddress,categoryid, i+count, policy, rule_name, risk_level, reputation_score, confidence_level)

So my schema has 130K DNSAddress nodes, 3 Policy nodes and 3 Rules, (HAS) relationship count is 130K and (WITH) relationship count is 193K
I have created indexes on DNSAddress(category_id) and DNSAddress(name)

Now, I need to find DNSAddress with category_id = 118 which have risk_level > 2

So, I am running the below query

Blockquote
MATCH (d:DNSAddress)-[r1:HAS]->(p:Policy)-[r2:WITH]->(r:Rule)
WHERE r2.risk_level > 2 AND d.category_id=118
RETURN DISTINCT d

This query always times out?
What am I doing wrong here?
Also, I have noticed previously that whenever I have (a)-[:R1]->(b)-[:R2]->(c) kind of relations, my queries take a hell lot of time to execute.
How to solve this issue?

Update:
Another query which I tried is

Blockquote
MATCH (d:DNSAddress {category_id: 118})-[r1:HAS]->(p:Policy)
WITH COLLECT(d) as address, p
UNWIND address as dns
MATCH (p)-[r2:WITH]->(r:Rule)
WHERE r2.risk_level > 2
RETURN DISTINCT d

This query also got timed out