Skip to main content
Solved

Rapid schedule query in IAM requires to much resources.

  • January 14, 2025
  • 2 replies
  • 69 views

J. de Lange
Hero
Forum|alt.badge.img+4

Hi, I’m currently running into performance problems caused by a scheduled system flow with a very rapid schedule (every second). This seems logical, we are running this code a lot so it stands to reason that it uses a lot of resources, except that the queries in our model executed by this flow, are extremely optimized. Our monitoring indicates that the query used by IAM to fetch the schedule for this flow in the stored procedure process_flow_schedule_start currently uses a ton of CPU time. So much so, that even with a slowed down schedule, it makes the top 3 most resource intensive queries run on the database server. 

User complained about a slow working application and we’ve had to slow down this flow which is a shame because this flow is really important for managing all our asynchronous API-calls and slowing down the schedule slows down a lot of processes for the users.

We would like to restore the rapid schedule. Using this rapid schedule is something that was recommended to us several times on this forum and I've seen posts of other users about fast schedules as well. It’s seems weird to me that nobody else has run into this problem before.
Is there something we can change to avoid this problem? I’ve considered making the flow loop instead of a rapidly restarting it but this doesn’t allow for multiple API calls to be executed simultaneously and some of the integrations are quite slow to respond.

The current fix I found was to change the stored procedure on the IAM database by making the process_flow_schedule_start query tables on the IAM databse instead of a view:

The original querying the view gui_appl_system_flow:

--control_proc_id:      proc_process_flow_schedule_start
--template_id:          proc_process_flow_schedule_start
--prog_object_item_id:  proc_process_flow_schedule_start
--template_description: 

declare 
    @model_id                           model_id,
    @branch_id                          branch_id,
    @schedule_id                        schedule_id,
    @multiple_running_instances_allowed no_yes

-- Find the currently active schedule for the pending flow
select 
    @model_id = f.model_id,
    @branch_id = f.branch_id,
    @schedule_id = f.schedule_id,
    @multiple_running_instances_allowed = f.multiple_running_instances_allowed
from gui_appl u 
join gui_appl_system_flow f
  on f.model_id = u.model_id
 and f.branch_id = u.branch_id
 and f.gui_appl_id = u.gui_appl_id
where u.gui_appl_id = @gui_appl_id
  and u.active = 1
  and f.process_flow_id = @process_flow_id

Changed to:

--control_proc_id:      proc_process_flow_schedule_start
--template_id:          proc_process_flow_schedule_start
--prog_object_item_id:  proc_process_flow_schedule_start
--template_description: 

declare 
    @model_id                           model_id,
    @branch_id                          branch_id,
    @schedule_id                        schedule_id,
    @multiple_running_instances_allowed no_yes

-- Find the currently active schedule for the pending flow
select
@model_id = s.model_id,
@branch_id = s.branch_id,
@schedule_id = iif(i.model_id is not null, i.schedule_id, s.default_schedule_id),
@multiple_running_instances_allowed = s.multiple_running_instances_allowed
from gui_appl g 
join sf_process_flow s
  on s.model_id = g.model_id 
 and s.branch_id = g.branch_id
left join iam_process_flow i
  on i.model_id = g.model_id
 and i.branch_id = g.branch_id
 and i.gui_appl_id = g.gui_appl_id
 and i.process_flow_id = s.process_flow_id
where g.gui_appl_id = @gui_appl_id
and g.active = 1
and s.process_flow_id = @process_flow_id
and s.is_system_flow = 1
and (     
    s.iam_custom_schedule_allowed = 1 -- The user can configure custom schedules
    or exists(                           -- There are schedules
        select 1
        from sf_process_flow_schedule o
        where o.model_id = g.model_id
          and o.branch_id = g.branch_id
          and o.process_flow_id = s.process_flow_id
    )
)


This hugely improves the performance of this query and fixes our problem but it’s far from ideal since we wouldn’t like to maintain code changes on procedures provided by Thinkwise and we may unknowingly break things. It may be profitable for Thinkwise to change this, if so what is the best way to request this? Via an idea on this forum, TCP or some other way?

Best answer by Mark Jongeling

Hey ​@J. de Lange,

Glad you were able to improve the performance this way.

Since the introduction of the proc_process_flow_schedule_start procedure in 2022.2, the view has been used since so it is a bit strange this suddenly causes performance degradation.

Feel free to create a TCP ticket for this so we can discuss it internally. Maybe the procedure code has to change like you shared, or maybe another solution can be thought of.

View original
Did this topic help you find an answer to your question?
This topic has been closed for replies.

2 replies

Mark Jongeling
Administrator
Forum|alt.badge.img+23
  • Administrator
  • 3945 replies
  • Answer
  • January 14, 2025

Hey ​@J. de Lange,

Glad you were able to improve the performance this way.

Since the introduction of the proc_process_flow_schedule_start procedure in 2022.2, the view has been used since so it is a bit strange this suddenly causes performance degradation.

Feel free to create a TCP ticket for this so we can discuss it internally. Maybe the procedure code has to change like you shared, or maybe another solution can be thought of.


J. de Lange
Hero
Forum|alt.badge.img+4
  • Author
  • Hero
  • 70 replies
  • January 14, 2025

This problem definitely isn’t new but it has gotten worse, perhaps because our IAM database is getting bigger. 
I’ll create a TCP, thanks ​@Mark Jongeling


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings