Eager load get_posts for submission_listings.
Ported in logic from upstream to use SQLAlchemy eager loading instead of repeated queries when building a submission_listing. Adjusted loaded relationships to include only those used on TheMotte. Using test data from seed_db, before and after: GET / |----------|--------|--------|--------|--------|--------|------------| | Database | SELECT | INSERT | UPDATE | DELETE | Totals | Duplicates | |----------|--------|--------|--------|--------|--------|------------| | default | 83 | 0 | 0 | 0 | 83 | 72 | |----------|--------|--------|--------|--------|--------|------------| Total queries: 83 in 0.031s GET / |----------|--------|--------|--------|--------|--------|------------| | Database | SELECT | INSERT | UPDATE | DELETE | Totals | Duplicates | |----------|--------|--------|--------|--------|--------|------------| | default | 14 | 0 | 0 | 0 | 14 | 0 | |----------|--------|--------|--------|--------|--------|------------| Total queries: 14 in 0.00718s
This commit is contained in:
parent
9953c5763c
commit
4d22d9bce2
5 changed files with 24 additions and 10 deletions
|
@ -204,7 +204,7 @@ def front_all(v, sub=None, subdomain=None):
|
|||
site=SITE
|
||||
)
|
||||
|
||||
posts = get_posts(ids, v=v)
|
||||
posts = get_posts(ids, v=v, eager=True)
|
||||
|
||||
if v:
|
||||
if v.hidevotedon: posts = [x for x in posts if not hasattr(x, 'voted') or not x.voted]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue