On May 30, 2006, at 8:05 PM, Brad Clements wrote:
Is it safe to change sql.py/ FromClause and TableClause count() to
use a
different label than "count"?
ive just changed it to "rowcount".
Since in this case, the count method is returning it's value, the
actual label used
doesn't seem to matter.
well....technically those count() methods at the SQL level return the
select() which you typically call scalar() on, but there could be
some people doing x = table.count().execute().fetchone()['count'],
but im sure its few if any.
Also, Firebird only allows
count(*)
or
count(column_ref)
So I am not sure how
func.count(1)
is supposed to be handled.
the idea of count(1) is that some databases like Oracle can optimize
count(1) much better than count(*), where the latter forces it to
queue up all the columns internally during the operation and the
former does not. other databases like count(*) better. for now i
changed it to something less controversial which is just to use the
first primary key column, or the first column if no pk col is present:
SELECT count(users.user_id) AS rowcount
Where in the engine do I override the handling of count? I couldn't
trace much
beyond sql.FunctionGenerator.
currently its just visit_function() in the ANSICompiler, which is too
generic of a place to add special behavior..so id have to add a new
"count" contstruct with its own compilation rules. count(*) should
be its own construct that the ANSICompiler can visit, so that other
dialects can override how its performed....although just fetching the
first PK column is probably all we need for a basic general-purpose
table counter.
-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users