Uploaded image for project: 'Blesta Core'
  1. Blesta Core
  2. CORE-1599

Improve performance of transaction listing

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.4.3, 3.5.0-b1
    • Component/s: None
    • Labels:
      None

      Description

      The following queries have sub-optimal performance.

      | 12 | blesta | localhost | blesta | Query   | 1    | Copying to tmp table on disk | SELECT COUNT(*)
      AS `total` FROM ((SELECT `transactions`.`id`, `transactions`.`client_id`, `transactions`.`amount`,
      `transactions`.`currency`, `transactions`.`type`, `transactions`.`transaction_type_id`,
      `transactions`.`account_id`, `transactions`.`gateway_id`, `transactions`.`reference_id`,
      `transactions`.`transaction_id`, `transactions`.`parent_transaction_id`, `transactions`.`status`,
      `transactions`.`date_added`, SUM(IFNULL(`transaction_applied`.`amount`,'0')) AS `applied_amount`,
      `transaction_types`.`name` AS `type_name`, `transaction_types`.`is_lang` AS `type_is_lang`,
      `gateways`.`name` AS `gateway_name`, `gateways`.`type` AS `gateway_type`,
      REPLACE(`clients`.`id_format`, '{num}', `clients`.`id_value`) AS `client_id_code`,
      `contacts`.`first_name` AS `client_first_name`, `contacts`.`last_name` AS `client_last_name`,
      `contacts`.`company` AS `client_company` FROM `transactions` INNER JOIN `clients` ON `clients`.`id`
      = `transactions`.`client_id` INNER JOIN `client_groups` ON `client_groups`.`id` =
      `clients`.`client_group_id` INNER JOIN `contacts` ON `contacts`.`contact_type` = 'primary' AND
      `contacts`.`client_id` = `clients`.`id` LEFT JOIN `transaction_types` ON
      `transactions`.`transaction_type_id` = `transaction_types`.`id` LEFT JOIN `gateways` ON
      `transactions`.`gateway_id` = `gateways`.`id` LEFT JOIN `transaction_applied` ON `transactions`.`id`
      = `transaction_applied`.`transaction_id` WHERE `client_groups`.`company_id` = '1' AND
      `transactions`.`status` = 'approved' GROUP BY `transactions`.`id`)) AS `t_2118254522` | 0.000    |
      

      Invoices listing.

      | 14 | blesta | localhost | blesta | Query | 0 | Copying to tmp table | SELECT `invoices`.*,
      REPLACE(`invoices`.`id_format`, '{num}', `invoices`.`id_value`) AS `id_code`,
      `invoice_delivery`.`date_sent` AS `delivery_date_sent`, REPLACE(`clients`.`id_format`, '{num}',
      `clients`.`id_value`) AS `client_id_code`, `contacts`.`first_name` AS `client_first_name`,
      `contacts`.`last_name` AS `client_last_name`, `contacts`.`company` AS `client_company`,
      `contacts`.`address1` AS `client_address1`, `contacts`.`email` AS `client_email`,
      invoices.total-IFNULL(invoices.paid,0) AS `due` FROM `invoices` INNER JOIN `clients` ON
      `clients`.`id` = `invoices`.`client_id` INNER JOIN `client_groups` ON `client_groups`.`id` =
      `clients`.`client_group_id` INNER JOIN `contacts` ON `contacts`.`contact_type` = 'primary' AND
      `contacts`.`client_id` = `clients`.`id` LEFT JOIN `invoice_delivery` ON
      `invoice_delivery`.`date_sent` IS NOT NULL AND `invoice_delivery`.`invoice_id` = `invoices`.`id`
      WHERE `invoices`.`date_closed` IS NULL AND `invoices`.`status` IN ('active','proforma') AND
      `invoices`.`date_billed` <= '2015-03-16 20:25:57' AND `client_groups`.`company_id` = '1' GROUP BY
      `invoices`.`id` ORDER BY `date_billed` DESC LIMIT 0, 25 | 0.000 |
      

        Activity

        cody Cody Phillips (Inactive) created issue -
        cody Cody Phillips (Inactive) made changes -
        Field Original Value New Value
        Project Marketplace [ 10200 ] Blesta Core [ 10000 ]
        Key MP-27 CORE-1599
        Workflow jira [ 12124 ] classic default workflow [ 12125 ]
        cody Cody Phillips (Inactive) made changes -
        Rank Ranked higher
        admin Paul Phillips made changes -
        Fix Version/s 3.4.3 [ 10613 ]
        cody Cody Phillips (Inactive) made changes -
        Description The following queries have sub-optimal performance.

        {noformat}
        | 12 | blesta | localhost | blesta | Query | 1 | Copying to tmp table on disk | SELECT COUNT(*)
        AS `total` FROM ((SELECT `transactions`.`id`, `transactions`.`client_id`, `transactions`.`amount`,
        `transactions`.`currency`, `transactions`.`type`, `transactions`.`transaction_type_id`,
        `transactions`.`account_id`, `transactions`.`gateway_id`, `transactions`.`reference_id`,
        `transactions`.`transaction_id`, `transactions`.`parent_transaction_id`, `transactions`.`status`,
        `transactions`.`date_added`, SUM(IFNULL(`transaction_applied`.`amount`,'0')) AS `applied_amount`,
        `transaction_types`.`name` AS `type_name`, `transaction_types`.`is_lang` AS `type_is_lang`,
        `gateways`.`name` AS `gateway_name`, `gateways`.`type` AS `gateway_type`,
        REPLACE(`clients`.`id_format`, '{num}', `clients`.`id_value`) AS `client_id_code`,
        `contacts`.`first_name` AS `client_first_name`, `contacts`.`last_name` AS `client_last_name`,
        `contacts`.`company` AS `client_company` FROM `transactions` INNER JOIN `clients` ON `clients`.`id`
        = `transactions`.`client_id` INNER JOIN `client_groups` ON `client_groups`.`id` =
        `clients`.`client_group_id` INNER JOIN `contacts` ON `contacts`.`contact_type` = 'primary' AND
        `contacts`.`client_id` = `clients`.`id` LEFT JOIN `transaction_types` ON
        `transactions`.`transaction_type_id` = `transaction_types`.`id` LEFT JOIN `gateways` ON
        `transactions`.`gateway_id` = `gateways`.`id` LEFT JOIN `transaction_applied` ON `transactions`.`id`
        = `transaction_applied`.`transaction_id` WHERE `client_groups`.`company_id` = '1' AND
        `transactions`.`status` = 'approved' GROUP BY `transactions`.`id`)) AS `t_2118254522` | 0.000 |
        {noformat}

        {noformat}
        | 14 | blesta | localhost | blesta | Query | 0 | Copying to tmp table | SELECT `invoices`.*,
        REPLACE(`invoices`.`id_format`, '{num}', `invoices`.`id_value`) AS `id_code`,
        `invoice_delivery`.`date_sent` AS `delivery_date_sent`, REPLACE(`clients`.`id_format`, '{num}',
        `clients`.`id_value`) AS `client_id_code`, `contacts`.`first_name` AS `client_first_name`,
        `contacts`.`last_name` AS `client_last_name`, `contacts`.`company` AS `client_company`,
        `contacts`.`address1` AS `client_address1`, `contacts`.`email` AS `client_email`,
        invoices.total-IFNULL(invoices.paid,0) AS `due` FROM `invoices` INNER JOIN `clients` ON
        `clients`.`id` = `invoices`.`client_id` INNER JOIN `client_groups` ON `client_groups`.`id` =
        `clients`.`client_group_id` INNER JOIN `contacts` ON `contacts`.`contact_type` = 'primary' AND
        `contacts`.`client_id` = `clients`.`id` LEFT JOIN `invoice_delivery` ON
        `invoice_delivery`.`date_sent` IS NOT NULL AND `invoice_delivery`.`invoice_id` = `invoices`.`id`
        WHERE `invoices`.`date_closed` IS NULL AND `invoices`.`status` IN ('active','proforma') AND
        `invoices`.`date_billed` <= '2015-03-16 20:25:57' AND `client_groups`.`company_id` = '1' GROUP BY
        `invoices`.`id` ORDER BY `date_billed` DESC LIMIT 0, 25 | 0.000 |
        {noformat}
        The following queries have sub-optimal performance.

        {noformat}
        | 12 | blesta | localhost | blesta | Query | 1 | Copying to tmp table on disk | SELECT COUNT(*)
        AS `total` FROM ((SELECT `transactions`.`id`, `transactions`.`client_id`, `transactions`.`amount`,
        `transactions`.`currency`, `transactions`.`type`, `transactions`.`transaction_type_id`,
        `transactions`.`account_id`, `transactions`.`gateway_id`, `transactions`.`reference_id`,
        `transactions`.`transaction_id`, `transactions`.`parent_transaction_id`, `transactions`.`status`,
        `transactions`.`date_added`, SUM(IFNULL(`transaction_applied`.`amount`,'0')) AS `applied_amount`,
        `transaction_types`.`name` AS `type_name`, `transaction_types`.`is_lang` AS `type_is_lang`,
        `gateways`.`name` AS `gateway_name`, `gateways`.`type` AS `gateway_type`,
        REPLACE(`clients`.`id_format`, '{num}', `clients`.`id_value`) AS `client_id_code`,
        `contacts`.`first_name` AS `client_first_name`, `contacts`.`last_name` AS `client_last_name`,
        `contacts`.`company` AS `client_company` FROM `transactions` INNER JOIN `clients` ON `clients`.`id`
        = `transactions`.`client_id` INNER JOIN `client_groups` ON `client_groups`.`id` =
        `clients`.`client_group_id` INNER JOIN `contacts` ON `contacts`.`contact_type` = 'primary' AND
        `contacts`.`client_id` = `clients`.`id` LEFT JOIN `transaction_types` ON
        `transactions`.`transaction_type_id` = `transaction_types`.`id` LEFT JOIN `gateways` ON
        `transactions`.`gateway_id` = `gateways`.`id` LEFT JOIN `transaction_applied` ON `transactions`.`id`
        = `transaction_applied`.`transaction_id` WHERE `client_groups`.`company_id` = '1' AND
        `transactions`.`status` = 'approved' GROUP BY `transactions`.`id`)) AS `t_2118254522` | 0.000 |
        {noformat}

        Invoices to deliver
        {noformat}
        | 14 | blesta | localhost | blesta | Query | 0 | Copying to tmp table | SELECT `invoices`.*,
        REPLACE(`invoices`.`id_format`, '{num}', `invoices`.`id_value`) AS `id_code`,
        `invoice_delivery`.`date_sent` AS `delivery_date_sent`, REPLACE(`clients`.`id_format`, '{num}',
        `clients`.`id_value`) AS `client_id_code`, `contacts`.`first_name` AS `client_first_name`,
        `contacts`.`last_name` AS `client_last_name`, `contacts`.`company` AS `client_company`,
        `contacts`.`address1` AS `client_address1`, `contacts`.`email` AS `client_email`,
        invoices.total-IFNULL(invoices.paid,0) AS `due` FROM `invoices` INNER JOIN `clients` ON
        `clients`.`id` = `invoices`.`client_id` INNER JOIN `client_groups` ON `client_groups`.`id` =
        `clients`.`client_group_id` INNER JOIN `contacts` ON `contacts`.`contact_type` = 'primary' AND
        `contacts`.`client_id` = `clients`.`id` LEFT JOIN `invoice_delivery` ON
        `invoice_delivery`.`date_sent` IS NOT NULL AND `invoice_delivery`.`invoice_id` = `invoices`.`id`
        WHERE `invoices`.`date_closed` IS NULL AND `invoices`.`status` IN ('active','proforma') AND
        `invoices`.`date_billed` <= '2015-03-16 20:25:57' AND `client_groups`.`company_id` = '1' GROUP BY
        `invoices`.`id` ORDER BY `date_billed` DESC LIMIT 0, 25 | 0.000 |
        {noformat}
        cody Cody Phillips (Inactive) made changes -
        Description The following queries have sub-optimal performance.

        {noformat}
        | 12 | blesta | localhost | blesta | Query | 1 | Copying to tmp table on disk | SELECT COUNT(*)
        AS `total` FROM ((SELECT `transactions`.`id`, `transactions`.`client_id`, `transactions`.`amount`,
        `transactions`.`currency`, `transactions`.`type`, `transactions`.`transaction_type_id`,
        `transactions`.`account_id`, `transactions`.`gateway_id`, `transactions`.`reference_id`,
        `transactions`.`transaction_id`, `transactions`.`parent_transaction_id`, `transactions`.`status`,
        `transactions`.`date_added`, SUM(IFNULL(`transaction_applied`.`amount`,'0')) AS `applied_amount`,
        `transaction_types`.`name` AS `type_name`, `transaction_types`.`is_lang` AS `type_is_lang`,
        `gateways`.`name` AS `gateway_name`, `gateways`.`type` AS `gateway_type`,
        REPLACE(`clients`.`id_format`, '{num}', `clients`.`id_value`) AS `client_id_code`,
        `contacts`.`first_name` AS `client_first_name`, `contacts`.`last_name` AS `client_last_name`,
        `contacts`.`company` AS `client_company` FROM `transactions` INNER JOIN `clients` ON `clients`.`id`
        = `transactions`.`client_id` INNER JOIN `client_groups` ON `client_groups`.`id` =
        `clients`.`client_group_id` INNER JOIN `contacts` ON `contacts`.`contact_type` = 'primary' AND
        `contacts`.`client_id` = `clients`.`id` LEFT JOIN `transaction_types` ON
        `transactions`.`transaction_type_id` = `transaction_types`.`id` LEFT JOIN `gateways` ON
        `transactions`.`gateway_id` = `gateways`.`id` LEFT JOIN `transaction_applied` ON `transactions`.`id`
        = `transaction_applied`.`transaction_id` WHERE `client_groups`.`company_id` = '1' AND
        `transactions`.`status` = 'approved' GROUP BY `transactions`.`id`)) AS `t_2118254522` | 0.000 |
        {noformat}

        Invoices to deliver
        {noformat}
        | 14 | blesta | localhost | blesta | Query | 0 | Copying to tmp table | SELECT `invoices`.*,
        REPLACE(`invoices`.`id_format`, '{num}', `invoices`.`id_value`) AS `id_code`,
        `invoice_delivery`.`date_sent` AS `delivery_date_sent`, REPLACE(`clients`.`id_format`, '{num}',
        `clients`.`id_value`) AS `client_id_code`, `contacts`.`first_name` AS `client_first_name`,
        `contacts`.`last_name` AS `client_last_name`, `contacts`.`company` AS `client_company`,
        `contacts`.`address1` AS `client_address1`, `contacts`.`email` AS `client_email`,
        invoices.total-IFNULL(invoices.paid,0) AS `due` FROM `invoices` INNER JOIN `clients` ON
        `clients`.`id` = `invoices`.`client_id` INNER JOIN `client_groups` ON `client_groups`.`id` =
        `clients`.`client_group_id` INNER JOIN `contacts` ON `contacts`.`contact_type` = 'primary' AND
        `contacts`.`client_id` = `clients`.`id` LEFT JOIN `invoice_delivery` ON
        `invoice_delivery`.`date_sent` IS NOT NULL AND `invoice_delivery`.`invoice_id` = `invoices`.`id`
        WHERE `invoices`.`date_closed` IS NULL AND `invoices`.`status` IN ('active','proforma') AND
        `invoices`.`date_billed` <= '2015-03-16 20:25:57' AND `client_groups`.`company_id` = '1' GROUP BY
        `invoices`.`id` ORDER BY `date_billed` DESC LIMIT 0, 25 | 0.000 |
        {noformat}
        The following queries have sub-optimal performance.

        {noformat}
        | 12 | blesta | localhost | blesta | Query | 1 | Copying to tmp table on disk | SELECT COUNT(*)
        AS `total` FROM ((SELECT `transactions`.`id`, `transactions`.`client_id`, `transactions`.`amount`,
        `transactions`.`currency`, `transactions`.`type`, `transactions`.`transaction_type_id`,
        `transactions`.`account_id`, `transactions`.`gateway_id`, `transactions`.`reference_id`,
        `transactions`.`transaction_id`, `transactions`.`parent_transaction_id`, `transactions`.`status`,
        `transactions`.`date_added`, SUM(IFNULL(`transaction_applied`.`amount`,'0')) AS `applied_amount`,
        `transaction_types`.`name` AS `type_name`, `transaction_types`.`is_lang` AS `type_is_lang`,
        `gateways`.`name` AS `gateway_name`, `gateways`.`type` AS `gateway_type`,
        REPLACE(`clients`.`id_format`, '{num}', `clients`.`id_value`) AS `client_id_code`,
        `contacts`.`first_name` AS `client_first_name`, `contacts`.`last_name` AS `client_last_name`,
        `contacts`.`company` AS `client_company` FROM `transactions` INNER JOIN `clients` ON `clients`.`id`
        = `transactions`.`client_id` INNER JOIN `client_groups` ON `client_groups`.`id` =
        `clients`.`client_group_id` INNER JOIN `contacts` ON `contacts`.`contact_type` = 'primary' AND
        `contacts`.`client_id` = `clients`.`id` LEFT JOIN `transaction_types` ON
        `transactions`.`transaction_type_id` = `transaction_types`.`id` LEFT JOIN `gateways` ON
        `transactions`.`gateway_id` = `gateways`.`id` LEFT JOIN `transaction_applied` ON `transactions`.`id`
        = `transaction_applied`.`transaction_id` WHERE `client_groups`.`company_id` = '1' AND
        `transactions`.`status` = 'approved' GROUP BY `transactions`.`id`)) AS `t_2118254522` | 0.000 |
        {noformat}

        Invoices listing.
        {noformat}
        | 14 | blesta | localhost | blesta | Query | 0 | Copying to tmp table | SELECT `invoices`.*,
        REPLACE(`invoices`.`id_format`, '{num}', `invoices`.`id_value`) AS `id_code`,
        `invoice_delivery`.`date_sent` AS `delivery_date_sent`, REPLACE(`clients`.`id_format`, '{num}',
        `clients`.`id_value`) AS `client_id_code`, `contacts`.`first_name` AS `client_first_name`,
        `contacts`.`last_name` AS `client_last_name`, `contacts`.`company` AS `client_company`,
        `contacts`.`address1` AS `client_address1`, `contacts`.`email` AS `client_email`,
        invoices.total-IFNULL(invoices.paid,0) AS `due` FROM `invoices` INNER JOIN `clients` ON
        `clients`.`id` = `invoices`.`client_id` INNER JOIN `client_groups` ON `client_groups`.`id` =
        `clients`.`client_group_id` INNER JOIN `contacts` ON `contacts`.`contact_type` = 'primary' AND
        `contacts`.`client_id` = `clients`.`id` LEFT JOIN `invoice_delivery` ON
        `invoice_delivery`.`date_sent` IS NOT NULL AND `invoice_delivery`.`invoice_id` = `invoices`.`id`
        WHERE `invoices`.`date_closed` IS NULL AND `invoices`.`status` IN ('active','proforma') AND
        `invoices`.`date_billed` <= '2015-03-16 20:25:57' AND `client_groups`.`company_id` = '1' GROUP BY
        `invoices`.`id` ORDER BY `date_billed` DESC LIMIT 0, 25 | 0.000 |
        {noformat}
        Hide
        cody Cody Phillips (Inactive) added a comment -

        Transactions listing has been improved.
        Invoices listing can not be improved without specifying additional criteria, such as `invoices`.`date_billed`>='SOME DATE'. This would require filtering capabilities for the invoices listing widget.

        Show
        cody Cody Phillips (Inactive) added a comment - Transactions listing has been improved. Invoices listing can not be improved without specifying additional criteria, such as `invoices`.`date_billed`>='SOME DATE'. This would require filtering capabilities for the invoices listing widget.
        cody Cody Phillips (Inactive) made changes -
        Fix Version/s 3.5.0 [ 10401 ]
        cody Cody Phillips (Inactive) made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        tyson Tyson Phillips (Inactive) made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            cody Cody Phillips (Inactive)
            Reporter:
            cody Cody Phillips (Inactive)
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Fix Release Date:
              25/Mar/15