Skip to content

Fix/504 composite indexes get eligible records info#136

Merged
snehar-nd merged 7 commits into
release-3.7.1from
fix/504-composite-indexes-getEligibleRecordsInfo
Jun 29, 2026
Merged

Fix/504 composite indexes get eligible records info#136
snehar-nd merged 7 commits into
release-3.7.1from
fix/504-composite-indexes-getEligibleRecordsInfo

Conversation

@snehar-nd

Copy link
Copy Markdown
Contributor

📋 Description

JIRA ID:

AMM-2353

✅ Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)

ℹ️ Additional Information

Please describe how the changes were tested, and include any relevant screenshots, logs, or other information that provides additional context.

Sneha and others added 5 commits June 22, 2026 16:48
Adds composite DB indexes on t_mctsoutboundcalls, t_childvaliddata, and
t_mothervalidrecord to fix the 504 Gateway Timeout on the Child+Self
call allocation info endpoint. Existing single-column indexes on low-
cardinality columns (phoneNumberType=2, ProviderServiceMapID=2) were
being skipped by the MySQL optimizer, causing full scans of 4M+ rows.

Run db_indexes_performance.sql directly on production DB — no deployment needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ordsInfo

The Child+Self call allocation info endpoint timed out (504) because
getEligibleRecordsInfo fired 3 separate COUNT queries against
t_mctsoutboundcalls (4M rows) sequentially — each doing a full table
scan. Q3 (HR unallocated) returned 0 rows but still scanned all 4M rows.

Fix: replace the 3 separate queries with a single native SQL query using
SUM(CASE WHEN) conditional aggregation. One table scan now returns all
three counts (LR unallocated, HR unallocated, allocated) instead of three
independent scans. Same fix applied to the Mother path.

Combined with composite DB indexes in db_indexes_performance.sql, this
reduces response time from 60s+ timeout to under 1s.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…y migration

Indexes belong in the DB migration repo, not the application repo.
See AMRIT-DB V83__ECD_outbound_calls_performance_indexes.sql.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…o fix 504

Converts getChildUnAllocatedCountLR, getChildUnAllocatedCountHR, and
getTotalAllocatedCountChild to native queries with FORCE INDEX hint so
MySQL uses the correct index instead of doing a full scan of 4M rows.

Reverts consolidated SUM(CASE WHEN) approach — back to 3 separate queries,
each now guided to idx_mcts_eligible_v2 via FORCE INDEX.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…k to 3 separate calls

Removes unused getChildCountsLRHRAllocated and getMotherCountsLRHRAllocated
from OutboundCallsRepo. Reverts mother count block in CallAllocationImpl
to use the original 3 separate query methods.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6da84db8-1066-4f8c-ac66-a3b269a339ba

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sneha and others added 2 commits June 29, 2026 13:36
Addresses reviewer comment: use OutboundCalls entity and mapped field names
instead of raw table/column names with FORCE INDEX. Performance is handled
by the restructured idx_mcts_eligible_v2 index (AMRIT-DB V84 migration).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…o fix 504

Reverts JPQL queries back to native SQL with FORCE INDEX hint on
getChildUnAllocatedCountLR, getChildUnAllocatedCountHR, and
getTotalAllocatedCountChild. FORCE INDEX is required to guarantee MySQL
uses idx_mcts_eligible_v2 (restructured via AMRIT-DB V84 migration)
instead of falling back to a full table scan on 4M+ rows.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@snehar-nd
snehar-nd changed the base branch from release-3.7.1 to release-3.6.2 June 29, 2026 14:27
@snehar-nd
snehar-nd changed the base branch from release-3.6.2 to release-3.7.1 June 29, 2026 14:29
@snehar-nd
snehar-nd merged commit aa2b486 into release-3.7.1 Jun 29, 2026
3 checks passed
@sonarqubecloud

Copy link
Copy Markdown

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