Some database engines have a fundamental concept of a row id. The
row id is everything you need to know to locate a row. Common
uses include secondary indexes (key is what’s indexed, value is
rowid which you then use to lookup the row).
One design is the InnoDB method of having secondary indexes have
the value in the index be the primary key of the row. Another is
to store the rowid instead. Usually (or often… or sometimes…)
rowid is much smaller than the pkey of the row. This is how
innodb can answer some queries just out of the index. If it used
rowid, it may involve more IO to answer the query. All this is
irrelevant if you never want just the primary key from a
secondary index.
Some engines are designed from the start to have rowid, others
it’s added later (e.g. NDB).
Anyway… all beside the point. Did you know you can do this in
mysql or drizzle:
drizzle> create table t1 (a int primary key);
Query …
[Read more]