tests/fixtures.py: be more efficient in bulk insert

Postgres supports inserting multiple rows at once which is more
efficient than the add_all() method.
queries: add resolving link alias query

A query which uses a temporary table to efficiently resolve link alias
names to link ids.