the query is ugly;
seems count(1) counts the decart-product or something:
SA: INFO SELECT count(1) AS count_1
FROM "Otnoshenie", mm_nazn2rabmesto, mm_nazn2pozicia, mm_pozicia2otdel,
mm_otdel2otdel AS mm_otdel2otdel, mm_otdel2otdel AS mm_otdel2otdel1,
mm_otdel2otdel AS mm_otdel2otdel2, "PVOwnership" JOIN "ParamValue"
ON "PVOwnership".param_value_id = "ParamValue".db_id
WHERE "ParamValue".time_trans <= ? AND "ParamValue".time_valid >= ?
AND "ParamValue".time_valid <= ? AND ("Otnoshenie".db_id
= "PVOwnership"."_AbstractNaznachenie_id" OR "Otnoshenie".db_id =
mm_nazn2rabmesto.left_id AND mm_nazn2rabmesto.right_id
= "PVOwnership"."_Rabotno_miasto_id" OR "Otnoshenie".db_id =
mm_nazn2pozicia.left_id AND (mm_nazn2pozicia.right_id
= "PVOwnership"."_Pozicia_id" OR mm_nazn2pozicia.right_id =
mm_pozicia2otdel.left_id AND (mm_pozicia2otdel.right_id
= "PVOwnership"."_Otdel_id" OR mm_pozicia2otdel.right_id =
mm_otdel2otdel.left_id AND (mm_otdel2otdel.right_id
= "PVOwnership"."_Otdel_id" OR mm_otdel2otdel.right_id =
mm_otdel2otdel1.left_id AND (mm_otdel2otdel1.right_id
= "PVOwnership"."_Otdel_id" OR mm_otdel2otdel1.right_id =
mm_otdel2otdel2.left_id AND mm_otdel2otdel2.right_id
= "PVOwnership"."_Otdel_id"))))) AND "PVOwnership".param_value_id
= "ParamValue".db_id AND "Otnoshenie".obj_id_id = ?
that's 3 levels: 4752
4 levels: 14256
5 levels: 42768
.. 8 levels: 1154736
while there are 57 rows total.
anyway, i didnt need count, just tried it.
this thing is a instance-level value-inheritance chain, where some parameter
can be present anywhere on the "nodes", and the nearest visible one should be
taken.
This as a const-level recursion takes forever for levels>=5, i'm wondering
should i try nested-sets, or directly to try organise & maintain some cache
whats visible on each node.
On Sunday 06 July 2008 18:47, Michael Bayer wrote:
> On Jul 6, 2008, at 11:33 AM, [EMAIL PROTECTED] wrote:
> > i have some tree-walking query via many2many, having configurable
> > levels of
> > hops to look into.
> > and it returns very different results for len(query) and
> > query.count(): len()
> > stays constant above the depth of the tree (correct), while .count()
> > keeps
> > growing an growing.
> > what's can be wrong?
>
> the generated SQL will tell all, lately ive been partial towards:
>
> sess.query(func.count(func.distinct(MyClass.id))).<other
> criterion>.first()
>
> since the way count() is determined can be controlled accurately.
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---