Last answered:

30 Nov 2022

Posted on:

29 Oct 2021

7

Resolved: M query fetch time increased after creating an index for the salaries table!

M query fetch time increased after creating an index for the salaries table!

5 answers ( 2 marked as helpful)
Posted on:

13 Nov 2021

2

I have the same problem. The query took almost double the duration.

Posted on:

13 Nov 2021

0

Same as you, it took more than the double of the duration.

Posted on:

02 Dec 2021

0

Me too, and there were 0 records returned after running the query.

Instructor
Posted on:

10 Dec 2021

10

Hi Ialit, AbdElrahman and Sawsan!

Тhanks for reaching out!

The final effect from using an index depends on local technology and hardware as well the type of data being used. There are many factors that will determine the total time of a query execution, and whatever index is chosen, it is always tested prior to being applied across the entire company.

Depending on the circumstances, sometimes it might happen that when a certain table has more than one index it would affect the performance negatively. We have to be careful to set the proper amount of columns to be indexed as in the end it might worsen the performance. So, while indexes are meant to improve the performance of a query, they may worsen it. Therefore, always remember to test an index prior to applying it.
Also, please remember that the purpose of this lecture is to show you how to use MySQL indexes - even if in this case you did not improve the performance, using indexes follows the structure provided in the lecture.

Hope this helps.
Best,
Martin

Posted on:

30 Nov 2022

3

Just chiming in to say my result was the same. Increased duration/fetch times with the index. I think this is actually an excellent example to show why it isn't necessary (or beneficial) to index every column. I like this example because I was thinking exactly that. Why not just index every column for the best performance? This example proves it is not always better to have an index on every frequently used column.

Submit an answer