Skip to content

Perf: N+1 Query in blockSync (72 events) #1188

Description

@claude

Performance Issue

Project: ethernal-backend
Type: N+1 Query
Impact: 72 events in 24h
Regression: No
Transaction: blockSync
Link: https://sentry.tryethernal.com/organizations/sentry/issues/23/

Problem

Individual block queries are being made repeatedly during block sync process instead of batch querying, creating an N+1 pattern.

Suggested Fix

Add eager loading/batch loading for blocks in the blockSync process. Use findAll with IN clause instead of individual findByPk calls.

Evidence

SELECT "id", "baseFeePerGas", "difficulty", "extraData", "gasLimit", "gasUsed", "hash", "miner", "nonce", "number", "parentHash", "l1BlockNumber", "timestamp", "transactionsCount", "raw", "workspaceId", "state", "orbitBatchId", "logsBloom", "mixHash", "receiptsRoot", "sendCount", "sendRoot", "sha3Uncles", "size", "stateRoot", "transactionsRoot", "withdrawals", "createdAt", "updatedAt" 
FROM "blocks" AS "Block" 
WHERE "Block"."id" = 553142833;

Created by Sentry Scanner

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendBackend componentsentryAuto-created from Sentry alert

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions