I am having a very strange issue with a BAQ. Simple BAQ OrderRel-OrderDtl-OrderHed-Customer. Criteria is OrderRel is Open and a Make. Test, returns 2186 records in 1171ms. Add criteria to OrderRel for ReqDate >= a parameter date (From) and ReqDate <= a parameter date (To). Test, enter From 10/25 To 11/24 and it take 43 seconds to return 943 records. Change ReqDate to NeedByDate. Test and returns 1046 records in 1.9 seconds.
I run the query in LinqPad as a SQL query using the ReqDate and it runs in less than a second. I been looking if there was any type of odd values in ReqDate and do not see any. We re-index and intgritchecks weekly on the database.
Dragos, thanks, did a all those and we do update statistics. Ended up rebooting all our Epicor environment, still was slow using my test query. I removed all tables except for OrderRel and it ran as expected, very fast. Added OrderDtl (inner join) back and it ran fast, with using parameters. Change OrderDtl to first table, ran fast. Put my test query back the way it was when it was running slow, ran fast. Everything seems fine now, no real explanation why it is working now.