zuul/zuul/driver/sql
James E. Blair 95bd778fcc Split build/buildset list queries into two
The only way to get reasonable performance out of all three databases
(mariadb, mysql, postgres) appears to be to make the following changes:

* Use group-by instead of distinct.
  Some versions of mysql produce the wrong output with distinct;
  this is more descriptive of what we want anyway.
* Split the query into two statements instead of joining on a subquery.
  Mariadb seems to be unable to produce a good query plan for the
  buildset list query.  Neither mariadb nor mysql support using
  "IN" with a subquery (so the idea of using IN instead of JOIN for
  the subquery is out).

These methods now perform a query to get the ids of the builds or
buildsets that match the criteria, then perform a second query to load
the ORM objects that match those ids.  This appears to be quite
fast for all three queries with the latest versions of all three database
systems.

Change-Id: I30bb3214807dfa8b26a848f85bb7a7bc660c6c1d
2024-04-09 06:39:08 -07:00
..
alembic Add a build-times web endpoint 2024-01-03 13:06:07 -08:00
__init__.py Required SQL reporters 2021-02-03 13:41:55 -08:00
alembic.ini Add alembic.ini 2018-01-09 18:13:09 +01:00
sqlconnection.py Split build/buildset list queries into two 2024-04-09 06:39:08 -07:00
sqlreporter.py Finish circular dependency refactor 2024-02-09 07:39:40 -08:00