Closed dracos closed 10 months ago
Merging #406 (13486c3) into master (f24a55c) will increase coverage by
0.17%
. Report is 1 commits behind head on master. The diff coverage is93.10%
.:exclamation: Current head 13486c3 differs from pull request most recent head 1536fe9. Consider uploading reports for the commit 1536fe9 to get more accurate results
@@ Coverage Diff @@
## master #406 +/- ##
==========================================
+ Coverage 74.66% 74.83% +0.17%
==========================================
Files 45 47 +2
Lines 2759 2782 +23
==========================================
+ Hits 2060 2082 +22
- Misses 699 700 +1
Files | Coverage Δ | |
---|---|---|
mapit/migrations/0005_geometrysubdivided.py | 100.00% <100.00%> (ø) |
|
mapit/migrations/0006_auto_20230523_0940.py | 100.00% <100.00%> (ø) |
|
mapit/models.py | 86.02% <93.33%> (+0.31%) |
:arrow_up: |
mapit/views/areas.py | 72.53% <66.66%> (ø) |
This creates a table containing the same areas as the Geometry table, but split using ST_Subdivide. This is updated on save, and is used for postcode/point lookups, as well as geometry intersection. This makes things quicker:
Below merged:
Also I spotted an st_collect that doesn't seem necessary and actually makes things slower: ``` mapit=# explain analyze WITH target AS MATERIALIZED ( SELECT ST_Transform( (select st_collect(polygon) from mapit_geometry where area_id=2643 group by area_id), 4326) AS division ) SELECT "mapit_postcode"."id", "mapit_postcode"."postcode", "mapit_postcode"."location"::bytea FROM mapit_postcode, target WHERE ST_CoveredBy(location, target.division) LIMIT 1 ; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Limit (cost=2318.48..2346.47 rows=1 width=43) (actual time=1478.528..1478.534 rows=1 loops=1) CTE target -> Result (cost=2217.96..2242.97 rows=1 width=32) (actual time=503.701..503.704 rows=1 loops=1) InitPlan 1 (returns $0) -> GroupAggregate (cost=0.42..2217.96 rows=466 width=36) (actual time=23.618..23.621 rows=1 loops=1) Group Key: mapit_geometry.area_id -> Index Scan using mapit_geometry_area_id on mapit_geometry (cost=0.42..1571.26 rows=467 width=14030) (actual time=0.024..0.983 rows=508 loops=1) Index Cond: (area_id = 2643) -> Nested Loop (cost=75.51..56226.67 rows=2006 width=43) (actual time=1478.526..1478.528 rows=1 loops=1) -> CTE Scan on target (cost=0.00..0.02 rows=1 width=32) (actual time=512.482..512.482 rows=1 loops=1) -> Bitmap Heap Scan on mapit_postcode (cost=75.51..55973.89 rows=201 width=43) (actual time=966.017..966.018 rows=1 loops=1) Filter: st_coveredby(location, target.division) Rows Removed by Filter: 309 Heap Blocks: exact=42 -> Bitmap Index Scan on postcodes_postcode_location_id (cost=0.00..75.46 rows=2006 width=0) (actual time=1.965..1.965 rows=14915 loops=1) Index Cond: (location @ target.division) Planning Time: 0.272 ms Execution Time: 1482.774 ms (18 rows) mapit=# explain analyze WITH target AS MATERIALIZED ( SELECT ST_Transform(mapit_geometry.polygon, 4326) AS division FROM mapit_geometry WHERE area_id = 2643 ) SELECT "mapit_postcode"."id", "mapit_postcode"."postcode", "mapit_postcode"."location"::bytea FROM mapit_postcode, target WHERE ST_CoveredBy(location, target.division) LIMIT 1 ; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=13246.67..13271.92 rows=1 width=43) (actual time=20.491..20.493 rows=1 loops=1) CTE target -> Index Scan using mapit_geometry_area_id on mapit_geometry (cost=0.42..13246.26 rows=467 width=32) (actual time=15.025..19.839 rows=21 loops=1) Index Cond: (area_id = 2643) -> Nested Loop (cost=0.41..23647896.06 rows=936571 width=43) (actual time=20.489..20.489 rows=1 loops=1) -> CTE Scan on target (cost=0.00..9.34 rows=467 width=32) (actual time=15.030..19.878 rows=21 loops=1) -> Index Scan using postcodes_postcode_location_id on mapit_postcode (cost=0.41..50385.17 rows=201 width=43) (actual time=0.028..0.028 rows=0 loops=21) Index Cond: (location @ target.division) Filter: st_coveredby(location, target.division) Planning Time: 0.265 ms Execution Time: 22.019 ms (11 rows) ```