openstack team mailing list archive
-
openstack team
-
Mailing list archive
-
Message #02551
Re: Getting pagination right
This is what happens when I braindump a bunch of stuff into an
email... I get myself confused :)
I'm proposing the following. Please pick the strategy apart:
1) Pass the LIMIT and OFFSET parameters down into the database API queries
2) Add a default ORDER BY for all queries returning result sets
3) Add a "page" query parameter that would be used to calculate the
OFFSET programmatically
4) Change the concept of the "marker" parameter to refer to *the
timestamp of the initial query*
This would result in queries to the database of the following template:
SELECT * FROM <table>
WHERE created_at <= @marker AND deleted_at <= @marker
AND <additional filters>
ORDER BY <whatever>
LIMIT @pagesize OFFSET (@pagesize * (@pageno - 1));
Sorry for calling out Justin re: the order of his SQL expression. No
offense intended. I know he's a good SQL brain :)
-jay
References