SQLite Forum

index question
Login
Given:
```
create table dance (id int primary key, select int not null, name text unique)
```

The table is a fixed sized table with the set of defined dances. I can select a set of dances by setting select=1; un-select=0;

I'm pretty certain I should define an index for the name. But I don't know whether to include "select" in the index or not. "select" is very volatile. I turn them all on or off, or select individual ones on or off from the user interaction.

If I define an index as
```
CREATE UNIQUE INDEX IF NOT EXISTS index_dn ON dance (name,select)
```
and use a select as
```
SELECT id,name FROM dance WHERE name='waltz' and select>0
```
is the index going to be used? Will the value of "select" be stored in the index in addition to the table, or only in the index?

What does it mean to use a WHERE clause in the CREATE INDEX as
```
CREATE UNIQUE INDEX IF NOT EXISTS index_dn ON dance (name,select)
  WHERE select>0
```
Does that mean that there is no index entry if select==0?