Add indexed option for custom field B-tree indexes
#1649
Glacier-Luo
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
EmDash lets you define custom fields on collections, but there's no way to add a database index on those fields. For projects with non-trivial data, this is a gap — queries that filter or sort by a custom field hit a full table scan.
In my own project (running on PostgreSQL), the ability to index custom fields is essential. Without it I've been stuck — I can define the fields I need but can't make the queries against them efficient or correct at scale.
Proposal
Add an
indexed: booleanoption to field definitions. When enabled, a standard B-tree index (CREATE INDEX IF NOT EXISTS idx_{table}_{column}) is created on the field's column. The index is dropped when the option is toggled off or the field is deleted.indexed?: booleanonSeedField)unique(which already creates a partial unique index) —indexedis a plain non-unique B-treeImplementation
I have a working implementation in PR #1512 (being split per maintainer request). The core pieces:
indexedcolumn to_emdash_fieldsSchemaRegistry.createField/updateFieldcallcreatePlainIndex/dropFieldIndexesas neededindexedthrough tocreateFieldBeta Was this translation helpful? Give feedback.
All reactions