|
||||||
Views:
11,030,476 |
Main | FAQ | IRC chat | Memberlist | Active users | Latest posts | Stats | Ranks | Online users | Search | 11-21-24 11:52 AM |
||||
Guest: Register | Login |
0 users currently in AcmlmBoard Developer Zone | 3 bots |
Main - AcmlmBoard Developer Zone - Pagination optimizations |
Arisotura |
| ||
Developer
pancakes Level: 84 Posts: 713/1870 EXP: 5546094 Next: 115858 Since: 01-05-12 From: France Last post: 37 days Last view: 37 days |
Pagination in Acmlmboard is done with the typical 'LIMIT X,Y' statement. There's an issue with that and long threads, though.
Let's say the user requests page 200 of a thread. His posts per page setting is 20. Your query will look like this: SELECT (tons of shit) FROM posts p LEFT JOIN (several other tables) WHERE t.id=1337 LIMIT 4000,20 Which basically means that MySQL will fetch 4020 rows and discard most of them. I coded a simple solution to reduce that overhead.
This retrieves the IDs of the posts that are going to be visible. It still has the aforementioned problem, but MySQL will read from the posts table's primary index (as opposed to reading from multiple tables), so it's much less severe. Once you got the result of that, you feed it to the query that fetches all the remaining data. SELECT (tons of shit) FROM posts p LEFT JOIN (several other tables) WHERE p.id IN ($result) Another solution would consist into giving posts per-thread incrementing numbers, and base pagination on that. But this has its number of problems, especially if you find yourself wanting to merge/split threads or delete a spammer's posts. And it only works for displaying a regular thread. ____________________ Kuribo64 - melonDS want some revolution in your coffee? |
Arisotura |
| ||
Developer
pancakes Level: 84 Posts: 884/1870 EXP: 5546094 Next: 115858 Since: 01-05-12 From: France Last post: 37 days Last view: 37 days |
Main - AcmlmBoard Developer Zone - Pagination optimizations |
Acmlmboard v2.5.6 (06/11/2024) © 2005-2024 Acmlm, Emuz, et al. |
MySQL - queries: 63, rows: 475/508, time: 5.542 seconds. |