Hello all,
here is the query I’m executing:
mysql> explain SELECT profile_id FROM search_region AS p FORCE INDEX (region_prof_links) WHERE region_id=3866 ORDER BY links DESC;
±—±------------±------±-----±------------------±---- --------------±--------±------±---------±--------------- --------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
±—±------------±------±-----±------------------±---- --------------±--------±------±---------±--------------- --------------------------+
| 1 | SIMPLE | p | ref | region_prof_links | region_prof_links | 5 | const | 12758122 | Using where; Using index; Using filesort |
±—±------------±------±-----±------------------±---- --------------±--------±------±---------±--------------- --------------------------+
and as you can see its not really greate cause it takes about 250 sec to execute…
Here are the indexes for the table search_region:
mysql> show index from search_region;
±--------------±-----------±-------------------------±-- -----------±------------±----------±------------±------- --±-------±-----±-----------±--------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
±--------------±-----------±-------------------------±-- -----------±------------±----------±------------±------- --±-------±-----±-----------±--------+
| search_region | 0 | region_profid | 1 | region_id | A | 18 | NULL | NULL | YES | BTREE | |
| search_region | 0 | region_profid | 2 | profile_id | A | 122008563 | NULL | NULL | YES | BTREE | |
| search_region | 1 | prof_id | 1 | profile_id | A | 122008563 | NULL | NULL | YES | BTREE | |
| search_region | 1 | region_prof_links | 1 | region_id | A | 18 | NULL | NULL | YES | BTREE | |
| search_region | 1 | region_prof_links | 2 | profile_id | A | 122008563 | NULL | NULL | YES | BTREE | |
| search_region | 1 | region_prof_links | 3 | links | A | 122008563 | NULL | NULL | YES | BTREE | |
| search_region | 1 | f_country_region_links | 1 | first_name | A | 18 | NULL | NULL | YES | BTREE | |
| search_region | 1 | f_country_region_links | 2 | country_id | A | 18 | NULL | NULL | | BTREE | |
| search_region | 1 | f_country_region_links | 3 | region_id | A | 74304 | NULL | NULL | YES | BTREE | |
| search_region | 1 | f_country_region_links | 4 | links | A | 521404 | NULL | NULL | YES | BTREE | |
| search_region | 1 | l_country_region_links | 1 | last_name | A | 30502140 | NULL | NULL | YES | BTREE | |
| search_region | 1 | l_country_region_links | 2 | country_id | A | 30502140 | NULL | NULL | | BTREE | |
| search_region | 1 | l_country_region_links | 3 | region_id | A | 61004281 | NULL | NULL | YES | BTREE | |
| search_region | 1 | l_country_region_links | 4 | links | A | 122008563 | NULL | NULL | YES | BTREE | |
| search_region | 1 | f_l_country_region_links | 1 | first_name | A | 18 | NULL | NULL | YES | BTREE | |
| search_region | 1 | f_l_country_region_links | 2 | last_name | A | 61004281 | NULL | NULL | YES | BTREE | |
| search_region | 1 | f_l_country_region_links | 3 | country_id | A | 61004281 | NULL | NULL | | BTREE | |
| search_region | 1 | f_l_country_region_links | 4 | region_id | A | 122008563 | NULL | NULL | YES | BTREE | |
| search_region | 1 | f_l_country_region_links | 5 | links | A | 122008563 | NULL | NULL | YES | BTREE | |
| search_region | 1 | f_profid_region | 1 | first_name | A | 316905 | NULL | NULL | YES | BTREE | |
| search_region | 1 | f_profid_region | 2 | profile_id | A | 122008563 | NULL | NULL | YES | BTREE | |
| search_region | 1 | f_profid_region | 3 | region_id | A | 122008563 | NULL | NULL | YES | BTREE | |
| search_region | 1 | l_profid_region | 1 | last_name | A | 968321 | NULL | NULL | YES | BTREE | |
| search_region | 1 | l_profid_region | 2 | profile_id | A | 122008563 | NULL | NULL | YES | BTREE | |
| search_region | 1 | l_profid_region | 3 | region_id | A | 122008563 | NULL | NULL | YES | BTREE | |
| search_region | 1 | f_l_profid_region | 1 | first_name | A | 1544412 | NULL | NULL | YES | BTREE | |
| search_region | 1 | f_l_profid_region | 2 | last_name | A | 122008563 | NULL | NULL | YES | BTREE | |
| search_region | 1 | f_l_profid_region | 3 | profile_id | A | 122008563 | NULL | NULL | YES | BTREE | |
| search_region | 1 | f_l_profid_region | 4 | region_id | A | 122008563 | NULL | NULL | YES | BTREE | |
±--------------±-----------±-------------------------±-- -----------±------------±----------±------------±------- --±-------±-----±-----------±--------+
29 rows in set (6.33 sec)
Any suggestions ?