Things you didn't know about indexes - Comments

Things you didn't know about indexes

hongminhee

Used PostgreSQL for years and somehow never bumped into INCLUDE. This was the first explanation that made it click: columns in the index proper affect ordering and have to be maintained on writes; INCLUDE columns are just there to cover the query.

bugsmith

It's pretty new to me too, and I'm a long time Postgres user (although far from being any kind of true database engineer).

snej

FYI almost all of this is applicable to SQLite too, except

  • Use EXPLAIN QUERY PLAN — its output is much more readable than EXPLAIN.
  • it doesn’t support INCLUDE, sadly.
bugsmith

That's interesting. I knew some of this also applied to SQLite (the only other database I regularly interact with) but wasn't sure to what extent.

hongminhee

Used PostgreSQL for years and somehow never bumped into INCLUDE. This was the first explanation that made it click: columns in the index proper affect ordering and have to be maintained on writes; INCLUDE columns are just there to cover the query.

bugsmith

It's pretty new to me too, and I'm a long time Postgres user (although far from being any kind of true database engineer).

snej

FYI almost all of this is applicable to SQLite too, except

  • Use EXPLAIN QUERY PLAN — its output is much more readable than EXPLAIN.
  • it doesn’t support INCLUDE, sadly.
bugsmith

That's interesting. I knew some of this also applied to SQLite (the only other database I regularly interact with) but wasn't sure to what extent.