Details
Description
When invoices are generated there is a sub-optimal query being run.
SELECT SUM(`transaction_applied`.`amount`) AS `total` FROM
`transaction_applied` INNER JOIN `invoices` ON `invoices`.`id` =
`transaction_applied`.`invoice_id` WHERE `invoices`.`status` IN
('active','proforma') AND `invoices`.`currency` = 'USD' AND
`invoices`.`client_id` = '12693' AND `invoices`.`date_closed` IS NULL
AND `invoices`.`date_billed` <= '2015-03-19 15:55:19' GROUP BY
`invoices`.`client_id`
Activity
| Field | Original Value | New Value |
|---|---|---|
| Rank | Ranked higher |
| Rank | Ranked higher |
| Security | Private [ 10000 ] |
| Fix Version/s | 3.4.3 [ 10613 ] |
| Status | Open [ 1 ] | In Progress [ 3 ] |
| Fix Version/s | 3.5.0 [ 10401 ] |
| Status | In Progress [ 3 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Solution is to add an index for invoice ID on transaction_applied:
OR
Above not needed since the number of transactions applied to each invoice is very small.