Last active
December 25, 2015 17:18
-
-
Save parhamr/7011685 to your computer and use it in GitHub Desktop.
Revisions
-
parhamr renamed this gist
Oct 17, 2013 . 1 changed file with 21 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,11 @@ possible_keys: NULL rows: 773625 Extra: Using where 1 row in set (0.00 sec) ``` This query is much faster: ```sql mysql> explain DELETE FROM `catalog_product_index_price` WHERE entity_id IN(433284, 433283)\G; *************************** 1. row *************************** id: 1 @@ -30,3 +34,20 @@ possible_keys: PRIMARY,IDX_CATALOGPRODUCTINDEXPRICE_ENTITYID 1 row in set (0.00 sec) ``` Incorrectly quoting both INT values produces the same result: ```sql mysql> explain DELETE FROM `catalog_product_index_price` WHERE entity_id IN('433284', '433283')\G; *************************** 1. row *************************** id: 1 select_type: SIMPLE table: catalog_product_index_price type: range possible_keys: PRIMARY,IDX_CATALOGPRODUCTINDEXPRICE_ENTITYID key: PRIMARY key_len: 4 ref: NULL rows: 19 Extra: Using where 1 row in set (0.00 sec) ``` -
parhamr revised this gist
Oct 16, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ Removing quotes from an INT column allows MySQL to use the index and this can reduce rows scanned by __99.997 percent__. Example from Magento 1.12 on a production database; the query takes nearly a second to execute: ```sql mysql> explain DELETE FROM `catalog_product_index_price` WHERE entity_id IN('433284', 433283)\G; -
parhamr revised this gist
Oct 16, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ Removing quotes from an INT column allows MySQL to use the index and this can reduce rows scanned by __99.997 percent__. Example from Magento 1.12 on a production database: ```sql mysql> explain DELETE FROM `catalog_product_index_price` WHERE entity_id IN('433284', 433283)\G; -
parhamr revised this gist
Oct 16, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ Removing quotes from an INT column allows MySQL to use the index and this can reduce rows scanned by __99.997 percent__. Example from Magento 1.12: ```sql mysql> explain DELETE FROM `catalog_product_index_price` WHERE entity_id IN('433284', 433283)\G; -
parhamr revised this gist
Oct 16, 2013 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ Removing the quotes from the INT column allows MySQL to use the index and this reduces the rows scanned by __99.997 percent__. Example from Magento 1.12: ```sql mysql> explain DELETE FROM `catalog_product_index_price` WHERE entity_id IN('433284', 433283)\G; *************************** 1. row *************************** @@ -28,4 +30,3 @@ possible_keys: PRIMARY,IDX_CATALOGPRODUCTINDEXPRICE_ENTITYID 1 row in set (0.00 sec) ``` -
parhamr created this gist
Oct 16, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ ```sql mysql> explain DELETE FROM `catalog_product_index_price` WHERE entity_id IN('433284', 433283)\G; *************************** 1. row *************************** id: 1 select_type: SIMPLE table: catalog_product_index_price type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 773625 Extra: Using where 1 row in set (0.00 sec) mysql> explain DELETE FROM `catalog_product_index_price` WHERE entity_id IN(433284, 433283)\G; *************************** 1. row *************************** id: 1 select_type: SIMPLE table: catalog_product_index_price type: range possible_keys: PRIMARY,IDX_CATALOGPRODUCTINDEXPRICE_ENTITYID key: PRIMARY key_len: 4 ref: NULL rows: 19 Extra: Using where 1 row in set (0.00 sec) ``` Removing the quotes from the INT column allows MySQL to use the index and this reduces the rows scanned by 99.997 percent.