importer: file-backed staging has no where:, so water_points stages 8M rows to read 4 921 #114
Labels
No labels
blocked
claude-wip
map-report
map:is
map:se
needs-review
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
art/ismap#114
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Scope:
importer/staging.go, theload:(file-backed) staging kind.A file-backed staging table has no way to filter rows on the way in.
stagingLoadcarries
db/file/glob/layer/srs/source_srid/swap_axes/promote_to_multi/gml_points/route_types/agencies/feature— and nopredicate. So a layer that needs a handful of rows out of a large source class has to
stage the whole class first, and filter in the layer query.
What was measured (live DB, after #85 landed):
pl_oipr(BDOT10k OT_OIPR_P)źródło+ 6wodospad)That is 1 usable row in 1 630, and 2.7 GB of table plus its GiST index carried
permanently so that
water_pointscan draw 4 921 points. The rest of OIPR_P is treesand scrub, which no layer reads and no layer is likely to read — the class is a
catch-all "obiekt przyrodniczy" bucket.
Why it cannot be worked around in config today: a query-kind staging entry with
needs: [pl_oipr]can narrow the table, but only after the full load has happened —the cost being paid is the load and the intermediate table, not the final one. There is
no OGR-level attribute filter and no COPY-time predicate.
Shape of the fix: a
where:on the load, applied per source file as the rows areread (for the glob case, once per county package) rather than after the append. For
GeoPackage/OGR sources this can push down to the reader; worst case it is a row test
during the COPY append, which still avoids the table and the index.
Caveats worth deciding on:
reprojection and any promote/force — so it is a different namespace from the layer
query's. That needs to be stated in the docs or it will surprise someone.
tables useful for ad-hoc catalogue checks — the R6 checks in #85 and #84 were both
run against staging tables precisely because they held everything. Possibly the rule
should be that
where:is only for classes where the unread remainder is provablyirrelevant, and the comment has to say why.
pl_skppis the counter-example that does not need this: 2 947 rows to yield 133,a 1 MB table. The knob is for the order-of-magnitude cases, not every filter.
From the #85 review (Poland's
water_points/ferries).