Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do MySQL indexes still work after inserting new rows?

Tags:

sql

mysql

I have a MySQL table with an index covering two fields. If I insert new rows into the table, will my index still work?

like image 791
Brian Avatar asked Dec 29 '09 22:12

Brian


People also ask

Do indexes affect inserts?

The number of indexes on a table is the most dominant factor for insert performance. The more indexes a table has, the slower the execution becomes. The insert statement is the only operation that cannot directly benefit from indexing because it has no where clause. Adding a new row to a table involves several steps.

Do indexes automatically update?

The Database Engine automatically modifies indexes whenever insert, update, or delete operations are made to the underlying data. For example, the addition of rows in a table may cause existing pages in rowstore indexes to split, making room for the insertion of new rows.

How do indexes affect inserts and updates?

Derby has to do work to maintain indexes. If you insert into or delete from a table, the system has to insert or delete rows in all the indexes on the table. If you update a table, the system has to maintain those indexes that are on the columns being updated.

What are the disadvantages of indexes in MySQL?

The Drawbacks of Using IndexesIndexes consume disk space – an index occupies its own space, so indexed data will consume more disk space too; Redundant and duplicate indexes can be a problem – MySQL allows you to create duplicate indexes on a column and it does not “protect you” from doing such a mistake.


1 Answers

Yes, the index is automatically updated; therefore indices (aka indexes) make inserts, updates and deletes slower.

like image 159
David Avatar answered Sep 20 '22 12:09

David