[orm-devel] count vs len()
Diedrich Vorberg
diedrich at tux4web.de
Wed Mar 31 11:24:47 CEST 2004
>> SelectResults do have a len(), see next question.
>
>I was thinking that on large tables fetchall could be inefficient if the
>length is the only data point required. I recently noticed the
>DelayedResult and was thinking maybe this could yield similar results
>without a potentially expensive select statement. I'll investigate further.
>For now I'm just using the execute for the custom statement (brittle, yes
>:) ):
>
> cursor = conn.execute("SELECT COUNT(*) FROM map_items")
> return cursor.rowcount
See datasource.py:711: queryResult::__len__() It does the same thing!
The comment on the function is no longer accurate: psycopg _does_
provide rowcount!
result = ds.select(model.map_item)
return len(result)
Diedrich
--
Diedrich Vorberg <diedrich at tux4web.de> .---. / \
http://tux4web.de Tel: 02302 425269 / \ ((__-^^-,-^^-__))
\.O-O./ `-_---' `---_-'
"Unix is simple, but it takes a genius /`\_/`\ `--|o` 'o|--'
to understand the simplicity." // _ \\ \ ` /
- Dennis Ritchie | \ )|_ ): :(
/`\_`> <_/ \ :o_o:
Associate Member of the FSF #1245 \__/'---'\__/ "-"
More information about the orm-devel
mailing list