Indexing

Indexing

by Charlie Benck -
Number of replies: 0

Indexing, in the context of MySQL databases, is a data structure or "schema" that trades off space for time, providing faster querying speeds. In essence, table data is given an "index" based off the nature and content of its columns, allowing for identification of identical/similar data far faster than without the index. Say, for example, that you have a deck of cards: if you search through the entire deck in hopes of finding the 10 of Hearts you might have to ask "is this the right card?" 52 times, whereas if you were to use an index based on the suit of each card (such that there was a separate pile for Spades, Hearts, etc) you would only have to ask "is this the right card" around 13 times (depending how you look at determining which pile to look in). Indexes aren't particularly important in small databases like those which we are creating, but in massive databases with thousands/millions/billions of records queries can take days and the presence of an index can massively reduce the amount of operations required to complete queries (if you've got 2 million names listed and seek to find names that begin with "e" but they're indexed by placement in the alphabet you eliminate the need to ask 2 millions pieces of data if it meets the criteria, since you can just jump to the part of the index that corresponds with "e").

Indexes are present in all sorts of places; authors catalogs, books, building plans, or anywhere where there is a lot of information which can be bundled by some similar characteristic and the need to quickly sift through that information.


If you have any interest, the following provide a more in depth description of what an index is in the realm of computer science:

https://web.cs.ucdavis.edu/~green/courses/ecs165a-w11/7-indexes.pdf

https://dev.mysql.com/doc/refman/8.0/en/mysql-indexes.html