From 9ff8611672f7bee789b1f6f79d67432907dd4b1b Mon Sep 17 00:00:00 2001 From: objecttothis Date: Sat, 1 May 2021 16:22:53 +0400 Subject: [PATCH] Requested Changes - Removed unnecessary indices on deleted column where there would not be many rows. - Explicitly stated NULL in second parameter of WHERE to improve readability. --- .../20210422000001_remove_duplicate_links.php | 8 ++++---- .../sqlscripts/3.4.0_database_optimizations.sql | 12 +----------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/application/migrations/20210422000001_remove_duplicate_links.php b/application/migrations/20210422000001_remove_duplicate_links.php index b0543306a..3f8c02a17 100644 --- a/application/migrations/20210422000001_remove_duplicate_links.php +++ b/application/migrations/20210422000001_remove_duplicate_links.php @@ -25,8 +25,8 @@ class Migration_remove_duplicate_links extends CI_Migration //Remove duplicate attribute links $this->db->trans_start(); - $this->db->where('sale_id'); - $this->db->where('receiving_id'); + $this->db->where('sale_id', NULL); + $this->db->where('receiving_id', NULL); $this->db->group_by('item_id'); $this->db->group_by('definition_id'); $this->db->group_by('attribute_id'); @@ -37,8 +37,8 @@ class Migration_remove_duplicate_links extends CI_Migration foreach($duplicated_links->result_array() as $duplicated_link) { - $this->db->where('sale_id'); - $this->db->where('receiving_id'); + $this->db->where('sale_id', NULL); + $this->db->where('receiving_id', NULL); $this->db->where('item_id', $duplicated_link['item_id']); $this->db->where('definition_id', $duplicated_link['definition_id']); $this->db->delete('attribute_links'); diff --git a/application/migrations/sqlscripts/3.4.0_database_optimizations.sql b/application/migrations/sqlscripts/3.4.0_database_optimizations.sql index 0b3f4e2ee..335e38c96 100644 --- a/application/migrations/sqlscripts/3.4.0_database_optimizations.sql +++ b/application/migrations/sqlscripts/3.4.0_database_optimizations.sql @@ -6,7 +6,6 @@ ALTER TABLE `ospos_attribute_values` ADD UNIQUE(`attribute_decimal`); ALTER TABLE `ospos_attribute_definitions` MODIFY `definition_flags` tinyint(1) NOT NULL; ALTER TABLE `ospos_attribute_definitions` ADD INDEX(`definition_name`); ALTER TABLE `ospos_attribute_definitions` ADD INDEX(`definition_type`); -ALTER TABLE `ospos_attribute_definitions` ADD INDEX(`deleted`); #opsos_attribute_links table ALTER TABLE `ospos_attribute_links` ADD UNIQUE INDEX `attribute_links_uq2` (`item_id`, `receiving_id`, `sale_id`, `definition_id`, `attribute_id`); @@ -20,7 +19,6 @@ ALTER TABLE `ospos_customers` MODIFY `taxable` tinyint(1) DEFAULT 1 NOT NULL; ALTER TABLE `ospos_customers` MODIFY `deleted` tinyint(1) DEFAULT 0 NOT NULL; ALTER TABLE `ospos_customers` MODIFY `discount_type` tinyint(1) DEFAULT 0 NOT NULL; ALTER TABLE `ospos_customers` ADD PRIMARY KEY(`person_id`); -ALTER TABLE `ospos_customers` ADD INDEX(`deleted`); ALTER TABLE `ospos_customers` ADD INDEX(`company_name`); #ospos_customers_packages table @@ -40,18 +38,15 @@ ALTER TABLE `ospos_employees` ADD PRIMARY KEY(`person_id`); #ospos_expenses table ALTER TABLE `ospos_expenses` MODIFY `deleted` tinyint(1) DEFAULT 0 NOT NULL; -ALTER TABLE `ospos_expenses` ADD INDEX(`deleted`); ALTER TABLE `ospos_expenses` ADD INDEX(`payment_type`); ALTER TABLE `ospos_expenses` ADD INDEX(`amount`); #ospos_expenses_categories table ALTER TABLE `ospos_expense_categories` MODIFY `deleted` tinyint(1) DEFAULT 0 NOT NULL; ALTER TABLE `ospos_expense_categories` ADD INDEX(`category_description`); -ALTER TABLE `ospos_expense_categories` ADD INDEX(`deleted`); #ospos_giftcards table ALTER TABLE `ospos_giftcards` MODIFY `deleted` tinyint(1) DEFAULT 0 NOT NULL; -ALTER TABLE `ospos_giftcards` ADD INDEX(`deleted`); #ospos_items table ALTER TABLE `ospos_items` MODIFY `deleted` tinyint(1) DEFAULT 0 NOT NULL; @@ -96,7 +91,6 @@ ALTER TABLE `ospos_sessions` ADD INDEX(`ip_address`); #ospos_stock_locations table ALTER TABLE `ospos_stock_locations` MODIFY `deleted` tinyint(1) DEFAULT 0 NOT NULL; -ALTER TABLE `ospos_stock_locations` ADD INDEX(`deleted`); #ospos_suppliers table DROP INDEX `person_id` ON `ospos_suppliers`; @@ -104,22 +98,18 @@ ALTER TABLE `ospos_suppliers` MODIFY `deleted` tinyint(1) DEFAULT 0 NOT NULL; ALTER TABLE `ospos_suppliers` MODIFY `category` tinyint(1) NOT NULL; ALTER TABLE `ospos_suppliers` ADD PRIMARY KEY(`person_id`); ALTER TABLE `ospos_suppliers` ADD INDEX(`category`); -ALTER TABLE `ospos_suppliers` ADD INDEX(`deleted`); #ospos_tax_categories table ALTER TABLE `ospos_tax_categories` MODIFY `deleted` tinyint(1) DEFAULT 0 NOT NULL; ALTER TABLE `ospos_tax_categories` MODIFY `tax_group_sequence` tinyint(1) NOT NULL; -ALTER TABLE `ospos_tax_categories` ADD INDEX(`deleted`); #ospos_tax_codes table ALTER TABLE `ospos_tax_codes` MODIFY `deleted` tinyint(1) DEFAULT 0 NOT NULL; -ALTER TABLE `ospos_tax_codes` ADD INDEX(`deleted`); #ospos_tax_jurisdictions table ALTER TABLE `ospos_tax_jurisdictions` MODIFY `deleted` tinyint(1) DEFAULT 0 NOT NULL; ALTER TABLE `ospos_tax_jurisdictions` MODIFY `tax_group_sequence` tinyint(1) DEFAULT 0 NOT NULL; ALTER TABLE `ospos_tax_jurisdictions` MODIFY `cascade_sequence` tinyint(1) DEFAULT 0 NOT NULL; -ALTER TABLE `ospos_tax_jurisdictions` ADD INDEX(`deleted`); #ospos_tax_rates table -ALTER TABLE `ospos_tax_rates` MODIFY `tax_rounding_code` tinyint(1) DEFAULT 0 NOT NULL; +ALTER TABLE `ospos_tax_rates` MODIFY `tax_rounding_code` tinyint(1) DEFAULT 0 NOT NULL; \ No newline at end of file