Answer the question
In order to leave comments, you need to log in
SELECT LIMIT OFFSET vs SELECT foo WHERE bar in () - which is faster?
Given a MySQL table with the following structure:
id int,
data1 varchar(300), data2 varchar(300), data3 varchar(300)... dataN varchar(300),
factor1 int,
factor2 int,
factor3 varchar(30),
factor4 tinyint(4),
factor5 datatime
...
factorN sometype
SELECT * FROM table WHERE (совокупность факторов) LIMIT 100 OFFSET N
LIMIT 100 OFFSET 750000
SELECT id FROM table WHERE (совокупность критериев)
SELECT * FROM table WHERE id in (set)
Answer the question
In order to leave comments, you need to log in
Yes, the second method can help, but only if the first request is cached.
This will really be faster, because the selection goes by the primary key without additional conditions that require iteration, and then sorting and partial selection using LIMIT / OFFSET
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question