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

number of database queries #4

Closed
clime opened this issue Apr 20, 2013 · 4 comments
Closed

number of database queries #4

clime opened this issue Apr 20, 2013 · 4 comments

Comments

@clime
Copy link

clime commented Apr 20, 2013

There is a significant performance hit for making SELECT for each cell in gridCluster and kmeansCluster. Have you thought about reducing it to just one (or a few) queries? I am not completely sure that it is possible but I feel it should be and it would improve performance greatly (especially if you have lots of cells). Have you thought about it? I am looking for a way to do it but I would like to hear from you first what you think.

@biodiv
Copy link
Owner

biodiv commented Apr 21, 2013

For the kmeans method, this should be possible and is an interesting idea. One would have to calculate the number of visible cells and then get the number of clusters with k*cellcount. After that, only one SELECT would be needed, targeting the current (grid)bounds instead of each grid cell. Furthermore, this would reduce the amount of times the distance cluster has to be run. I will give that a try. Thank you for this input.

For the gridCluster I currently don't know how the amount of SELECT could be reduced, but that does not mean it is not possible. If you (or anyone else) knows a solution it would be highly appreciated.

@biodiv
Copy link
Owner

biodiv commented Jun 4, 2014

I might have found a way querying the database only once by using a grid calculated by a postgis function:
http://gis.stackexchange.com/questions/16374/how-to-create-a-regular-polygon-grid-in-postgis
Hopefully I will find the time to test this.

@biodiv
Copy link
Owner

biodiv commented Jul 9, 2014

query amount reduced using temporary tables

@biodiv biodiv closed this as completed Jul 9, 2014
@clime
Copy link
Author

clime commented Jul 16, 2014

Good job. I can't test because i am on travels but good job.

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

No branches or pull requests

2 participants