-
Notifications
You must be signed in to change notification settings - Fork 16
fix: re-enable subgraph_domain.name indexes (hash + gin trigram) #1856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7c58b7f
5aa8208
2006086
56e1c7e
a15e021
127c1de
a62a62a
427ff54
3d49f4f
e5f770b
6168351
fef01b5
072fff2
dec0101
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "ensindexer": minor | ||
| "@ensnode/ensdb-sdk": minor | ||
| --- | ||
|
|
||
| Re-enable `subgraph_domain.name` indexes (originally disabled in #1819) by pairing a hash index for exact-match lookups with a GIN trigram index (`gin_trgm_ops`) for partial-match filters (`_contains`, `_starts_with`, `_ends_with`). The hash index avoids the btree 8191-byte row size limit triggered by spam names. The trigram index requires the `pg_trgm` Postgres extension, which ENSIndexer now installs automatically via a Drizzle migration (`0001_enable_ext_pg_trgm.sql`) that runs before Ponder starts. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| -- This migration enables the pg_trgm extension, which is used for trigram-based indexing and | ||
| -- searching in PostgreSQL. | ||
| CREATE EXTENSION IF NOT EXISTS pg_trgm; | ||
|
shrugs marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| { | ||
| "id": "7a9206c1-c22e-460d-8314-efa9b4cd64bc", | ||
| "prevId": "d661dcae-f64d-4ecd-a4da-3d5783e17e2c", | ||
| "version": "7", | ||
| "dialect": "postgresql", | ||
| "tables": { | ||
| "ensnode.metadata": { | ||
| "name": "metadata", | ||
| "schema": "ensnode", | ||
| "columns": { | ||
| "ens_indexer_schema_name": { | ||
| "name": "ens_indexer_schema_name", | ||
| "type": "text", | ||
| "primaryKey": false, | ||
| "notNull": true | ||
| }, | ||
| "key": { | ||
| "name": "key", | ||
| "type": "text", | ||
| "primaryKey": false, | ||
| "notNull": true | ||
| }, | ||
| "value": { | ||
| "name": "value", | ||
| "type": "jsonb", | ||
| "primaryKey": false, | ||
| "notNull": true | ||
| } | ||
| }, | ||
| "indexes": {}, | ||
| "foreignKeys": {}, | ||
| "compositePrimaryKeys": { | ||
| "metadata_pkey": { | ||
| "name": "metadata_pkey", | ||
| "columns": ["ens_indexer_schema_name", "key"] | ||
| } | ||
| }, | ||
| "uniqueConstraints": {}, | ||
| "policies": {}, | ||
| "checkConstraints": {}, | ||
| "isRLSEnabled": false | ||
| } | ||
| }, | ||
| "enums": {}, | ||
| "schemas": {}, | ||
| "views": {}, | ||
| "sequences": {}, | ||
| "roles": {}, | ||
| "policies": {}, | ||
| "_meta": { | ||
| "columns": {}, | ||
| "schemas": {}, | ||
| "tables": {} | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import type { Address } from "enssdk"; | ||
| import { index, onchainTable, relations } from "ponder"; | ||
| import { index, onchainTable, relations, sql } from "ponder"; | ||
|
|
||
| import { monkeypatchCollate } from "../lib/collate"; | ||
|
|
||
|
|
@@ -93,9 +93,13 @@ export const subgraph_domain = onchainTable( | |
| expiryDate: t.bigint(), | ||
| }), | ||
| (t) => ({ | ||
| // Temporarily disable the `byName` index to avoid index creation issues. | ||
| // For more details, see: https://github.com/namehash/ensnode/issues/1819 | ||
| // byName: index().on(t.name), | ||
| // uses a hash index because some name values exceed the btree max row size (8191 bytes) | ||
|
shrugs marked this conversation as resolved.
shrugs marked this conversation as resolved.
|
||
| byExactName: index().using("hash", t.name), | ||
|
shrugs marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm surprised no other code is updated in relation to us making the schema changes here? Ex: code in API handlers?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. none! postgres planner will use the indexes without specification |
||
| // GIN trigram index for partial-match filters (_contains, _starts_with, _ends_with). | ||
| // (inline `gin_trgm_ops` via `sql` because passing it through `.op()` gets dropped by Ponder, | ||
| // producing `USING gin (name)` with no opclass) | ||
| byFuzzyName: index().using("gin", sql`${t.name} gin_trgm_ops`), | ||
|
|
||
| byLabelhash: index().on(t.labelhash), | ||
| byParentId: index().on(t.parentId), | ||
| byOwnerId: index().on(t.ownerId), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.