Fix/504 composite indexes get eligible records info#136
Conversation
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>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
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>
|



📋 Description
JIRA ID:
AMM-2353
✅ Type of Change
ℹ️ Additional Information
Please describe how the changes were tested, and include any relevant screenshots, logs, or other information that provides additional context.