-
Notifications
You must be signed in to change notification settings - Fork 156
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
Performance suggestion for random_task
view
#972
Comments
Hi @risicle What I would like to know particularly is whether you encountered performance issues before or after the switch to the new server. |
Yup, I of course don't have the ability to analyze a running system with a real life workload, so my analysis can really be taken with a pinch of salt. I've noticed speed to be an issue with the "random task" function quite often. Most recently on task 2525 this last tuesday evening, the 7th - a "random task" request was taking, maybe, 30 seconds? (leading many users to of course do the "is it doing anything? i'll click again..." thing which would exacerbate it. But of course, if that is not a bottleneck in reality this would be a pointless overcomplication to add, what with all the housekeeping needed... When was the switch to the new server? |
(have you set up postgres to log slow queries?) |
(I know very little about PostGIS so I don't have anything substantive to add, but I will point out project 2525 specifically is a bit on the extremely high side for number of tasks in a project.) |
Indeed, however it isn't the first time I've noticed this problem. If we were to ignore the pre-building-adjacency-lists route for a moment (due to the moderate amount of implementation pain), I'm assuming the current, build-a-big-union-and-then-check-disjoint-against-that technique is deliberately being used over a more obvious disjoint-join-condition technique for performance reasons. I would have thought the latter would be faster as it might be able to make use of a spatial index. Using that approach would be as simple as adding a
and again in the view this would make the
(but I haven't tried this so there may be some gotcha lurking in the above!) |
It was done on Feb 9th. As far as I know no one complained about performances issues after the switch. Anyway, thanks for your code snippet. |
Oh of course, I glossed over that extra join - it would probably be something more like, keeping the current flow of the view:
(might which is quite ugly so I personally would probably alter the behaviour of the view somewhat so that Anyway, if it's not currently a problem, it's not currently a problem, but I would recommend enabling slow query logging in case performance hiccup is reached in the future. (also in my above relationship listing, I accidentally suggested joining |
Taking a browse of the code and wondering why the "pick a random task" feature can get so slow during a mapping party it occurred to me that you could save a lot of db load by denormalizing and maintaining an adjacency table for tasks rather than performing expensive geometry operations in-query. Supposing a m2m relationship called
neighbours
,locked_filter
would become something along the lines of:which is a join postgres can do incredibly fast.
If you wanted to go a step further, it would be easily possible to denormalize the "in priority area" information into a boolean field on
Task
and entirely remove expensive geometry operations from this view.As for how to maintain the denormalized data, there are many ways to skin that cat.
(also I found this project's code pleasingly clear so 👍 there)
The text was updated successfully, but these errors were encountered: