Welcome Guest, Not a member yet? Register   Sign In
Pagination Algorithms
#5

[eluser]kurucu[/eluser]
Thanks for all the responses so far. I can see that the functions for total pages and the page you want given a particular post are similar.

However, my problem I think really lies within the fact that it is hard to find the number of posts up to the one you want.

The ID is not useful because posts may be moved between threads for moderation. Is there a method to find the row number and select based on that?

Come to think of it... is it as simple as selecting all posts in the thread before the given post date?

So, something based on this method would be:

Code:
Run count(*) queries to find total_post_count and posts_before_current (based on post dates)

total_pages = ceil( total_post_count / posts_per_page )
desired_page = floor( posts_before_current / posts_per_page)

Select first posts_per_page starting at desired_page

Would that be quite a quick set of queries to perform regularly?

-----

As a bit of background, I settled for a threaded system that specifies parent_id to give hierarchy. I've read about other tree methods that use incremental boundary numbers but, while slick, looked impossible to maintain. I only provide one view at present: linear chronological; but I'll keep my mind open so that a threaded output can be shown if I don't have to use recursive queries.

I have a thread table, rather than relying on selecting the ultimate parent from the post table, just for speed when viewing/searching, and to store one-off thread meta data.

It took me a lot of pondering on how to do it efficiently while still offering reasonable features! I think this model works well. I left-join user information to the posts result to show signatures, usernames etc. I considered loading a user cache for each thread, but decided this was more efficient. I may be wrong!


Messages In This Thread
Pagination Algorithms - by El Forum - 09-01-2009, 06:24 AM
Pagination Algorithms - by El Forum - 09-01-2009, 06:50 AM
Pagination Algorithms - by El Forum - 09-01-2009, 06:56 AM
Pagination Algorithms - by El Forum - 09-01-2009, 07:25 AM
Pagination Algorithms - by El Forum - 09-01-2009, 08:30 AM
Pagination Algorithms - by El Forum - 09-01-2009, 09:45 AM
Pagination Algorithms - by El Forum - 09-02-2009, 02:23 AM
Pagination Algorithms - by El Forum - 09-02-2009, 03:58 AM
Pagination Algorithms - by El Forum - 09-02-2009, 09:28 AM
Pagination Algorithms - by El Forum - 09-02-2009, 02:30 PM
Pagination Algorithms - by El Forum - 09-03-2009, 03:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB