Define a composite index in EdgeDB

116 views Asked by At

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.

1

There are 1 answers

0
CodesInChaos On BEST ANSWER

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