Skip to content

Perf (regression): Slow DB query in processTokenTransfer transaction #680

@claude

Description

@claude

Performance Issue

Project: ethernal-backend
Type: Slow DB Query | Regression
Impact: 9 events in 24h
Regression: Yes
Transaction: processTokenTransfer
Link: https://sentry.tryethernal.com/organizations/sentry/issues/91/

Problem

Performance regression in token transfer processing. The transaction involves multiple DB queries with the main bottleneck being a 1.07-second SELECT query with JOINs on token_transfers, workspaces, and transactions tables.

Suggested Fix

  • Review and optimize the main SELECT query that joins token_transfers with workspaces and transactions
  • Consider adding database indexes if missing on frequently queried columns
  • Investigate if any of the queries can be batched or parallelized

Evidence

Main slow query (1.07s):
SELECT TokenTransfer.id, TokenTransfer.src, TokenTransfer.dst, TokenTransfer.token,
       TokenTransfer.transactionId, TokenTransfer.workspaceId, workspace.id AS "workspace.id",
       workspace.name AS "workspace.name", workspace.public AS "workspace.public",
       workspace.rpcServer AS "workspace.rpcServer",
       workspace.processNativeTokenTransfers AS "workspace.processNativeTokenTransfers", 
       transaction.id AS "transaction.id", transaction.blockNumber AS "transaction.blockNumber", 
       transaction.hash AS "transaction.hash"
FROM token_transfers AS TokenTransfer
INNER JOIN workspaces AS workspace ON TokenTransfer.workspaceId = workspace.id
LEFT OUTER JOIN transactions AS transaction ON TokenTransfer.transactionId = transaction.id
WHERE TokenTransfer.id = 168589804;

Additional queries: token_balance_changes INSERT (~0.013s), contract SELECT (~0.013s)

Created by Sentry Scanner

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