select Max(ma.Coloumn2), mcp.column2 from Entity1 mr
JOIN Entity2 mcp on mr.column1 = mcp.column1
JOIN Entity3 ma on mcp.column1 = ma.column1
where mr.column3 = XXX GROUP by mcp.column2
I have a query mentioned above. In my Entity1 there are around 200,000 rows, in entity 3 there are 20k rows, in entity 2 there are only 40 rows.
This query executed in around 4 minutes in SQL, in LINQ it gives timeout exception. But when I rebuild the indexes of entity2 then it gives the result in micro seconds, and after 2-3 days problem occurs again and then I rebuild indexes then problem got away.
I am not able to determine the root cause of this issue. Can anyone help me with this?