linz / nz-buildings

:house: NZ Buildings | QGIS plugin and PostGIS database schema for building dataset management
https://nz-buildings.rtfd.io
Other
6 stars 2 forks source link

Slow selection of outlines #345

Open jducnuigeen opened 4 years ago

jducnuigeen commented 4 years ago

Bug Description

As an LDA doing buildings QA, during alter relationships, the user must often select individual/multiple outlines while making changes to a relationship. This action queries the db, checking the added/removed table, checking the matched table, and checking the related table. Performance/response of the database to these selections can be slow, sometimes upwards of 10 seconds per selection. Investigate if there is a way to speed up selection (possibly using the layers already loaded).

Acceptance Criteria:

Desktop

YingtingChen commented 4 years ago

related function: https://github.com/linz/nz-buildings/blob/master/buildings/gui/alter_building_relationships.py#L302

(possibly using the layers already loaded)

Just had a try using the layers (in the pic). Those layers are views which only have either bulk_load_outline_id or building_outline_id. So for those added or removed outlines we can check if the id is in the layer. But matched or related outlines will still need to query the db as we want all the corresponding outlines

image

Or we could add another column in the view e.g. related_bulk_load_outlines

bulk_load_outline_id related (jsonb)
2033 {"bulk_load_outline_id": [2033, 2034], "building_outline_id": [1023, 1033]}

this way we could get all the information through the layers not db