In the MySQL database, when you create a composite index, you do not know which column is in front of the creation process, which column should be in the following way:
Select COUNT (Distinct first_name)/count (*) as first_name_selectivity,
COUNT (distinct last_name)/count (*) as last_name_selectivity,
COUNT (*)
From Actor\g
Mysql> Select COUNT (Distinct first_name)/count (*) as first_name_selectivity,
, COUNT (distinct last_name)/count (*) as last_name_selectivity,
COUNT (*)
From Actor\g
1. Row ***************************
first_name_selectivity:0.6400
last_name_selectivity:0.6050
COUNT (*): 200
1 row in Set (0.01 sec)
first_name_selectivity:0.6400, so the selectivity of the first_name column is higher, so the answer takes it as the first column of the indexed column:
Mysql> ALTER TABLE Yoon add key (First_name,last_name);
MySQL Create composite index