I will answer Liven. To answer your bonus question about how much of the productivity gains you get from creating the index, the answer is "It depends."
If one or both tables are small and they are the only two tables in the query, the performance gain can be small to zero. When the number of records is small, sometimes itβs faster to just read all the records and not use the index in any case. The database engine must be smart enough to understand this - that "query optimization is everything."
Similarly, if you have other tables involved and other selection criteria, the database engine may decide not to use this index and that another way to search for records is faster.
In another case, if you have two very large tables, creating an index in the field used to combine them can reduce the execution time by 99% or more.
That is why it is a good idea to learn to read the explanation plans for your database engine. If the request takes a long time, run an explanation plan and see what it does. Often creating a good index can greatly improve the query.
source share