php - Most Efficient Way to do Pagination/Rough Estimate of Total Number of Rows -


i have common problem, cannot seem find answer it.

i need page's worth of rows table, enough info paginate data. in general need rough estimate of total number of rows (in general need know ceil(count()/50)).

so count() overkill. , have select * table limit 0, 50 running, if can appended command better.

i have heard sql_calc_found_rows. heard not particularly more efficient doing count yourself. "unfortunately, using sql_calc_found_rows has nasty consequence of blowing away limit optimization might happen".

so, in all, kindof think using mysql's row estimate way go. not know how that. or how off estimate might be.

note1: in situation of tables working updated few times day, not time. note2: using pdo php.

another interesting idea found:

a better design convert pager “next” link. assuming there 20 results per page, query should use limit of 21 rows , display 20. if 21st row exists in results, there’s next page, , can render “next” link.

if don't need total count of table it's indeed fastests solution.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -