Can Somebody Help Me To Optimize This Code?

Hi all

Recently our hoster told us there are many tmp tables created on the disk, Disk I/O abuse , they will suspend our server if we dont have the permanent solution for this ,

I think the problems comes with the addon which imports products from .CSV files. we usually import 1000pcs items to store a time.

and i think it is better to optimize below code .

if ($mode == 'assign_id') {

$features = db_get_array(“SELECT DISTINCT(a.description), b.parent_id FROM ?:product_features_descriptions as a LEFT JOIN ?:product_features as b ON a.feature_id = b.feature_id WHERE a.lang_code = ?s AND b.feature_type != ?s ORDER BY b.parent_id, a.description ASC”, DESCR_SL, 'G');

if (!empty($features)) {

foreach ($features as &$f) {

$f['feature_id'] = db_get_field(“SELECT feature_id FROM ?:product_features_ids WHERE description = ?s AND lang_code = ?s”, $f['description'], DESCR_SL);

if (!empty($f['parent_id'])) {

$f['parent'] = db_get_field(“SELECT description FROM ?:product_features_descriptions WHERE lang_code = ?s AND feature_id = ?i ORDER BY description ASC”, DESCR_SL, $f['parent_id']);




$view->assign('features', $features);


can it be optimized to reduce the tmp tables created while importing files ?