You don't need to refresh all the data with a materialized view if you don't want to:
Original Message:
Sent: Wed October 27, 2021 08:19 AM
From: CHRISTOPHER WESTFALL
Subject: SQL Window Functions: Rollup WO costs (including tasks)
User1971,
I haven't played with formulas much but you can pull related data so it might be possible to do that to populate the value directly using a formula.
I do like using material views sometimes, but wouldn't use them for your use case due to the following reasons:
- Refreshing a view refreshes all the data in the view and is a huge consumption of resources. For your use case, the underlying data is changing constantly, so you can't use that as a trigger. Your only real scheduling option would be to schedule the refresh it at a set interval (e.g. - once a night), but still that's a huge waste of system resources and it creates up to a 24 hour lag in value.
- You could reduce the amount of data in the view (e.g. - last 12 months), but then that makes the use of the view extremely limited
------------------------------
CHRISTOPHER WESTFALL
Original Message:
Sent: Wed October 27, 2021 01:53 AM
From: User1971
Subject: SQL Window Functions: Rollup WO costs (including tasks)
@Christopher Westfall
Another option would be to use materialized views in Oracle. They're pretty easy to set up when they only reference data within the same database. It gets harder/riskier when they involve data in other databases (via dblinks).
The materialized view could be set up to update on a schedule -- or even update when the underlying tables are updated (live updates).
Related info here: Precompute data for BIRT reports?
Original Message:
Sent: Tue October 26, 2021 09:23 AM
From: User1971
Subject: SQL Window Functions: Rollup WO costs (including tasks)
@Christopher Westfall
Thanks. Good points.
Additionally, I wonder if asynchronous attribute formulas might also be an option worth considering?
In a different post, @Steven Shull talks about how asynchronous automation scripts work: Run asynchronous tasks from automation scripts (new in 7.6.1.2?)
"This allows you to ensure these background tasks aren't running on the UI JVM. If these processes are resource intensive in WebSphere, it can negatively impact the experience for your other users who were on that JVM/server."
I know asynchronous automation scripts are not the same thing as asynchronous attribute formulas. But I wonder if that explanation still applies -- and is useful for explaining the benefit of running jobs asynchronously.
More info here:
Also, a while back, @Steve Hauptman and I had brainstormed about this requirement in general. Here are some assorted notes:
- Performance
- Update conflict issues (update contention). We need a way to control the event that triggers the formula so it is not constantly firing.
- How to know which WO to process?
- Those issues are the nature of your requirement and implementation, not specific to formulas. So, automation scripts and even Java would have issues if they were ran each time task costs were updated. So, we might need to use an alternative - like escalations to kickoff the process, maybe nightly. Of course there would still be the issue of "which WOs changed?".
- There is also the option of leveraging my view and maybe just use a basic SetValue action in escalation.
I don't think we found a solution that we really liked...yet.
Original Message:
Sent: Mon October 25, 2021 11:59 AM
From: CHRISTOPHER WESTFALL
Subject: SQL Window Functions: Rollup WO costs (including tasks)
User1971,
If the real goal here is to roll-up this data to make searching and reporting easier, it rarely needs to be real-time and a huge priority would be finding the solution that has minimal impact to overall system performance while people are actively trying to work with records.
I would suggest a much simpler approach. The following sql would give you a new roll-up for any work orders with changes in the past 2 days. (The change date is updated at either the work order or task level even when adding estimates or actuals.)
This would give you a much smaller set of data with changes that you could push into your extra fields on the work order table, or you could create a new table just for these costs and populate it with this query once a day (after the initial population.)
select ORGID, SITEID, WOGROUP, SUM(ESTLABCOST) as ESTLABCOST_TI, SUM(ESTMATCOST) as ESTMATCOST_TI, SUM(ESTSERVCOST) as ESTSERVCOST_TI, SUM(ESTTOOLCOST) as ESTTOOLCOST_TI, SUM(ACTLABCOST) as ACTLABCOST_TI, SUM(ACTMATCOST) as ACTMATCOST_TI, SUM(ACTSERVCOST) as ACTSERVCOST_TI, SUM(ACTTOOLCOST) as ACTTOOLCOST_TIfrom WORKORDERwhere EXISTS ( SELECT 1 FROM WORKORDER W2 WHERE W2.CHANGEDATE > SYSDATE - 2 AND W2.WOGROUP = WORKORDER.WOGROUP )group by ORGID, SITEID, WOGROUP
------------------------------
CHRISTOPHER WESTFALL
Original Message:
Sent: Sun September 19, 2021 11:21 PM
From: User1971
Subject: SQL Window Functions: Rollup WO costs (including tasks)
MAM 7.6.1.2; Oracle 19c:
I want to use SQL window functions/analytic functions to query for WO costs including task costs.
#Maximo
#AssetandFacilitiesManagement