I need help optimizing the following query.
MATCH (p:Program)-[ao:AIRS_ON]->(t:Timeslot) WITH p, min(t.gmtDateTime) as minTs MATCH (p1:Program)-[ao1:AIRS_ON]->(t1:Timeslot) WHERE t1.gmtDateTime = minTs RETURN p1,t1,minTs ORDER BY t1.gmtDateTime LIMIT 100
There is an index on :Timeslot.gmtDateTime, but the query is still taking a couple minutes to run on a 16G 4 core EC2 instance.
In laymans terms I'm trying to get a list of Programs and the Timeslot with the earliest airDate for that program.
My database currently has about 1.6 million (:Program)-[:AIRS_ON]->(:Timeslot) relationships so it is somewhat large but not huge, and currently only contains about 5% of the final database size.
Any help would be appreciated.