douyuben9434 2011-05-30 06:49
浏览 123
已采纳

MYSQL使用范围/限制计算所有行和数据分页

I dont know if this is a duplicate but here's my question..

I was trying to implement a pagination of data taken from database

My dilemma is:

  1. Should i go about pagination, querying data in groups, ie. 5 (doing a Select with limits/ range), then displaying them in a table with pagination. It will have page numbers so it would require counting all the table entries thus that would be 2 database queries for the initial display.or

  2. query all the row entries and then count the result set and apply pagination. This would remove the query count on the database but would also mean that i would download the whole data everytime a single view on any page is made (but i could also apply caching)

and other suggestions are highly accepted and thank you in advance

  • 写回答

1条回答 默认 最新

  • doure5236 2011-05-30 06:51
    关注

    SQL_CALC_FOUND_ROWS .

    This will allow you to use LIMIT and have the amount of rows as no limit was used.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本