Refactor database queries for Drive Ls
As reported in https://gitlab.cern.ch/cta/CTA/-/issues/1065, cta-admin drive ls
is too slow.
The querying of drive states in the catalogue is currently done like this:
const auto driveNames = m_catalogue.getTapeDriveNames();
for (const auto& driveName : driveNames) {
const auto tapeDrive = m_catalogue.getTapeDrive(driveName);
...
The methods getTapeDriveNames
and getTapeDrive
are making a DB query, so the number of round-trips to the DB is equal to number of drives + 1
.
We can reduce this to a single DB round-trip by creating a new catalogue method getTapeDrives
which has the same query as getTapeDrive
but without WHERE DRIVE_NAME = :DRIVE_NAME
at the end. Then return all drive statuses in one go (like getTapeDriveNames
does).