Database Indexing [closed]

5

What is the advantage of maintaining an indexed database, with foreign key and indexing of the most used fields as in searches?

    
asked by anonymous 14.05.2015 / 13:02

1 answer

4

The difference can be analyzed using explain .

try to query a table, using a where field. Then try putting an index in that field and remove, and see the differences. Explain gives an explanation of what MySQL does when it executes a query.

With the index searches are accelerated, which only has significant impact from the moment these tables begin to have many records. Foreign keys have the same impact, and also help in performance when joining multiple tables.

In addition, the foreign keys lets you define what should happen when deleting records from a given table, and its index is referenced in others. Allows for example to delete permissions of a given user if the permissions have a foreign key for the user, and the corresponding line of the user is deleted.

    
14.05.2015 / 13:12