Re: paging through results with fetchmany()
Gerhard Haering <[email protected]> Thu, 11 Nov 2004 10:17:02 +0100
| Newsgroups | gmane.comp.python.db.pypgsql.user |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Nov 07, 2004 at 09:41:50AM -0800, Uzo Uzo wrote: > I return a set of results, which I break into multiple pages. This > is how I have implemented, but I feel that it is too expensive in > terms of execution. Is there anyway to tell PgSQL to start fetching > from a particular number? > > c.execute(Query) > c.fetchmany( (pagenum-1)*NumPerPage) # skip previous results > c.fetchmany(NumPerPage) # fetch for page Looks like you want the LIMIT and OFFSET parameters for SELECT. http://www.postgresql.org/docs/current/interactive/sql-select.html -- Gerhard -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail?
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFBky4OdIO4ozGCH14RApGtAKC9ILkNWav5LeCFs70/J3vtVhNtzgCeK1sA vtqq1y/DMkg1yjQhlBIdtf0= =F0SE -----END PGP SIGNATURE-----