I'd like to create a partial index on my table named Messages
on State
and Id
columns. Normally this can be done by adding a WHERE
clause to create index statement as described in the official docs. The proper SQLite statement would be:
CREATE INDEX `index_Messages_State_Id` ON `Messages` (`State`, `Id`) WHERE State = -2
Since I'm currently using Room as my ORM, I don't know how to declare a partial index using Room syntax.
Here is a brief of my Messages
table:
@Entity(tableName = "Messages")
public class Message implements Parcelable {
@PrimaryKey
@SerializedName("i")
@ColumnInfo(name = "Id")
private long mId;
@SerializedName("t")
@ColumnInfo(name = "Type")
private byte mType;
@SerializedName("s")
@ColumnInfo(name = "State")
private byte mState;
....
}
Thanks in advance.