5 Ocak 2025 Pazar

LIMIT ve Covering Index + Subquery

Örnek
Şöyle yaparız
SELECT t1.name, t1.age, t1.gender, t1.create_time FROM student as t1 
  INNER JOIN 
   (SELECT id FROM student ORDER BY create_time DESC LIMIT 1000000,10) AS t2 ON t1.id = t2.id;
Açıklaması şöyle
The key lies in that the subquery only retrieves the primary key IDs. By taking advantage of the index coverage technique, it first accurately locates a small number of primary key IDs that meet the conditions, and then queries based on these primary key IDs later, which significantly improves the query efficiency and reduces the query cost.

Hiç yorum yok:

Yorum Gönder

LIMIT ve Covering Index + Subquery

Örnek Şöyle yaparız SELECT t1.name, t1.age, t1.gender, t1.create_time FROM student as t1    INNER JOIN     (SELECT id FROM student ORDER BY ...