Skip to content

Conversation

@paras-dba
Copy link
Contributor

@paras-dba paras-dba commented Dec 30, 2025

📋 Description

JIRA ID: AMM-1660

Ticket was created to optimised the performance of the SP "Pr_GetCallHistory" in ASSAM server previously it was taking 31 sec now it will take 0.10 sec

Summary by CodeRabbit

  • New Features
    • Enhanced call history retrieval with comprehensive beneficiary and child data integration, enabling more detailed record access.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 30, 2025

📝 Walkthrough

Walkthrough

A new database migration file introduces the Pr_GetCallHistory stored procedure for the Assam system. The procedure accepts an obcallid parameter and returns two result sets: one combining mother call records with mother validation data, and another combining child call records with child validation data via UNION ALL.

Changes

Cohort / File(s) Summary
Database Migration - Call History Procedure
src/main/resources/db/migration/dbiemr/V32__Assam_SP.sql
Adds Pr_GetCallHistory stored procedure with parameterized input (v_obcallid). Executes two SELECT statements joined with UNION ALL: first retrieves mother call metadata from t_bencall, t_mctsoutboundcalls, and t_mothervalidrecord; second retrieves child call metadata from t_bencall, t_mctsoutboundcalls, and t_childvaliddata. Both branches include optional filtering when obcallid parameter is provided.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A hopping procedure to fetch calls so fine,
Mother and child data, perfectly aligned,
UNION ALL brings them together with grace,
Call history records, in their rightful place! 📞✨

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Optimised stored procedure Pr_GetCallHistory' directly and clearly describes the main change: optimization of a specific stored procedure. It is concise, specific, and accurately summarizes the primary objective of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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 and usage tips.

@paras-dba paras-dba requested a review from drtechie December 30, 2025 13:58
@sonarqubecloud
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd30e68 and a906909.

📒 Files selected for processing (1)
  • src/main/resources/db/migration/dbiemr/V32__Assam_SP.sql
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (java)
🔇 Additional comments (5)
src/main/resources/db/migration/dbiemr/V32__Assam_SP.sql (5)

1-1: LGTM!

The DROP PROCEDURE IF EXISTS statement ensures idempotency for the migration, which is a best practice.


36-36: LGTM!

Using UNION ALL instead of UNION is appropriate here since mother and child call records are distinct datasets with no possibility of duplicates between them. This avoids unnecessary deduplication overhead.


38-60: Verify indexes on child-related join columns.

Similar to the mother records query, ensure indexes exist on:

  • t_mctsoutboundcalls.childID
  • t_childvaliddata.MCTSID_no_Child_ID

The INNER JOIN on Line 57-58 means child call records without matching entries in t_childvaliddata will be excluded. Verify this is the intended behavior.

The script provided in the previous comment will also check for these child-related indexes.


62-64: LGTM!

The procedure closing statements properly restore the delimiter, which is standard practice for MySQL stored procedure definitions.


12-34: Indexes already exist for all join columns in the base schema (V1__DB_IEMR.sql).

This migration only creates a stored procedure and does not modify table structures. All columns referenced in the joins already have indexes from the initial schema:

  • t_bencall.OBCallID: FK_BenCall_MCTSOutboundCalls_idx
  • t_mctsoutboundcalls.OBCallID: Primary key
  • t_mctsoutboundcalls.MotherID: FK_tMCTSOutboundCalls_MotherValidRecord_idx
  • t_mctsoutboundcalls.ChildID: FK_tMCTSOutboundCalls_ChildValidData_idx
  • t_mothervalidrecord.MCTSID_no: Unique key
  • t_childvaliddata.MCTSID_no_Child_ID: Unique key

The WHERE clause change from IFNULL(v_obcallid, t1.obcallid) to (v_obcallid IS NULL OR t1.obcallid = v_obcallid) is logically equivalent and should work efficiently with existing indexes.

Likely an incorrect or invalid review comment.

@paras-dba paras-dba merged commit 38905c8 into main Dec 31, 2025
7 of 8 checks passed
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.

4 participants