surrealdb / surrealdb

A scalable, distributed, collaborative, document-graph database, for the realtime web

Home Page:https://surrealdb.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: COMPOSITE INDEX does not work

ioannist opened this issue · comments

Describe the bug

REMOVE TABLE haircut;

UPDATE haricut:1 CONTENT {
    year: 2022,
};

DEFINE INDEX timeIndex ON TABLE haircut COLUMNS year;

SELECT * FROM haircut WHERE year = 2022 EXPLAIN; // uses index as expected

//----------

REMOVE TABLE haircut;

UPDATE haricut:1 CONTENT {
    year: 2022,
    month: 5,
};

DEFINE INDEX timeIndex ON TABLE haircut COLUMNS year, month;

SELECT * FROM haircut WHERE year = 2022 AND month = 5 EXPLAIN; // does not use composite index as expected

Steps to reproduce

Execute code above

Expected behaviour

A composite index should be used just like a one-value index.

SurrealDB version

1.5

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct