Good morning,
I got an email from Epicor last week notifying me that two of my BAQs are long running and can affect system performance. They show a max and average time that is way higher than anything I regularly experience. I just went to try to optimize my BAQ, but it runs plenty fast. Is this a warning based on a test run that I might have done that took too long to respond?
Do you see anything in this BAQ that looks wrong? I know I am pulling over a hundred thousand lines of part trans, but it still runs fast in my experience.
This BAQ is called Planned FAIs. The goal is to look ahead at the orders we have, and then look back at the part transactions. MFG transactions in the last 2 years mean that we do not need to do a new First Article Inspection, anything older than 2 years mean we do need the FAI. This attempts to look ahead and quantify the potential sales value of orders with upcoming FAIs. It does the job alright for now.
/*
* Disclaimer!!!
* This is not a real query being executed, but a simplified version for general vision.
* Executing it with any other tool may produce a different result.
*/
select
[Orders].[OrderDtl_PartNum] as [OrderDtl_PartNum],
[PartTransactions].[PartTran_RevisionNum] as [PartTran_RevisionNum],
[Orders].[OrderDtl_UnitPrice] as [OrderDtl_UnitPrice],
(sum(Orders.Calculated_Remain)) as [Calculated_RemainToShip],
(Orders.OrderDtl_UnitPrice* RemainToShip) as [Calculated_RemainSOValue],
(min(Orders.OrderRel_ReqDate)) as [Calculated_NextRelDate],
[PartTransactions].[Calculated_LMD] as [Calculated_LMD],
[PartTransactions].[Calculated_NeedFAI] as [Calculated_NeedFAI]
from (select
[OrderHed].[Company] as [OrderHed_Company],
[OrderDtl].[OrderNum] as [OrderDtl_OrderNum],
[OrderDtl].[PartNum] as [OrderDtl_PartNum],
[OrderDtl].[RevisionNum] as [OrderDtl_RevisionNum],
[OrderRel].[ReqDate] as [OrderRel_ReqDate],
[OrderRel].[OurReqQty] as [OrderRel_OurReqQty],
(OrderRel.OurJobShippedQty+ OrderRel.OurStockShippedQty) as [Calculated_Shipped],
(OrderRel.OurReqQty- Shipped) as [Calculated_Remain],
[OrderDtl].[UnitPrice] as [OrderDtl_UnitPrice]
from Erp.OrderHed as OrderHed
inner join Erp.OrderDtl as OrderDtl on
OrderHed.Company = OrderDtl.Company
and OrderHed.OrderNum = OrderDtl.OrderNum
and ( OrderDtl.OpenLine = true )
inner join Erp.OrderRel as OrderRel on
OrderDtl.Company = OrderRel.Company
and OrderDtl.OrderNum = OrderRel.OrderNum
and OrderDtl.OrderLine = OrderRel.OrderLine
and ( OrderRel.OpenRelease = true )
where (OrderHed.OpenOrder = true)) as Orders
left outer join (select
[PartTran].[Company] as [PartTran_Company],
[PartTran].[PartNum] as [PartTran_PartNum],
[PartTran].[RevisionNum] as [PartTran_RevisionNum],
(max(PartTran.TranDate)) as [Calculated_LMD],
(iif(datediff(day, LMD, Constants.Today)>=730,1,0)) as [Calculated_NeedFAI]
from Erp.PartTran as PartTran
where (PartTran.TranType in ('MFG-CUS', 'MFG-STK'))
group by [PartTran].[Company],
[PartTran].[PartNum],
[PartTran].[RevisionNum]) as PartTransactions on
Orders.OrderHed_Company = PartTransactions.PartTran_Company
and Orders.OrderDtl_PartNum = PartTransactions.PartTran_PartNum
and Orders.OrderDtl_RevisionNum = PartTransactions.PartTran_RevisionNum
and ( PartTransactions.Calculated_NeedFAI >= 1 )
where (PartTransactions.Calculated_NeedFAI = 1)
group by [Orders].[OrderDtl_PartNum],
[PartTransactions].[PartTran_RevisionNum],
[Orders].[OrderDtl_UnitPrice],
[PartTransactions].[Calculated_LMD],
[PartTransactions].[Calculated_NeedFAI]
PlannedFAIs.baq (44.2 KB)




