I Have gone through some Q&A eg.
How does database indexing work?
Mysql covering vs composite vs column index
These are good reads, But I got some more question about Indexes ie. Assuming below table and Execution plans:
CREATE TABLE student(`id` INT(9),
`name` VARCHAR(50),
`rollNum` INT(9),
`address` VARCHAR(50),
`deleted` int(2) default 0,
Key `name_address_key`(`name`,`deleted`),
Key `name_key`(`name`)
);
Plan 1: explain select * from student where name = "abc" and deleted =0;
its shows key = name_address_key
Plan 2: explain select * from student where name = "abc"
its also shows same key = name_address_key
my question is : How MySQl decide the index for execution plan?