Skip to content

Commit

Permalink
cron: specify index for ticket aging query
Browse files Browse the repository at this point in the history
Somehow on large datasets (like >1M tickets), MySQL can get confused on which
index will provide the best performance. Generally, as systems age, they will
have significantly more closed tickets than open ones. Therefore, it should be
safe to assume that scanning the `status_id` index on the ticket table for
`open` tickets would be the fastest way to arrive at the sort-of short list of
tickets which should need to possibly be aged.
  • Loading branch information
greezybacon authored and protich committed Oct 22, 2018
1 parent e04778d commit 387fe1a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/class.ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -4210,7 +4210,8 @@ static function checkOverdue() {
Punt for now
*/

$sql='SELECT ticket_id FROM '.TICKET_TABLE.' T1 '
$sql='SELECT ticket_id FROM '.TICKET_TABLE.' T1'
.' USE INDEX (status_id)'
.' INNER JOIN '.TICKET_STATUS_TABLE.' status
ON (status.id=T1.status_id AND status.state="open") '
.' LEFT JOIN '.SLA_TABLE.' T2 ON (T1.sla_id=T2.id AND T2.flags & 1 = 1) '
Expand Down

0 comments on commit 387fe1a

Please sign in to comment.