indexingcompound-indexcomposite-indexedgedb

Define a composite index in EdgeDB


How do you define a composite index in EdgeDB?

The documentation states:

The simplest form of index is an index, which references one or more properties directly:

type User {
    property name -> str;
    index on (__subject__.name);
}

but I couldn't find a way to reference multiple properties in an index.


Solution

  • You can add index on (...) to the containing type, where ... is an arbitrary scalar expression. To create a composite index it should be a tuple (x, y):

    type User {
        property first_name -> str;
        property last_name -> str;
        index on ((.first_name, .last_name));
    }
    

    source