diff --git a/.changeset/hash-and-trigram-name-indexes.md b/.changeset/hash-and-trigram-name-indexes.md new file mode 100644 index 0000000000..e4a4a3123e --- /dev/null +++ b/.changeset/hash-and-trigram-name-indexes.md @@ -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. diff --git a/docs/ensnode.io/src/content/docs/docs/contributing/index.mdx b/docs/ensnode.io/src/content/docs/docs/contributing/index.mdx index b9beadb5d7..fce21e8752 100644 --- a/docs/ensnode.io/src/content/docs/docs/contributing/index.mdx +++ b/docs/ensnode.io/src/content/docs/docs/contributing/index.mdx @@ -15,7 +15,7 @@ This guide covers running ENSNode locally for development and contributions. ### Prerequisites - [Git](https://git-scm.com/) -- [Postgres 17](https://www.postgresql.org/) +- [Postgres 17](https://www.postgresql.org/) with the [`pg_trgm`](https://www.postgresql.org/docs/current/pgtrgm.html) extension available for installation (ships with stock Postgres contrib; ENSIndexer runs `CREATE EXTENSION IF NOT EXISTS pg_trgm` at startup to back partial-name search indexes) - [Node.js](https://nodejs.org/) - It's recommended you install Node.js through [nvm](https://github.com/nvm-sh/nvm) or [asdf](https://asdf-vm.com/). - see `.nvmrc` and `.tool-versions` for the specific version of Node.js diff --git a/docs/ensnode.io/src/content/docs/docs/deploying/docker.mdx b/docs/ensnode.io/src/content/docs/docs/deploying/docker.mdx index bea25babb4..88f159aa3a 100644 --- a/docs/ensnode.io/src/content/docs/docs/deploying/docker.mdx +++ b/docs/ensnode.io/src/content/docs/docs/deploying/docker.mdx @@ -11,6 +11,10 @@ import dockercompose from '@workspace/docker-compose.yml?raw'; The Docker images are the easiest way to run or deploy the ENSNode suite of services, both locally and in the cloud. +:::note[Postgres Requirement] +ENSIndexer runs `CREATE EXTENSION IF NOT EXISTS pg_trgm` at startup to back partial-name search indexes. If you're swapping out the bundled `postgres:17` image for a managed or custom Postgres, make sure the [`pg_trgm`](https://www.postgresql.org/docs/current/pgtrgm.html) extension is available for installation (it ships with stock Postgres contrib and is available for installation on most managed providers). +::: + ({ - // 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) + byExactName: index().using("hash", t.name), + // 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),