From 241ad277f91dae525e177ce085dea949f52e2925 Mon Sep 17 00:00:00 2001 From: Matt Breden Date: Tue, 7 Nov 2017 13:19:55 -0800 Subject: [PATCH] Issue #2921686 by mbreden: Add index to commerce_line_item table for faster reports --- modules/report/commerce_pos_report.install | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/report/commerce_pos_report.install b/modules/report/commerce_pos_report.install index f184ec2..c099358 100644 --- a/modules/report/commerce_pos_report.install +++ b/modules/report/commerce_pos_report.install @@ -53,6 +53,13 @@ function commerce_pos_report_schema() { return $schema; } +/** + * Implements hook_install(). + */ +function commerce_pos_report_install() { + db_add_index('commerce_line_item', 'commerce_pos_report', array('order_id', 'quantity', 'type')); +} + /** * Implements hook_uninstall(). */ @@ -60,6 +67,7 @@ function commerce_pos_report_uninstall() { // Variable cleanup. variable_del('commerce_pos_report_end_of_day_hour'); variable_del('commerce_pos_report_end_of_day_minute'); + db_drop_index('commerce_line_item', 'commerce_pos_report'); } /** @@ -146,3 +154,10 @@ function commerce_pos_report_update_7201() { } } + +/** + * Add an index to commerce_line_item table for faster reports. + */ +function commerce_pos_report_update_7202() { + db_add_index('commerce_line_item', 'commerce_pos_report', array('order_id', 'quantity', 'type')); +}