On the use of federated Index in mysql pagination Optimization with where condition

if the table table has a federated index (sex, id)
and id itself is the primary key
, does the following sql go to the index?

select * from table where sex="m" order by id limit 1000000,10

my feeling is that according to the execution order of sql
, we should first execute from table where sex="m", to filter out the result set, and then go to order by id, so I don"t feel like I"m going to index
, so I have to

.
select * from table in (select id from table where sex="m" order by id limit 1000000,10)

is that so?

Mar.16,2021

(1) SQL statement execution order:
SELECT

 FROM          --1
    WHERE    --2
      GROUP BY   --3
        HAVING      --4
           ORDER BY  --5
           

(2) if select queries only index fields, order by index fields will use the index, otherwise it will be arranged in the whole table;
(3) if there are where conditions, such as where sex='m' order by id, order by will also use the index!


Don't ask in an EXPLAIN, post?

Menu