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

Optimize database queries #15

Open
passiomatic opened this issue Jul 20, 2013 · 1 comment
Open

Optimize database queries #15

passiomatic opened this issue Jul 20, 2013 · 1 comment
Assignees
Milestone

Comments

@passiomatic
Copy link
Owner

Several queries spawn quite a lot of subqueries due to the way they are constructed. The obvious ones in fever.py are:

  • get_feeds, see feed.icon.id
  • get_feed_groups, see s.feed.id

The underlying problem is that xxx.icon.id and xxx.feed.id fields are not formally retrieved by Peewee, even if they are there in the record, so an extra query per row is performed.

The Peewee .switch(model) method could do the trick: http://peewee.readthedocs.org/en/latest/peewee/api.html#Query.switch

@passiomatic
Copy link
Owner Author

One more optimization could be this: every time an entry listing is displayed the system requires the list of saved ids, read ids and the unread|saved|all entry listing.

A more optimized query could retrieve the unread entries and also perform a left outer join on Saved model to figure out which entry are saved or not.

In the same vein another query could retrieve the saved entries and also perform a left outer join on Read model to figure out which entry have been read or not.

Finally the query to retrieve all entries could both left outer join Saved and Read models.

@passiomatic passiomatic modified the milestones: 0.9.2, 1.0.0 Feb 25, 2014
@passiomatic passiomatic modified the milestones: 1.0.0, 0.9.2 May 7, 2014
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

1 participant