Dear forum users!
I have a sql query to the database in which there are 100,000 lines in the "users" table and 20,000,000 records in the "friends" table. I am trying to execute the following query in phpMyAdmin:
SELECT `friends`.`friend_age` FROM `friends` WHERE `id_user` IN(SELECT `users`.`uid` FROM `users` WHERE `age`=13 AND `number_of_friends` <> 0) AND `friend_age` <> 0 ORDER BY `friend_age`
When you try to execute the request, everything hangs .... Then after some time phpMyAdmin gives the following error:
Fatal error: Maximum execution time of 300 seconds exceeded in D:\XAMPP\phpMyAdmin\libraries\dbi\DBIMysqli.class.php on line 290
I have already tried to create indices of fields for which the sample is carried out as it is written here: MySQL: using indexes . However, this did not help, the request is still not executed. Help please solve this problem.
I tried to look with the help of EXPLAIN
, which is not so, and I realized that the first index is not very good:
However, it is not yet clear how to optimize. Went here: 5.2.1. EXPLAIN statement syntax (getting information about SELECT)
So far, too, not really helped (((At least someone, please respond! Och need help !!!
PS : added an index on the id_user
column in the friends
table and the first index became better: