logo       

Re: Pagination of search results: msg#00024

Subject: Re: Pagination of search results
on 11/23/05 9:14 AM, n.j.saunders@xxxxxxxxx purportedly said:

> I'm writing a search engine, the results of which will displayed in
> blocks of 25, paginated. I will also display the number of records
> found (1-25 of 345).
> 
> I'm trying to determine the most efficient way to implement this.
> Since the session is dropped after the script is terminated, I'm
> ruling our cursors. Also, cursors would prevent me from retrieving the
> total number of records potentially returned from a search, and so I
> couldn't display the correct number of page links. Also, this would
> require persistent connections, which I'd like to avoid for a number
> of reasons.
> 
> The best I've come up with is "SELECT b.*, c.cnt FROM table AS b,
> (SELECT COUNT(1) AS cnt FROM table WHERE <LOTS OF CLAUSES>) AS c WHERE
> <SAME LOT OF CLAUSES> LIMIT 25 OFFSET 0"
> 
> However this means that the query is essentially getting executed
> twice for each page.
> 
> Is there any better way of implementing this? All advice gratefully received.

As I understand the query planner in PG optimizes for LIMIT, but may not be
able to work in all situations or may require some tweaking for best
performance. If performance is a big issue, the way I have found (that has
the least overall overhead) is to have the application cache results--either
in memory (stored as part of the PHP session) or as a temporary text file
tied to the session. For the latter, the tricky bit is making sure to remove
old files, and there are several ways this can be done depending on
anticipated volume and storage issues. For the former, you need to watch out
for memory issues. I tend to prefer the latter technique unless I can
guarantee that results will be small (including accumulated storage from
multiple simultaneous sessions).

Best regards,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe