Hello,
I have a program that maps a GROUP BY query to orm instances (let's say we have
one called comm1). The instances have a relationship attribute: comm1.inodes.
Something goes wrong when accessing comm1.inodes. SQLAlchemy generates a query
that doesn't have a clause for the instance's primary key, and fetches a ton of
rows from the database. The primary key doesn't appear in the result so all
those rows appear identical. The Python-level results eliminate the duplicates,
and yield the correct value.
The problem is, the query runs like a cartesian product, and if we're unlucky it
ends up consuming gigabytes of memory due to the unnecessarily repeated rows.

See https://github.com/g2p/bedup/blob/master/bedup/model.py#L204
for the declarative mapping, and see
https://github.com/g2p/bedup/issues/1#issuecomment-10637878
for an example of bad generated queries.



-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to