Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unique index slows down?

Tags:

sql

mysql

does it slow down the query time to use a lot of unique indexes? i dont have that many im just curious, i think i have heard this some where

  • id (primary auto_increment)
  • username (unique)
  • password
  • salt (unique)
  • email (unique)
like image 760
tomek Avatar asked Jan 13 '10 20:01

tomek


People also ask

Does unique index improve performance?

In addition to enforcing the uniqueness of data values, a unique index can also be used to improve data retrieval performance during query processing.

Why does index query slow down?

Why? Because sequentially scanning an index is actually less efficient than sequentially scanning a table, for indexes with a large number of rows for a given key.

Do indexes slow down inserts?

If you update a table, the system has to maintain those indexes that are on the columns being updated. So having a lot of indexes can speed up select statements, but slow down inserts, updates, and deletes.

Does index slow down select query?

Answer: Of course! I have discussed this subject multiple times on this blog. Of course, Index can reduce the performance of any query and particularly of SELECT queries without even being that indexed utilized directly in the query.


1 Answers

It depends on the database server software and table/index type you are using. Inserts will be slower any time you have indexes of any sort, but not necessarily by a lot - this will depend on the table size as well.

In general, unique indexes should speed up any SELECT queries you use that are able to take advantage of the index(es)

like image 76
Graza Avatar answered Oct 19 '22 21:10

Graza