From: Frank B. <fb...@fo...> - 2003-11-03 16:52:01
|
Hallo, while tuning an application, I found that a "count(*)" takes rather long. This in itself would be okay, but somehow SQLObject counts two times, where one should be enough. The code in question is this: # Normal is my SQLObject # self._q.sql holds the current query, for example: # (normal.title LIKE '%beat%') allResults = len(Normal.select(self._q.sql)) print "--- after first count" ps = list(Normal.select(self._q.sql)[0,10]) print "--- after second count" # do somthing with "p in ps" here... This results in the following queries by SO: QueryOne: SELECT COUNT(*) FROM normal WHERE (normal.artist LIKE '%beat%') COUNT results: 163 --- after first count QueryOne: SELECT COUNT(*) FROM normal WHERE (normal.artist LIKE '%beat%') COUNT results: 163 Select: SELECT normal.id, normal.description, ... FROM normal WHERE (normal.artist LIKE '%beat%') LIMIT 10 --- after second count I'd expect that "len(Normal.select(self._q.sql)" will do a count(*), but why the second one? I tried to force a single limit-query by using list(). How could I get at the count of all results without doing several SQLs for each result? ciao -- Frank Barknecht _ ______footils.org__ |