BAQ Adapter ExecuteByID performance Issue

Hey,

I have a very complex BAQ that returns roughly 7K records without any filters in 1.15 mins, and with the filters of reqDate between (01/01/2021 to 31/01/2021), it usually takes 30 to 40 seconds to return 3400 rows. Everything is fine up to this point, however, as soon as I call the BAQ with the same date range from customization using the BAQ adapter method ExecuteByID, it takes around 11 mins to get 3400 rows. But if I call the same BAQ from customization it only takes 2 mins to load all the (7K) rows.
Secondly, the same BAQ works fine if used in a dashboard.

I failed to understand why the BAQ parameters are creating a performance issue when the BAQ itself runs fine. @josecgomez, @Bart_Elia can you guys please advise if there is something I can do to improve the performance. This is the first time I have come across such an issue.

Thanks
Mateen

Not sure as to why the performance difference exists for your two scenarios, but i came into some inconsistency issues with general performance. Perhaps it could be of benefit.

Many thanks for your response @cfinley. However, I have fixed the issue by moving out OrderNum and CustID parameters to table criteria instead of Sub Query criteria. Don’t know why it really matters though.

Sounds like the BAQ was running your query like the first query instead of the second. Every result was being returned in the table before the criteria was applied. Effectively pulling back unnecessary rows then filtering them out.

SELECT S1.*
FROM (SELECT T1.* FROM Erp.Table T1) S1
WHERE S1.FieldName = ''

SELECT T1.*
FROM Erp.Table T1
WHERE T1.FieldName = ''