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

Check for ID field index before querying tables via id #24

Open
acannistra opened this issue Apr 19, 2022 · 0 comments
Open

Check for ID field index before querying tables via id #24

acannistra opened this issue Apr 19, 2022 · 0 comments

Comments

@acannistra
Copy link
Contributor

This function is very, very slow on large tables without an index onosm_id. We should at the very least warn if an index doesn't exist here. This might mean we have a startup function that looks for all of the required indices (this one, and some geometry indices needed elsewhere).

def get_feature_by_id(self, layer, id, id_field):
_q = f"SELECT * from {layer} WHERE {layer}.{id_field} = {id}"
_r = self.data.ExecuteSQL(_q)
if len(_r) > 1:
warnings.warn(
f"More than one ID match for {id_field}:{id} (layer: {layer})"
)
return _r.GetNextFeature()

We could also add the index, but that's harder..

@acannistra acannistra changed the title Check for osm_id index before querying tables via osm_id Check for ID field index before querying tables via id Apr 19, 2022
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

1 participant