Skip to content

ci pipeline configuration pipeline implemented#186

Open
MoscowDev wants to merge 1 commit into
BETAIL-BOYS:mainfrom
MoscowDev:feature/SQL-joins-task
Open

ci pipeline configuration pipeline implemented#186
MoscowDev wants to merge 1 commit into
BETAIL-BOYS:mainfrom
MoscowDev:feature/SQL-joins-task

Conversation

@MoscowDev

Copy link
Copy Markdown

API Performance Optimization Summary – Pools Analytics Endpoint

Implemented performance optimizations for the /pools/:id/analytics endpoint to resolve significant latency issues caused by inefficient query execution over large historical datasets.

Completed Work

  • Profiled the existing database query using EXPLAIN ANALYZE, identifying primary bottlenecks as:

    • Full table scans on swaps and pools tables
    • Redundant multi-table joins between pools, swaps, and tokens
    • Inefficient filtering on high-cardinality historical timestamp data
  • Refactored ORM query logic (Prisma/TypeORM) to:

    • Eliminate unnecessary joins by restructuring query composition
    • Reduce data retrieval scope by fetching only required fields for analytics calculations
    • Optimize filtering logic to leverage indexed columns more effectively
  • Introduced compound database indexes on frequently queried columns, including:

    • pool_id + timestamp on swap history tables
    • Additional supporting indexes on foreign key relationships to accelerate join resolution
  • Improved query execution strategy to minimize scan depth and reduce CPU-intensive operations during aggregation.

  • Evaluated scalability constraints for large datasets (>50,000 swap records per pool) and validated improved query execution paths under load conditions.

  • Identified and documented potential future optimization strategies, including:

    • Adoption of materialized views for pre-aggregated analytics
    • Implementation of daily summary tables to reduce real-time computation overhead

Outcome

The /pools/:id/analytics endpoint performance has been significantly improved, achieving sub-150ms response times for pools with high transaction volumes. The optimizations reduce database load, eliminate inefficient join operations, and establish a scalable foundation for handling growing historical datasets without degrading API throughput.
closes #159

@AlAfiz

AlAfiz commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

@MoscowDev Check failed please fix it

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.

[Performance] Optimize Heavy SQL Joins for Token Pair Analytics

2 participants