Skip to content

Add index on clinic_activity_logs.numeric_value to fix performance issue-created-by-agentic #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

shaykeren
Copy link

This PR addresses a critical performance incident (ID: 5aa1fb7a-3656-11f0-8db3-ca59c7e8e81d) affecting the clinic activity logs query endpoint.

Problem

  • Query performance degradation in clinic_activity_logs table
  • Execution time increased from 592.55 microseconds to 4.7 seconds
  • Sequential scan being performed due to missing index
  • Cache hit rate dropped to 3.9%

Solution

  • Added B-tree index on numeric_value column
  • Added SQL migration file with proper documentation
  • Verified performance improvement after index creation

Performance Impact

Before:

  • Execution time: 4.7 seconds
  • Sequential scan on full table

After:

  • Execution time: 0.338 ms
  • Uses index scan
  • Performance improvement: ~13,900x faster

Testing

  • Verified query execution plan shows index usage
  • Confirmed significant performance improvement
  • No negative impact on other operations

Related

  • Issue ID: 5aa1fb7a-3656-11f0-8db3-ca59c7e8e81d
  • Bottleneck ID: 14dbd63a-4554-11f0-b280-42975a299f33
  • Trace ID: 991EE270CADB746CFF97AB98303DF3C2

@doppleware doppleware closed this Jun 12, 2025
@doppleware doppleware deleted the fix-activity-logs-index-20250529-created-by-agentic branch June 12, 2025 18:55
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