Thanks Richard. Not heavy use sites as they are business to business or management tool sites.
On Feb 8, 5:31 pm, Richard Vézina <ml.richard.vez...@gmail.com> wrote: > If your query don't involve joins, why not making to request to database? > > If you don't have a heavy load site I don't think you will have speed issue > by doing it that way... > > web2py make a lot of request to database if you use represent (one request > per row) since the lambda is attached to a record... > > Richard > > > > > > > > On Wed, Feb 8, 2012 at 5:15 PM, Cliff <cjk...@gmail.com> wrote: > > I'm building my own record counter and paginator for index functions, > > like this: > > > 'records 1 - 20 of 315 found by query' > > > The question is what is the best way to get the total record count, in > > this case 315. In the case above, I use a limitby(0, 20) to get the > > first 20 records. > > > I can think of two ways to do it, but I don't like either one. First > > is to formulate the query without the limitby clause and do a > > db(query).count(). That would give me the total number of records in > > the set. Then add the limitby clause to the query to get the records > > of interest. I don't like this because it involves two hits to the > > database. > > > The second way is to get the entire record set by running a select > > without the limitby, then letting Python take the desired slice out of > > the row set. I don't like this method because it might return a lot > > of rows. Thus I get the db bottleneck again plus the overhead of > > turning all of the rows into Web2py objects. > > > There must be a better solution. Can some kind soul tell me what it > > might be? > > > All opinions welcome. > > > Thanks, > > Cliff Kachinske