mysqlindexingmemory-table

Indexing every column in a table


I have a couple of questions regarding MySQL indexing:

1) Is there any speed increase when indexing a table stored in memory?

2) When searching my table I match on column field, would indexing every column defeat the purpose of an index?

Many thanks.


Solution

  • Indexing any table, either memory or file system based, will speed up queries that select or sort results based on that column. This is because the index works like a tree structure and the search distance depends on the depth of the tree, which increases a lot slower than the row count of the column (logarithmic).

    Indexing every column does not defeat the purpose of the index, but it will slow up inserts and updates because those changes will cause an update of every index of that table. Also, the indexes take up space on the database server, so that is another drawback to be considered.

    Other SO questions to read relating to this question:

    Best practices for indexing
    What is an index
    How many indexes are enough