Anybody able to give me some pointers on this one please - this BAQ in E10.2.300 never runs, it times out. BUT, take the same SQL code generated by the BAQ and run it in SSMS and it runs in less than a second, and returns 214 rows.
select
[Part].[PartNum] as [Part_PartNum],
[Part].[PartDescription] as [Part_PartDescription],
[PartPlant].[Number01] as [PartPlant_Number01]
from Erp.Part as Part
inner join Erp.PartPlant as PartPlant on
Part.Company = PartPlant.Company
and Part.PartNum = PartPlant.PartNum
where (Part.PartNum in (select OrderDtl_PartNum from (select distinct
[OrderDtl].[PartNum] as [OrderDtl_PartNum]
from Erp.OrderDtl as OrderDtl
where (OrderDtl.Company = 'BVD' and OrderDtl.RequestDate > @StartDate and OrderDtl.RequestDate < @EndDate)) as OrderDtl))
order by Part.PartNum
If you re-write the query one portion at a time, does it work until a certain point?
I had this happen in an environment and support was never able to help diagnose the root cause.
This also runs very quick, < 1 sec (but is obviously only returning 2 records)
select
[Part].[PartNum] as [Part_PartNum],
[Part].[PartDescription] as [Part_PartDescription],
[PartPlant].[Number01] as [PartPlant_Number01]
from Erp.Part as Part
inner join Erp.PartPlant as PartPlant on
Part.Company = PartPlant.Company
and Part.PartNum = PartPlant.PartNum
where (Part.PartNum in ('ACA005KA', 'NYC005KZ'))
For whatever reason Epicor doesnāt like the where clause, but SSMS laps it up.
The 2 executions plans are slightly different. They both suggest a missing Index, as follows:
E10 - wants OrderDtl with Company, PartNum, RequestDate
SSMS - wants OrderDtl with Company, RequestDate (and INCLUDES PartNum)
Does that help, or is there something else I can see on the query plans? Iām not considering adding any index, because even though SSMS suggests it the query runs in < 1 sec anyway!
The query displayed in the BAQ screen is not what is ran in reality. Add a filter on Part.Company in the top query and it should help fixing your issue.
Indeed - the suggested missing index is now the same.
General question on execution plans then - I normally just look for the missing index bit, is there anything else that you āreadā into the plan result?
Can this go as an enhancement to BAQ execution?
Seem odd, but Iāve had a few BAQs that o have to add an innocuous filter to speed execution but orders of magnitude.
Just created a BAQ that had a criteria of Company = CurrentCompany. Took 350ms to run, set the criteria to Company= āTTā and it ran in just over 50! What theā¦time for a bit of a trace I guess. Canāt understand how CurrentCompany isntāt the same as āTTā.