[ACCEPTED]-Does a SQLite Foreign key automatically have an index?-query-optimization

Accepted answer
Score: 44

In the SQLite Documentation it says:

... "an index should 4 be created on the child key columns of each 3 foreign key constraint"

ie. the index 2 is not automatically created, but you should 1 create one in every instance.

Score: 43

Even if it is not actually a no-op (a data 7 structure describing the constraint is added 6 to the table), foreign key related statement 5 doesn't create any index on involved columns. Indexes 4 are implicitly created only in the case 3 of PRIMARY KEY and UNIQUE statements. For 2 more details, check it out build.c module 1 on the sqlite source tree: http://www.sqlite.org/cvstrac/rlog?f=sqlite/src/build.c https://www.sqlite.org/src/file?name=src/build.c&ci=tip

More Related questions