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
Cody Phillips (Inactive)
created issue -
Cody Phillips (Inactive)
made changes -
Field | Original Value | New Value |
---|---|---|
Rank | Ranked higher |
Cody Phillips (Inactive)
made changes -
Rank | Ranked higher |
Cody Phillips (Inactive)
made changes -
Security | Private [ 10000 ] |
Paul Phillips
made changes -
Fix Version/s | 3.4.3 [ 10613 ] |
Cody Phillips (Inactive)
made changes -
Status | Open [ 1 ] | In Progress [ 3 ] |
Cody Phillips (Inactive)
made changes -
Fix Version/s | 3.5.0 [ 10401 ] |
Cody Phillips (Inactive)
made changes -
Status | In Progress [ 3 ] | Resolved [ 5 ] |
Resolution | Fixed [ 1 ] |
Tyson Phillips (Inactive)
made changes -
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.