Count for pagination

From: Jason Long <jason(at)octgsoftware(dot)com>
To: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Count for pagination
Date: 2011-04-08 16:58:23
Message-ID: 1302281903.7116.45.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The main search screen of my application has pagination.

I am basically running 3 queries with the same where clause.

1. Totals for the entire results(not just the number of rows on the
first page)
a. <300 ms
2. Subset of the total records on that page.
a. 1-2 sec
3. Count of the total records for the pagination to show the number of
pages
a. 1-2 sec

The queries are generated by Hibernate and I am looking to rewrite them
in native SQL
to improve performance.

Any suggestions on how to get the count of all records that could be
returned and only
a subset of those records for that page in an optimized fashion? I
have no problem using
a widow query or a Postgres specific feature as my app only runs on
Postgres.

--
Thank you for your time,

Jason Long
CEO and Chief Software Engineer
BS Physics, MS Chemical Engineering
http://www.octgsoftware.com
HJBug Founder and President
http://www.hjbug.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Diego Schulz 2011-04-08 17:15:25 Re: Changed SSL Certificates
Previous Message Carlos Mennens 2011-04-08 16:42:05 Changed SSL Certificates