Skip to content

FOUR-33159 POC Performance issue when opening the column configuration in a saved search - #9061

Draft
devmiguelangel wants to merge 7 commits into
developfrom
FOUR-33159
Draft

devmiguelangel wants to merge 7 commits into
developfrom
FOUR-33159

Conversation

@devmiguelangel

@devmiguelangel devmiguelangel commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Issue & Reproduction Steps

FOUR-33159 POC Performance issue when opening the column configuration in a saved search

Problem

Opening Columns on a Request Saved Search with fulltext PMQL (e.g. (fulltext LIKE "%test%")) took ~76s and could 500 with MySQL error 1038 (Out of sort memory).

Two independent bottlenecks were hit on every load:

  1. HasDataColumns::getData() re-executed the full Saved Search PMQL (including LOWER(data) LIKE '%test%') just to sample recent data JSON for column names.
  2. For unscoped (global fulltext) searches, SavedSearch::getProcessesAttribute() fell back to Process::get() (all processes) and then ran a recursive ExportManager screen walk per process, adding ~50s of PHP.

Solution

Column discovery no longer depends on the user's PMQL or on sort_buffer_size.

  • Bounded, PMQL-free samplingHasDataColumns::getData() now uses column_discovery_query (type base query, optionally scoped by process_id), orders by indexed id DESC, and limits to 10 rows. The fulltext clause is never applied. MySQL 1038 is caught and returns an empty sample instead of a 500.
  • Variable Finder instead of ExportManager — new ProcessVariableDiscoveryService resolves data.* fields from var_finder_variables (indexed) for both scoped and unscoped searches. Screen fallback uses ScreensInProcess (direct BPMN screenRef scan) capped to the 25 most recently updated processes, not the recursive export graph.
  • Separate pagination for available columnsGET /api/1.1/processes/variables?onlyAvailable= now paginates Saved Search available + data columns independently. Process variables load in a second phase. Empty processIds returns the unscoped catalog instead of an empty page. Active columns are excluded in SQL. Fixed a duplicate paginate() call in the controller.
  • CachingCache::flexible + lock + last-known-good for both the discovery service and data_columns, keyed on saved search / process / Variable Finder state.
  • FrontendVariablesList.vue pages available columns until meta.last_page, then switches to process variables. The edit screen no longer background-fetches every page.

Scope

  • Saved Search listing results are unchanged; scopeFilter() / valueAliasFullText() are untouched.
  • Task and Collection Saved Searches still resolve columns.
  • No MySQL configuration change is required.

Related Tickets & Packages

https://processmaker.atlassian.net/browse/FOUR-33159
https://github.com/ProcessMaker/package-savedsearch/pull/696

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.

ci:package-savedsearch:FOUR-33159

.

@devmiguelangel devmiguelangel self-assigned this Sep 15, 2026
@cursor

cursor Bot commented Sep 15, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes a hot API path used when editing saved-search columns, including pagination semantics and new caching; behavior is heavily tested but unscoped discovery may differ slightly from loading all processes via ExportManager.

Overview
Fixes slow/failing Saved Search column configuration by reshaping GET /api/1.1/processes/variables and centralizing how data.* fields are resolved.

onlyAvailable now paginates saved-search available + data columns on their own via getAvailableColumnsPaginator, instead of merging them into the process-variables page (which dropped fields and skewed totals). Empty processIds no longer returns an empty list; it uses unscoped discovery (Variable Finder or a bounded screen scan).

Adds ProcessVariableDiscoveryService: prefers indexed Variable Finder queries, falls back to ScreensInProcess (replacing recursive ExportManager walks), and wraps results in Cache::flexible with locks and last-known-good payloads. The controller excludes active saved-search columns in SQL for the finder path, orders by field, and on MySQL 1038 logs and falls back to screen-based discovery.

Feature tests cover fulltext saved searches with empty process IDs, multi-page onlyAvailable, active-column exclusion, no PMQL/LOWER scans for available columns, and sort-memory fallback.

Reviewed by Cursor Bugbot for commit c171a6e. Bugbot is set up for automated code reviews on this repo. Configure here.

…g pagination and variable filtering scenarios

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread ProcessMaker/Services/ProcessVariableDiscoveryService.php
Comment thread ProcessMaker/Http/Controllers/Api/V1_1/ProcessVariableController.php Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread ProcessMaker/Services/ProcessVariableDiscoveryService.php Outdated
@decisions-sonarqube

Copy link
Copy Markdown

@devmiguelangel
devmiguelangel marked this pull request as draft September 17, 2026 00:35
cursor[bot]

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant