MySQL Data - Best way to implement paging?

后端 未结 7 1118
灰色年华
灰色年华 2020-11-22 09:32

My iPhone app connects to my PHP web service to retrieve data from a MySQL database. A request can return 500 results.

What is the best way to implement paging and r

7条回答
  •  孤街浪徒
    2020-11-22 10:09

    Query 1: SELECT * FROM yourtable WHERE id > 0 ORDER BY id LIMIT 500

    Query 2: SELECT * FROM tbl LIMIT 0,500;

    Query 1 run faster with small or medium records, if number of records equal 5,000 or higher, the result are similar.

    Result for 500 records:

    Query1 take 9.9999904632568 milliseconds

    Query2 take 19.999980926514 milliseconds

    Result for 8,000 records:

    Query1 take 129.99987602234 milliseconds

    Query2 take 160.00008583069 milliseconds

提交回复
热议问题