Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is because InnoDB actually stores the data via the primary key index. I'm fairly certain this is the only way they could do it (sanely).

As a side note, because of this, secondary indices just have a pointer to a PK. So when looking up by a secondary index, it has to traverse two trees.



Unless, of course, the secondary index has all of the columns you need to execute your query. (Sometimes it can help to add an extra column or two to your secondary index if you want to avoid the extra lookup.)

sqlite3 stores rows in an integer primary key index. If you do not specify an "integer primary key" column, it synthesizes one behind the scenes (essentially a rowid) and your primary key lookups end up going through two indexes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: