Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request to add query optimization #17

Open
zabano opened this issue Jun 16, 2016 · 1 comment
Open

request to add query optimization #17

zabano opened this issue Jun 16, 2016 · 1 comment

Comments

@zabano
Copy link

zabano commented Jun 16, 2016

Hi Colton,

Thank you for developing this great package. I am very grateful.
Would it be possible to add some query optimization to the get_collection (and get_resource) method based on the included resources? for example, i added the following code to line 621 of serializer.py.

for local in include.keys():
  if local:
      loader = joinedload(local)
      for remote in include[local]:
          if '.' in remote:
              for r in remote.split('.'):
                  loader.joinedload(r)
          else:
              loader.joinedload(remote)
      collection = collection.options(loader)

Thanks,
Omar

@zabano zabano changed the title request to add query optimization to get_collection request to add query optimization Jun 16, 2016
@ColtonProvias
Copy link
Owner

Definitely! I'm a fan of optimization. I noticed one fork of this project even has caching within get_collection and I want to implement that as well.

(Note to self on location of joinedload in SQLAlchemy: http://docs.sqlalchemy.org/en/latest/orm/loading_relationships.html#sqlalchemy.orm.joinedload)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants