Skip to content

Optimize Subgraph Query Performance with Pagination and Event Filtering #6127

@DavidBraide

Description

@DavidBraide

Description

Issue Title

Optimize Subgraph Query Performance with Pagination and Event Filtering

Description

As part of my work analyzing query performance for a Uniswap V3 subgraph (see report), I identified two optimizations to improve subgraph efficiency:

  1. Pagination Controls: Enforce first and skip parameters in queries to reduce response times for large datasets (e.g., fetching 10 pools vs. 100 reduced response time by ~30%).
  2. Selective Event Indexing: Filter low-impact events during indexing to reduce node load and sync time (e.g., indexing only PoolCreated events saved ~20% indexing time).

Proposed Solution

  • Update graph-node documentation to recommend pagination best practices.
  • Add a configuration option in subgraph.yaml to allow developers to specify event filters (e.g., exclude specific events).
  • Provide example code for optimized queries in the Subgraph Developer Guide.

Steps to Reproduce

  1. Deploy a subgraph for UniswapV3Factory (0x1F98431c8aD98523631AE4a59f267346ea31F984).
  2. Run query: { pools(first: 10, orderBy: createdAtBlock, orderDirection: desc) { id, token0, token1, fee } }.
  3. Compare response time with first: 100 or unfiltered event indexing.

Expected Outcome

  • Reduced query response times by ~30% with pagination.
  • Faster indexing (~20% improvement) with selective event filtering.

Additional Context

See my full analysis: https://github.com/DavidBraide/uniswap-v3-subgraph/blob/main/docs/query-performance-analysis.md. I’m happy to collaborate on implementing these optimizations or updating documentation.

Good First Issue

This is suitable for new contributors, as it involves documentation updates and minor configuration changes. I propose tagging this as a good first issue for community members to tackle.

Are you aware of any blockers that must be resolved before implementing this feature? If so, which? Link to any relevant GitHub issues.

No response

Some information to help us out

  • Tick this box if you plan on implementing this feature yourself.
  • I have searched the issue tracker to make sure this issue is not a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions