Project

General

Profile

action #94667

Updated by tinita over 3 years ago

## Motivation 

 The SQL to fetch the data is inefficient. For each item in the result set another `SELECT FROM job_settings` is executed. For https://openqa.suse.de/admin/test_suites that means about 2500 SELECTs currently. 
 Also the costly DateTime columns are fetched, although they are not needed. 

 ## Acceptance criteria 

 * AC1: the number of SQL queries doesn't depend on the number of items in the table anymore 
 * AC2: Less columns are fetched 

 ## Suggestions 

 * All three `/api/v1/products`, `/api/v1/machines`, `/api/v1/test_suites` are handled by the same code in `lib/OpenQA/WebAPI/Controller/API/V1/Table.pm` 
 * Enable `DBIC_TRACE=1` environment variable to see all SQL 
 * Fetch the JobSettings data in one SELECT 
 * https://github.com/os-autoinst/openQA/pull/3969 #93925 has a similar optimizations 
 * This could be a good task for someone not so familiar with DBIx::Class yet

Back