DemocracyClub / UK-Polling-Stations

:earth_africa: A website to help people find their UK polling station
https://wheredoivote.co.uk/
BSD 3-Clause "New" or "Revised" License
33 stars 30 forks source link

MOAR performance improvements in import scripts #743

Open chris48s opened 7 years ago

chris48s commented 7 years ago

Full import was so fast.. then I fixed #721 and now is crazy slow again - needs additional optimization or I wil go insane :(

idea 1:

In create_address_records_for_council(), create a list of all the local authorities which touch the target local auth then limit the search space for the spatial join where we work out the local auth to a subquery of just those areas. For example, if the target auth is Vale of Glamorgan our search space only needs to be Vale of Glamorgan, Bridgend, Cardiff and RCT, not the entire country!

idea 2:

~Try and do the lookup using ONSAD first instead of using the spatial join and then fall back to a spatial lookup only if the UPRN is not in ONSAD~ (see #746)

chris48s commented 7 years ago

Also more sophisticated approach to #720 - running these in series is also a bottleneck

In descending order of solution desirability:

chris48s commented 6 years ago

Can you use __slots__ to improve performance in import script classes? https://www.python-course.eu/python3_slots.php https://www.chrisbarra.xyz/posts/let-me-introduce-slots/