Open margrietpalm opened 2 months ago
Slow sqlites:
zevenaar.sqlite | 1858 s
Purmer_Purmerend | 2 | 830.213017
Y0254_5_BOL_purmerend | 8 | 790.278416
Y0228_Lochem_KBO | 6 | 584.664718
Hoofdgebied_uitwerking_Cluster16_hwa | 2 | 372.378615
assen_pittelo - pittelo_klimaatsom (1) | 19 | 2551.272434
assen_marsdijk - marsdijk_klimaatsom (1)
groningen-selwerd - selwerd1d2d_rwa_gecombineerd_dem_huidig (1) | 90 | 281.943609
hub_scenarioberekeningen__0d1d_test | 1 | 207.50814
marsdijk | 10 | 253.05844
westerkogge_leggertool__0d1d_test | 10 | 1784.648107
sgravendeel_riolering | 1 | 1907.207829
Biggest issue is migration 223, specifically making the polygons. For test case (zevenaar):
create_buffer_polygons
: ~6 secondscreate_square_polygons
: ~4 secondsNote that using either
backup=False
orbackup=True
does not make a noticable difference.Optimized query (works in sqlite 3.33 and newer)
Potential solution (indexes may not be necessary) that works in sqlite 3.33 and newer
journal_mode
Changing
journal_mode
toWAL
should ensure that results are not directly written to disk. Attempts so far didn't result in any changes.connection.execute(text("pragma journal_mode = WAL;"))
tomigrations/env.py::run_migrations_online
connection.execute(text("pragma journal_mode = WAL;"))
to functions that slow downn migrationother optimizations (to do)
https://phiresky.github.io/blog/2020/sqlite-performance-tuning/