Re: [sqlite] why select distinct does not use index?

2007-11-08 Thread Joe Wilson
--- "Maxim V. Shiyanovsky" <[EMAIL PROTECTED]> wrote: > Suppose I have simple table: > > CREATE TABLE [profile_data] ( > [profile_id] INTEGER, > [version] INTEGER); > > CREATE INDEX [by_id] ON [profile_data] ([id]); > > Why > > sqlite> explain query plan >...> select distinct(profile_i

Re: [sqlite] why select distinct does not use index?

2007-11-08 Thread Ian Frosst
In the call to create index, it looks like you're creating a duplicate index on [id], which I believe references the default btree id (also called rowid.) If you change that line to: CREATE INDEX [by_id] ON [profile_data] ([profile_id]); your index should be used (though whether indexes get use

[sqlite] why select distinct does not use index?

2007-11-08 Thread Maxim V. Shiyanovsky
Suppose I have simple table: CREATE TABLE [profile_data] (   [profile_id] INTEGER,   [version] INTEGER); CREATE INDEX [by_id] ON [profile_data] ([id]); Why sqlite> explain query plan    ...> select distinct(profile_id) from profile_data; 0|0|TABLE profile_data Does not use index?