sea-orm icon indicating copy to clipboard operation
sea-orm copied to clipboard

[feat] migration should support partial index

Open onichandame opened this issue 3 years ago • 3 comments

Motivation

Sqlite supports a WHERE clause on creating an index. see docs

This feature is useful if only a subset of rows need to be indexed. Without it the index must cover all rows, which unnecessarily consumes more disk space.

Proposed Solutions

Something like sea_query::Index::create().filter(<Condition>) for use with entities, and sea_query::Index::create().filter_raw("<Where Clause>") for more freedom.

Additional Information

onichandame avatar Jul 14 '22 08:07 onichandame

Hey @onichandame, thanks for the proposal!

As far as I know, both SQLite and PostgreSQL supported partial index, docs:

  • https://www.sqlite.org/partialindex.html
  • https://www.postgresql.org/docs/current/indexes-partial.html

But MySQL doesn't support it. I think we could introduce this feature in SeaQuery as 2 out of 3 databases support it.

Thoughts? @tyt2y3 @ikrivosheev

billy1624 avatar Jul 15 '22 08:07 billy1624

Agreed

tyt2y3 avatar Jul 17 '22 06:07 tyt2y3

Alright, I take that as a go! I open a tracking issue on https://github.com/SeaQL/sea-query/issues/396

billy1624 avatar Jul 26 '22 05:07 billy1624

Reason to close: this issue has been moved to SeaQuery

tyt2y3 avatar Feb 21 '23 10:02 tyt2y3