Skip to content
This repository has been archived by the owner on May 24, 2019. It is now read-only.

Improve performance of compute_ranks country matching #282 #283

Merged
merged 1 commit into from
May 3, 2016

Conversation

jaredlockhart
Copy link
Collaborator

Rather than compare distances to every country, attempt to find a country which contains the point and fail fast. Otherwise compute distances and find the nearest one.

I compared performance between doing this in memory and letting the database do it using st_contains, and the performance with the db was every so slightly worse than the in memory case, but only slightly. However, reducing load on the db is a good thing, so I think doing it in memory should be fine. This is roughly 4 times faster than simply sorting by all distances and doing no containment checks, according to my local benchmarking.

@jaredlockhart
Copy link
Collaborator Author

@hannosch r?

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling e6a52b2 on 282 into 5fa2be8 on master.

@hannosch
Copy link
Contributor

hannosch commented May 3, 2016

@jaredkerim My comments are in #285 - code speaks more clearly :)

And yeah, the DB would have the additional R-Tree index, which is missing in the in-memory case. But it does add the extra network latency to talk to the DB each time. If the two are close in runtime, doing it locally is definitely better.

@jaredlockhart jaredlockhart merged commit 8edc7f9 into master May 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants