{"action":"created","issue":{"url":"https://api.github.com/repos/TabbycatDebate/tabbycat/issues/676","repository_url":"https://api.github.com/repos/TabbycatDebate/tabbycat","labels_url":"https://api.github.com/repos/TabbycatDebate/tabbycat/issues/676/labels{/name}","comments_url":"https://api.github.com/repos/TabbycatDebate/tabbycat/issues/676/comments","events_url":"https://api.github.com/repos/TabbycatDebate/tabbycat/issues/676/events","html_url":"https://github.com/TabbycatDebate/tabbycat/issues/676","id":337741102,"node_id":"MDU6SXNzdWUzMzc3NDExMDI=","number":676,"title":"Optimise N+1 end points","user":{"login":"philipbelesky","id":495961,"node_id":"MDQ6VXNlcjQ5NTk2MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/495961?v=4","gravatar_id":"","url":"https://api.github.com/users/philipbelesky","html_url":"https://github.com/philipbelesky","followers_url":"https://api.github.com/users/philipbelesky/followers","following_url":"https://api.github.com/users/philipbelesky/following{/other_user}","gists_url":"https://api.github.com/users/philipbelesky/gists{/gist_id}","starred_url":"https://api.github.com/users/philipbelesky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philipbelesky/subscriptions","organizations_url":"https://api.github.com/users/philipbelesky/orgs","repos_url":"https://api.github.com/users/philipbelesky/repos","events_url":"https://api.github.com/users/philipbelesky/events{/privacy}","received_events_url":"https://api.github.com/users/philipbelesky/received_events","type":"User","site_admin":false},"labels":[{"id":404828755,"node_id":"MDU6TGFiZWw0MDQ4Mjg3NTU=","url":"https://api.github.com/repos/TabbycatDebate/tabbycat/labels/performance","name":"performance","color":"AB6D1B","default":false}],"state":"open","locked":false,"assignee":{"login":"czlee","id":1725499,"node_id":"MDQ6VXNlcjE3MjU0OTk=","avatar_url":"https://avatars2.githubusercontent.com/u/1725499?v=4","gravatar_id":"","url":"https://api.github.com/users/czlee","html_url":"https://github.com/czlee","followers_url":"https://api.github.com/users/czlee/followers","following_url":"https://api.github.com/users/czlee/following{/other_user}","gists_url":"https://api.github.com/users/czlee/gists{/gist_id}","starred_url":"https://api.github.com/users/czlee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/czlee/subscriptions","organizations_url":"https://api.github.com/users/czlee/orgs","repos_url":"https://api.github.com/users/czlee/repos","events_url":"https://api.github.com/users/czlee/events{/privacy}","received_events_url":"https://api.github.com/users/czlee/received_events","type":"User","site_admin":false},"assignees":[{"login":"czlee","id":1725499,"node_id":"MDQ6VXNlcjE3MjU0OTk=","avatar_url":"https://avatars2.githubusercontent.com/u/1725499?v=4","gravatar_id":"","url":"https://api.github.com/users/czlee","html_url":"https://github.com/czlee","followers_url":"https://api.github.com/users/czlee/followers","following_url":"https://api.github.com/users/czlee/following{/other_user}","gists_url":"https://api.github.com/users/czlee/gists{/gist_id}","starred_url":"https://api.github.com/users/czlee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/czlee/subscriptions","organizations_url":"https://api.github.com/users/czlee/orgs","repos_url":"https://api.github.com/users/czlee/repos","events_url":"https://api.github.com/users/czlee/events{/privacy}","received_events_url":"https://api.github.com/users/czlee/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/TabbycatDebate/tabbycat/milestones/35","html_url":"https://github.com/TabbycatDebate/tabbycat/milestone/35","labels_url":"https://api.github.com/repos/TabbycatDebate/tabbycat/milestones/35/labels","id":3463941,"node_id":"MDk6TWlsZXN0b25lMzQ2Mzk0MQ==","number":35,"title":"Performance","description":"","creator":{"login":"philipbelesky","id":495961,"node_id":"MDQ6VXNlcjQ5NTk2MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/495961?v=4","gravatar_id":"","url":"https://api.github.com/users/philipbelesky","html_url":"https://github.com/philipbelesky","followers_url":"https://api.github.com/users/philipbelesky/followers","following_url":"https://api.github.com/users/philipbelesky/following{/other_user}","gists_url":"https://api.github.com/users/philipbelesky/gists{/gist_id}","starred_url":"https://api.github.com/users/philipbelesky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philipbelesky/subscriptions","organizations_url":"https://api.github.com/users/philipbelesky/orgs","repos_url":"https://api.github.com/users/philipbelesky/repos","events_url":"https://api.github.com/users/philipbelesky/events{/privacy}","received_events_url":"https://api.github.com/users/philipbelesky/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":2,"state":"open","created_at":"2018-06-30T05:34:27Z","updated_at":"2018-07-04T23:40:09Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2018-07-03T04:24:51Z","updated_at":"2018-07-06T08:04:04Z","closed_at":null,"author_association":"MEMBER","body":"This is an ongoing tracker for identifying/discussing these views, although scout doesn't actually identify many over the 150ms threshold so they could definitely all be ticked off. None are egregious in terms of execution time (except for `/database/participants/adjudicator/`) but it would be nice to improve them:\r\n\r\n- [ ] `tournaments.views.TournamentAdminHomeView`\r\n- [ ] `tournaments.views.TournamentAssistantHomeView`\r\n- [ ] `adjallocation.views.SaveDebatePanel`\r\n- [ ] `results.views.AdminNewBallotSetView` + `results.views.AdminEditBallotSetView`\r\n- [ ] `django.contrib.admin.options.changelist_view` for `/database/participants/adjudicator/`"},"comment":{"url":"https://api.github.com/repos/TabbycatDebate/tabbycat/issues/comments/402959251","html_url":"https://github.com/TabbycatDebate/tabbycat/issues/676#issuecomment-402959251","issue_url":"https://api.github.com/repos/TabbycatDebate/tabbycat/issues/676","id":402959251,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMjk1OTI1MQ==","user":{"login":"czlee","id":1725499,"node_id":"MDQ6VXNlcjE3MjU0OTk=","avatar_url":"https://avatars2.githubusercontent.com/u/1725499?v=4","gravatar_id":"","url":"https://api.github.com/users/czlee","html_url":"https://github.com/czlee","followers_url":"https://api.github.com/users/czlee/followers","following_url":"https://api.github.com/users/czlee/following{/other_user}","gists_url":"https://api.github.com/users/czlee/gists{/gist_id}","starred_url":"https://api.github.com/users/czlee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/czlee/subscriptions","organizations_url":"https://api.github.com/users/czlee/orgs","repos_url":"https://api.github.com/users/czlee/repos","events_url":"https://api.github.com/users/czlee/events{/privacy}","received_events_url":"https://api.github.com/users/czlee/received_events","type":"User","site_admin":false},"created_at":"2018-07-06T08:04:04Z","updated_at":"2018-07-06T08:04:04Z","author_association":"MEMBER","body":"Hmm, I think it's the other way round. You generally can't make updating a single debate any more efficient, because (a) for the debate itself, there's no concept of an N+1 problem if you're only dealing with one row and (b) for things the debate has many of, like teams, speaker scores and team scores, in general `UPDATE` statements don't really work well with multiple rows anyway.\r\n\r\n(If you have an N+1 problem with an update, there are ways in SQL to make it more efficient, but as far as I can tell you can't collapse it into a single statement, I think you have to use `transaction.atomic()` or something. Suffice to say Django's not great with this. Or, lots of people have pointed to this: https://github.com/aykut/django-bulk-update/)\r\n\r\nI'm not fully confident about this assessment, but last time I looked at it, I felt like serialising _large_ amounts of data had a bunch of N+1 issues (3545827ae8c08acaae8f8ff03f6c0cf0ba19bca8). I think we just want to revise the framework—having `serialise()` as a method of _individual_ models doesn't really seem amenable to performance improvements. I'm imagining instead some module that is called upon with requests for information, and gathers all the relevant data using a prefetch strategy similar to `Round.debate_set_with_prefetches()`, but returning the requested JSON response. With tactful prefetches I suspect even \"expensive\" attributes can be made to run in reasonable time—some of the existing functions in prefetch.py files aren't exactly cheap, but once implemented, they seemed to make the things they affected pretty smooth."}}
{"actor":{"display_login":"czlee"}}