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 widgets on pan // zoom #724

Open
javisantana opened this issue Aug 7, 2017 · 1 comment
Open

optimize widgets on pan // zoom #724

javisantana opened this issue Aug 7, 2017 · 1 comment

Comments

@javisantana
Copy link
Contributor

javisantana commented Aug 7, 2017

When we move the map the widgets (dataviews) data is requested again. Server side we calculate everything again, so if we have a formula widget with the count we do something like this for each request:

select count(1) from NODE_TABLE where the_geom_webmercator && USER_VIEWPORT_BBOX

this makes sense when we do the first data fetch but when the user moves the map a little bit (which is pretty common) we launch that query again even if the viewport only changes a little bit.

A possible optimization: instead of getting the count for the full USER_VIEWPORT_BBOX do the calculation for the diff between the last viewport and the new one so with basic math we could know the new count

This should work for all the widgets.

While I was thinking about this it reminded me of the WMS way to do things. WMS fetches the whole viewport image to render the map, then someone would likely thought the same thing about just calculating diffs and came up with the tiles solution (not a new idea, Slotted ALOHA was pretty successful splitting things in fixed steps). That probably means that if we have the right aggregations on tiles we would be able to calculate widgets update without hitting database.

EDIT: crossfilters.js, the library that does what our widgets to but in client side, use this technique. I'd recommend spending a little bit time on the source code (yes, arg), specifically things like this

@pramsey
Copy link

pramsey commented Sep 19, 2017

Going tile-by-tile for all tiles intersecting the viewport would be Even Better, n'est pas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants