On Fri, May 11, 2018, 5:13 PM Jonathan Vanasco <[email protected]>
wrote:
> I tracked down a pattern that has been causing some bottleneck issues in
> an app. I'm hoping there may be a way to handle this, but for once I don't
> expect there to be!
>
> The problem arises when I fetch a specific "light" query with joined
> objects (however toplevel objects have the same issue).
>
> foo =
> s.query(Foo).options(sqlalchemy.orm.joinedload('bar').load_only('name')).filter(Foo.id==2)
>
> Later on, I might request the same bar I had loaded using `get`
>
> bar = s.query(Bar).get(id=22)
>
> If I happen to grab a Bar that was loaded off a load_only, every time i
> touch an attribute I talk to the database - which is what causes my slowup.
>
Attributes that were part of the load_only? Or are you referring to
attributes that weren't loaded ?
The former would be a bug. The latter, I'm not sure what you would expect
it to do. Do you want the unloaded attributes to raise attribute error?
Or did you want the get() to fully refresh what was not loaded (that is
doable).
> I don't necessarily want to call expunge_all() or expunge, because I might
> still access that object.
>
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
>
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.