Changeset 86940 in vbox
- Timestamp:
- Nov 20, 2020 5:32:53 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/cgi/status.py
r86938 r86940 312 312 # 313 313 # Get the data. 314 # bird: I changed these to join on idGenTestBox. 315 # @todo The query isn't very efficient as postgresql probably will repeat the 316 # subselect in column 5 for each result row. 314 # 315 # Note! We're not joining on TestBoxesWithStrings.idTestBox = 316 # TestSets.idGenTestBox here because of indexes. This is 317 # also more consistent with the rest of the query. 318 # Note! The original SQL is slow because of the 'OR TestSets.tsDone' 319 # part, using AND and UNION is significatly faster because 320 # it matches the TestSetsGraphBoxIdx (index). 317 321 # 318 322 (oDb,) = self._connectToDb(); … … 320 324 return False; 321 325 326 # oDb.execute(''' 327 #SELECT TestBoxesWithStrings.sName, 328 # TestSets.enmStatus, 329 # TestSets.tsCreated, 330 # TestBoxesWithStrings.sOS, 331 # SchedGroupNames.sSchedGroupNames 332 #FROM (SELECT TestBoxesInSchedGroups.idTestBox AS idTestBox, 333 # STRING_AGG(SchedGroups.sName, ',') AS sSchedGroupNames 334 # FROM TestBoxesInSchedGroups 335 # INNER JOIN SchedGroups 336 # ON SchedGroups.idSchedGroup = TestBoxesInSchedGroups.idSchedGroup 337 # WHERE TestBoxesInSchedGroups.tsExpire = 'infinity'::TIMESTAMP 338 # AND SchedGroups.tsExpire = 'infinity'::TIMESTAMP 339 # GROUP BY TestBoxesInSchedGroups.idTestBox) 340 # AS SchedGroupNames, 341 # TestBoxesWithStrings 342 #LEFT OUTER JOIN TestSets 343 # ON TestSets.idTestBox = TestBoxesWithStrings.idTestBox 344 # AND ( TestSets.tsCreated > (CURRENT_TIMESTAMP - '%s hours'::interval) 345 # OR TestSets.tsDone IS NULL) 346 #WHERE TestBoxesWithStrings.tsExpire = 'infinity'::TIMESTAMP 347 # AND SchedGroupNames.idTestBox = TestBoxesWithStrings.idTestBox 348 #''', (cHoursBack,)); 322 349 oDb.execute(''' 323 SELECT TestBoxesWithStrings.sName, 324 TestSets.enmStatus, 325 TestSets.tsCreated, 326 TestBoxesWithStrings.sOS, 327 SchedGroupNames.sSchedGroupNames 328 FROM (SELECT TestBoxesInSchedGroups.idTestBox AS idTestBox, 329 STRING_AGG(SchedGroups.sName, ',') AS sSchedGroupNames 330 FROM TestBoxesInSchedGroups 331 INNER JOIN SchedGroups 332 ON SchedGroups.idSchedGroup = TestBoxesInSchedGroups.idSchedGroup 333 WHERE TestBoxesInSchedGroups.tsExpire = 'infinity'::TIMESTAMP 334 AND SchedGroups.tsExpire = 'infinity'::TIMESTAMP 335 GROUP BY TestBoxesInSchedGroups.idTestBox) 336 AS SchedGroupNames, 337 TestBoxesWithStrings 338 LEFT OUTER JOIN TestSets 339 ON TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox 340 AND ( TestSets.tsCreated > (CURRENT_TIMESTAMP - '%s hours'::interval) 341 OR TestSets.tsDone IS NULL) 342 WHERE TestBoxesWithStrings.tsExpire = 'infinity'::TIMESTAMP 343 AND SchedGroupNames.idTestBox = TestBoxesWithStrings.idTestBox 344 ''', (cHoursBack,)); 345 346 # Process the data 350 ( SELECT TestBoxesWithStrings.sName, 351 TestSets.enmStatus, 352 TestSets.tsCreated, 353 TestBoxesWithStrings.sOS, 354 SchedGroupNames.sSchedGroupNames 355 FROM ( 356 SELECT TestBoxesInSchedGroups.idTestBox AS idTestBox, 357 STRING_AGG(SchedGroups.sName, ',') AS sSchedGroupNames 358 FROM TestBoxesInSchedGroups 359 INNER JOIN SchedGroups 360 ON SchedGroups.idSchedGroup = TestBoxesInSchedGroups.idSchedGroup 361 WHERE TestBoxesInSchedGroups.tsExpire = 'infinity'::TIMESTAMP 362 AND SchedGroups.tsExpire = 'infinity'::TIMESTAMP 363 GROUP BY TestBoxesInSchedGroups.idTestBox 364 ) AS SchedGroupNames, 365 TestBoxesWithStrings 366 LEFT OUTER JOIN TestSets 367 ON TestSets.idTestBox = TestBoxesWithStrings.idTestBox 368 AND TestSets.tsCreated >= (CURRENT_TIMESTAMP - '%s hours'::interval) 369 AND TestSets.tsDone IS NOT NULL 370 WHERE TestBoxesWithStrings.tsExpire = 'infinity'::TIMESTAMP 371 AND SchedGroupNames.idTestBox = TestBoxesWithStrings.idTestBox 372 ) UNION ( 373 SELECT TestBoxesWithStrings.sName, 374 TestSets.enmStatus, 375 TestSets.tsCreated, 376 TestBoxesWithStrings.sOS, 377 SchedGroupNames.sSchedGroupNames 378 FROM ( 379 SELECT TestBoxesInSchedGroups.idTestBox AS idTestBox, 380 STRING_AGG(SchedGroups.sName, ',') AS sSchedGroupNames 381 FROM TestBoxesInSchedGroups 382 INNER JOIN SchedGroups 383 ON SchedGroups.idSchedGroup = TestBoxesInSchedGroups.idSchedGroup 384 WHERE TestBoxesInSchedGroups.tsExpire = 'infinity'::TIMESTAMP 385 AND SchedGroups.tsExpire = 'infinity'::TIMESTAMP 386 GROUP BY TestBoxesInSchedGroups.idTestBox 387 ) AS SchedGroupNames, 388 TestBoxesWithStrings 389 LEFT OUTER JOIN TestSets 390 ON TestSets.idTestBox = TestBoxesWithStrings.idTestBox 391 AND TestSets.tsCreated < (CURRENT_TIMESTAMP - '%s hours'::interval) 392 AND TestSets.tsDone IS NULL 393 WHERE TestBoxesWithStrings.tsExpire = 'infinity'::TIMESTAMP 394 AND SchedGroupNames.idTestBox = TestBoxesWithStrings.idTestBox 395 )''', (cHoursBack, cHoursBack,)); 396 397 398 # 399 # Process, format and output data. 400 # 347 401 dResult = testbox_data_processing(oDb); 348 349 # Format and output it.350 402 self._oSrvGlue.setContentType('text/plain'); 351 403 self._oSrvGlue.write(format_data(dResult)); … … 367 419 # 368 420 # Get the data. 369 # bird: I changed these to join on idGenTestBox and idGenTestCase instead of 370 # also needing to check the tsExpire columns. 421 # 422 # Note! These queries should be joining TestBoxesWithStrings and TestSets 423 # on idGenTestBox rather than on idTestBox and tsExpire=inf, but 424 # we don't have any index matching those. So, we'll ignore tests 425 # performed by deleted testboxes for the present as that doesn't 426 # happen often and we want the ~1000x speedup. 371 427 # 372 428 (oDb,) = self._connectToDb(); … … 381 437 FROM TestSets 382 438 INNER JOIN TestCases 383 ON TestCases.idGenTestCase 439 ON TestCases.idGenTestCase = TestCases.idGenTestCase 384 440 INNER JOIN TestBoxesWithStrings 385 ON TestBoxesWithStrings.idGenTestBox = TestSets.idGenTestBox 386 WHERE TestSets.tsCreated > (CURRENT_TIMESTAMP - '%s hours'::interval) 441 ON TestBoxesWithStrings.idTestBox = TestSets.idTestBox 442 AND TestBoxesWithStrings.tsExpire = 'infinity'::TIMESTAMP 443 WHERE TestSets.tsCreated >= (CURRENT_TIMESTAMP - '%s hours'::interval) 387 444 ''', (cHoursBack,)); 388 445 else: … … 393 450 FROM TestSets 394 451 INNER JOIN BuildCategories 395 ON BuildCategories.idBuildCategory 396 AND BuildCategories.sB uildCategories= '%s'452 ON BuildCategories.idBuildCategory = TestSets.idBuildCategory 453 AND BuildCategories.sBranch = '%s' 397 454 INNER JOIN TestCases 398 ON TestCases.idGenTestCase 455 ON TestCases.idGenTestCase = TestSets.idGenTestCase 399 456 INNER JOIN TestBoxesWithStrings 400 ON TestBoxesWithStrings.idGenTestBox = TestSets.idGenTestBox 401 WHERE TestSets.tsCreated > (CURRENT_TIMESTAMP - '%s hours'::interval) 457 ON TestBoxesWithStrings.idTestBox = TestSets.idTestBox 458 AND TestBoxesWithStrings.tsExpire = 'infinity'::TIMESTAMP 459 WHERE TestSets.tsCreated >= (CURRENT_TIMESTAMP - '%s hours'::interval) 402 460 ''', (sBranch, cHoursBack,)); 403 461
Note:
See TracChangeset
for help on using the changeset viewer.