Hello. Does anyone know if there is a way to determine the number of rows retrieved in a result set without actually iterating over it? Any help would be greatly appreciated. Thanks. - Asad
On Wed, 14 Apr 2004 10:14:56 -0400 (EDT) Asad Habib <ahabib@engin.umich.edu> wrote:
Hello. Does anyone know if there is a way to determine the number of rows retrieved in a result set without actually iterating over it? Any help would be greatly appreciated. Thanks.
What kind of result set? SQL or catalog? for SQL it is probably best to perform a second "select count(*) from foo" query to get the count, unless the where clause is complex, in which case Python len() will be fine (and won't iterate). For catalog results, len(results) is your only choice, unless you use 'sort_limit' in which case you can use results.actual_result_count. len(results) may iterate in certain cases (like if you concatenated results for example), but should be efficient for the most part. hth, -Casey
participants (2)
-
Asad Habib -
Casey Duncan