Migrate away from temporary tables for read queries
To do so, we import a function from a recent version of psycopg2, execute_values, which can execute queries efficiently with a list of values.
We also scale the cursor back from having things in SQL functions towards having things inside the db.py database "backend". This will make it easier to iterate, as we won't have to deploy function changes to twenty different databases.
After these changes, testing the web UI on a physical replica works.
Close swh/infra/sysadm-environment#1073 (closed)
Test Plan
Local integration tests are happy; Navigating the frontend backed by a physical replica seems to be okay now.
Migrated from D340 (view on Phabricator)