Skip to content
This repository was archived by the owner on Aug 5, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funky-mails-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ensnode/ensdb-sdk": patch
---

Updated the max character count (length constraint) for the `byName` partial index defined on the `subgraph_domains` table in the "abstract" ENSIndexer Schema.
20 changes: 18 additions & 2 deletions packages/ensdb-sdk/src/ensindexer-abstract/subgraph.schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { index, onchainTable, relations } from "ponder";
import { index, onchainTable, relations, sql } from "ponder";
import type { Address } from "viem";

import { monkeypatchCollate } from "../lib/collate";
Expand Down Expand Up @@ -93,7 +93,23 @@ export const subgraph_domain = onchainTable(
expiryDate: t.bigint(),
}),
(t) => ({
byName: index().on(t.name),
/**
* Maximum character length for the `subgraph_domain.name` partial index.

Copilot AI Mar 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment refers to subgraph_domain.name, but the actual table name is subgraph_domains (and this index is created on that table). Consider updating the wording to reference subgraph_domains.name to avoid confusion when debugging in Postgres.

Suggested change
* Maximum character length for the `subgraph_domain.name` partial index.
* Maximum character length for the `subgraph_domains.name` partial index.

Copilot uses AI. Check for mistakes.
*
* PostgreSQL B-tree indexes have a maximum size of 8,191 bytes (8KB) per entry.
* Without a limit, index creation fails for entries exceeding this size.
* For example, spam domain records with thousands of characters in `name` column
* cause index creation to fail.
*
* UTF-8 uses 1-4 bytes per character. For the safe maximum of 4 bytes:
* 8,191 ÷ 4 = ~2,000 characters would be the upper bound.
*
* We use 255, which is sufficient for virtually all ENS names in practice.
* This is implemented as a partial index with WHERE length(name) <= 255,
* which excludes oversized spam entries while still allowing normal lookups
* (e.g. where: { name: "foo.eth" }) to use the index.
Comment on lines +109 to +110

Copilot AI Mar 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc comment claims normal lookups like where: { name: "foo.eth" } will use this partial index, but in practice the GraphQL layer builds eq(column, value) predicates (parameterized) without length(name) <= 255. Postgres can only use a partial index when the query’s WHERE clause implies the index predicate, so name = $1 alone typically won’t qualify. Consider either (a) adjusting the query builder to add length(name) <= 255 when the provided filter value is <= 255 chars (to preserve semantics), or (b) changing to an expression index approach paired with matching query generation. At minimum, please update this comment to avoid overstating index usage.

Suggested change
* which excludes oversized spam entries while still allowing normal lookups
* (e.g. where: { name: "foo.eth" }) to use the index.
* which excludes oversized spam entries while still indexing typical-length names.
* Note: PostgreSQL can only use this partial index when a query's WHERE clause
* implies the predicate (e.g. includes a matching length constraint), so simple
* equality filters alone (name = $1) may not always qualify for index usage.

Copilot uses AI. Check for mistakes.
*/
byName: index().on(t.name).where(sql`length(${t.name}) <= 255`),
byLabelhash: index().on(t.labelhash),
byParentId: index().on(t.parentId),
byOwnerId: index().on(t.ownerId),
Expand Down
Loading