You are here:  » disable keys in server load mod

Support Forum



disable keys in server load mod

Submitted by clare on Mon, 2011-05-16 09:21 in

In the server load mod that creates the temporary table products_import, I was just wondering what the following code does...

<?php
 $sql 
"ALTER TABLE `".$config_databaseTablePrefix."products_import` DISABLE KEYS"
?>

then after import they are enabled again.

I ask because i was putting a require to a php script that does some stuff with categories into the import and thinking of the best place to put it, it doesnt alter the products_import table, just collects some data from it to be put in another table. I am thinking that I should make any alterations just before the "drop products table" command, after the line

<?php
 $sql 
"ALTER TABLE `".$config_databaseTablePrefix."products_import` ENABLE KEYS";
    
database_queryModify($sql,$result); 
?>

Is that right, or could I put it straight after the import, before the keys are re-enabled?

I am not really sure why the keys are disabled when the table is copied?

Submitted by support on Mon, 2011-05-16 10:02

Hi Clare,

The DISABLE KEYS query prevents MySQL from trying to build the merchant, category, brand and search indexes whilst the import is taking place. MySQL can use a much faster algorithm to build them "in one go" on the ENABLE KEYS query; so if your custom code requires access to category information as you mention; it would be best to include it _after_ the ENABLE KEYS query; but _before_ the products_import table is copied over to become the new products table.

Cheers,
David.
--
PriceTapestry.com

Submitted by clare on Mon, 2011-05-16 10:33

Thanks David!