On Thu, Feb 09, 2006 at 10:52:03AM -0800, Uwe C. Schroeder wrote: > Depending on your keys neither. > Rather let the DB handle the resultset. count(*) is quite slow. > > How about something like > > select blablabla from _complex_query order by _key_ (optional DESC or ASC) > OFFSET xxx LIMIT 15 > > where your offset would be a parameter from the php side and is basically the > page number of the number of pages you want to display. > The only drawback of that is that you will never see the total number of hits. > So maybe you do a count(*) ONCE and then use the above query to loop over the > resultset - or you don't show the number of pages and just have a "next > results" and "previous results" button that adjusts the offset parameter. Another possibility is to put a limit of 151. If you get 151 rows you print 1 2 3 .. 8 9 10 More. If you get less you know how many pages. As you get to page 5 you can limit to 225+1. Have a nice day, -- Martijn van Oosterhout <kleptog@xxxxxxxxx> http://svana.org/kleptog/ > Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a > tool for doing 5% of the work and then sitting around waiting for someone > else to do the other 95% so you can sue them.
Attachment:
signature.asc
Description: Digital signature