DeltaHF
Well-known member
My forum is about to hit a major milestone (10 million posts!), and I want to be able to reliably identify the post ID of the ten millionth public (non-deleted) message posted on the forum. Maybe I'm just being dense, but this problem turned out to be a bit more complicated than I anticipated.
I thought I would simply write a query to select all of the post_ids of all visible posts, and spit out the nth one:
I tested this query with known nth posts from the past (100th post, 5 millionth, etc.), to see if it returned their ID, but I found it to be several weeks off base. It's even several weeks off base when I try to use it to return the most recent post on the forum!
Is there a better way to do this?
I thought I would simply write a query to select all of the post_ids of all visible posts, and spit out the nth one:
Code:
SELECT
post_id
FROM
xf_post
WHERE
message_state = 'visible'
ORDER BY
post_id
ASC
LIMIT 10000000,1
I tested this query with known nth posts from the past (100th post, 5 millionth, etc.), to see if it returned their ID, but I found it to be several weeks off base. It's even several weeks off base when I try to use it to return the most recent post on the forum!
Is there a better way to do this?