Eric Grange wrote: > I recently added a field and index to an existing table, and now SQLite > seems to be using that index in place of the primary key, even on simple > queries > > CREATE TABLE vin ( > id INTEGER PRIMARY KEY AUTOINCREMENT, > tx_id INTEGER NOT NULL, > from_vout_id INTEGER, > addr_id INTEGER REFERENCES addresses (id), -- newly added field is this > one > FOREIGN KEY(tx_id) REFERENCES transactions(id), > FOREIGN KEY(from_vout_id) REFERENCES vout(id) > ) > > CREATE INDEX vin_addr_idx on vin (addr_id) > > And the offending query is > > select id from vin order by id desc limit 1 > > for which the query plan is > > 0 0 0 SCAN TABLE vin USING INDEX vin_addr_idx > 0 0 0 USE TEMP B-TREE FOR ORDER BY
The SQLite I have here uses the primary key. > This is with the precompiled sqlite.dll. Which version? Regards, Clemens