Database Indexes
The database is the core of how process-automation works. The assumption is that queries will always be performant. As your applicationApplicationThe overarching model container grouping all components, domain logic, and configurations for an enterprise solution. gets larger, so will the amount of data flowing through it. The standard SQL provisioning does not declare any indexes. Once tables get large enough you may need them at some point. It is a good practice to add indexes on critical columns even when you currently do not encounter any performance issues.
ProcessAutomation Internals
The TaskJob dataElement manages a queue through its database connection. It has to fetch new jobs using a query,
which can cause a performance hit if the table gets large. Similarly, if you are using TimerJob a lot the table might
get large. It is recommended to add an index on status for both of these.
BatchJobs are managed by key which should also receive an index in case you manage many batches at once.
CREATE INDEX IF NOT EXISTS idx_task_job_priority
ON PROCESS_AUTOMATION.TaskJob (queue, priority DESC)
WHERE status = 'Queued';
CREATE INDEX IF NOT EXISTS idx_task_job_status
ON PROCESS_AUTOMATION.TaskJob (status);
CREATE INDEX IF NOT EXISTS idx_task_job_batch
ON PROCESS_AUTOMATION.TaskJob (batch_id)
WHERE batch_id IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_timer_job_active_timestamp
ON PROCESS_AUTOMATION.TimerJob (status, timestamp)
WHERE status = 'Active';
CREATE INDEX IF NOT EXISTS idx_batch_job_key
ON PROCESS_AUTOMATION.BatchJob (key)
WHERE key IS NOT NULL;
Status fields
The same issue can occur with any status fieldFieldA property of a DataElement expanded to a database column and user interface input element. which uses database queries for its updates (Schedule or FlowEngine). It is a best practice to add indexes to all status fieldsFieldA property of a DataElement expanded to a database column and user interface input element., even if they are currently unused. This ensures extending a workflow in the future will not suddenly cause performance issues.
Similar to the index on TaskJob, you can add an index on its status using the following query.
CREATE INDEX IF NOT EXISTS idx_schema_element_status
ON schema.Element (status);