Partial Indexing

#1

I have a question about partial indexing.

For example, a field of String type ttt, will be distinguished by the first 5 characters, then I can make a index of substr(ttt,1,5) in MySQL.

With ObjectDB, how can I write the annotation for this purpose?

TIA

#2

Currently ObjectDB supports only indexing of complete fields (single field or multiple fields).

The obvious workaround is to add to the entity class an additional field that will hold the partial content. You can keep that partial field synchronized with the main field by using a callback method (which will be annotated with @PrePersist and @PreUpdate). The new field should be indexed and used in queries.

ObjectDB Support
#3

Thanks! Your reply do make sense.

Reply