Skip to content

FOUR-27824 Slow query without indexes - #9100

Open
devmiguelangel wants to merge 4 commits into
developfrom
FOUR-27824
Open

devmiguelangel wants to merge 4 commits into
developfrom
FOUR-27824

Conversation

@devmiguelangel

@devmiguelangel devmiguelangel commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Issue & Reproduction Steps

The Saved Search index migration only recognized indexes by their canonical names. Environments with equivalent DBA-created indexes under different names could receive duplicate indexes. During rollback, index-drop errors were also swallowed, allowing canonical indexes used for foreign-key support to remain in place.

Solution

  • Detect existing indexes by ordered leading columns as well as canonical names.
  • Recognize the manually applied process_categories (is_system, id) index as covering process_categories (is_system).
  • Create a temporary migration-owned foreign-key index when rollback needs to remove a canonical index currently supporting a foreign key.
  • Remove temporary rollback indexes after the canonical indexes are restored.
  • Add migration coverage for creation, idempotency, equivalent manual indexes, and rollback behavior.

How to Test

Automated tests were not run per request. The focused coverage is in:

php artisan test tests/Feature/Migrations/AddSavedSearchIndexesTest.php

Related Tickets & Packages

FOUR-27824

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.

@cursor

cursor Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes migration DDL behavior (index detection, create/skip, and drop with FK replacement) on production tables; mistakes could affect query performance or constraint indexing during migrate/rollback.

Overview
Hardens the Saved Search index migration so it no longer creates duplicate indexes when equivalent indexes already exist under other names, and so rollback can drop canonical indexes without breaking foreign keys.

up / addIndex: Besides checking the canonical index name, it now treats any existing index whose leading columns match as sufficient (hasCoveringIndex), including cases like (is_system, id) covering (is_system). It cleans up temporary rollback indexes via dropRollbackIndexes when skipping or after creating an index.

down / dropIndex: Removes the try/catch that hid drop failures. Before dropping, ensureForeignKeysRemainIndexed adds a short-lived migration-owned index on FK columns when the index being removed was the only one supporting a foreign key; those temp indexes are removed when up runs again.

Tests: New AddSavedSearchIndexesTest covers index creation, idempotent up, reuse of DBA-style manual indexes, and down behavior including FK/rollback index handling.

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

@devmiguelangel devmiguelangel changed the title FOUR-27824 Harden Saved Search index migration FOUR-27824 Slow query without indexes Oct 14, 2026
@devmiguelangel devmiguelangel self-assigned this Oct 14, 2026

@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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9169aab. Configure here.

@decisions-sonarqube

Copy link
Copy Markdown

@pmPaulis

Copy link
Copy Markdown
Contributor

This validation is adding in this migration for avoid error in this execution because the indexes can be added manually.
Regards,

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.

2 participants