Admin list runs query for each claim
I turned on the SQLAlchemy debug thing to look why the admin screen takes so long to load, and was surprised to see many of these queries, one for each claim it seems:
<query statement="SELECT claim.id AS claim_id, claim.export_id AS claim_export_id, claim.cover_id AS claim_cover_id, claim.name AS claim_name, claim.email AS claim_email, claim.phone AS claim_phone, claim.iban AS claim_iban, claim.amount AS claim_amount, claim.packaging_deposit_in AS claim_packaging_deposit_in, claim.packaging_deposit_out AS claim_packaging_deposit_out, claim.committee_id AS claim_committee_id, claim.description AS claim_description, claim.receipt_name AS claim_receipt_name, claim.submitted AS claim_submitted, claim.updated AS claim_updated, claim.status_code AS claim_status_code, claim.parent_id AS claim_parent_id
FROM claim
WHERE %s = claim.parent_id" parameters=(453L,) duration=0.001>
I haven't been able to find the origin of the query yet.
Comments (4)
-
reporter -
reporter - marked as enhancement
Not really a bug yet, more of a probable issue once Reclaim has been used more.
Possible work-around: pagination, since this seems to be related to code in the templates that queries whether a row has sub-rows.
-
This is (partially) due to improper use of sqlalchemy. For years, I've been thinking that the relationship property loaded everything by default. That is not the case, it only queries the DB the first time the relationship is accessed, and then caches the data. The current implementation uses dynamic queries, which are not cached, so I can cut the amount of queries used in half by switching from dynamic loading to the default lazy loading. It will still run a query for every claim though.
-
- changed status to resolved
Have better control about relationship loading. Resolves issue
#13→ <<cset d6a68cf089ab>>
- Log in to comment
Found it. Models.py, line 107: