Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance is better when fetching all rows at once #4539

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c505c15
[-] IN: Wrong id_guest in cart.xml
gRoussac Oct 6, 2015
8901373
[-] CORE : Fix #PSCSX-7012, bad length for compagny field (address) f…
gRoussac Oct 9, 2015
14b2ca7
[*] BO : Add versioning to addJS to renew admin.js
gRoussac Oct 9, 2015
1e19325
[-] BO : Fix #PSCSX-7050, wrong pictures shown in AdminProducts
gRoussac Oct 14, 2015
8f12447
[-] BO : Notice in AdminCustomers
gRoussac Oct 14, 2015
81aea52
Merge pull request #4268 from gRoussac/notice
julienbourdeau Oct 14, 2015
e4cb55f
[*] TR: update Swedish installer
Oct 14, 2015
b591e32
[-] FO : Added missing hook for AdvancedEU on accessories
tchauviere Oct 14, 2015
a0f2a12
Merge pull request #4270 from tchauviere/fix/missing-aeuc-hooks
gRoussac Oct 14, 2015
f1c5716
Merge pull request #4275 from AlexEven/swedish
gRoussac Oct 14, 2015
377a9d6
[-] CORE : cleanCompareProducts interval
Mehdib92 Oct 14, 2015
b89e4a3
Merge pull request #4279 from Mehdib92/patch-2
gRoussac Oct 14, 2015
2850be3
Merge pull request #4241 from gRoussac/PSCSX-7012
Oct 14, 2015
a645a2c
Merge pull request #4183 from gRoussac/guest
Oct 14, 2015
78d6fe6
[-] FO : Fix undefined var when no combinations
gRoussac Oct 14, 2015
afbbce2
Merge pull request #4277 from gRoussac/js-und
tchauviere Oct 14, 2015
c641bf6
[*] FO: theme.sql new demo address
Oct 14, 2015
0d55695
Merge pull request #4281 from AlexEven/1.6.1.x-sql
gRoussac Oct 14, 2015
dcb70b6
Merge pull request #4267 from gRoussac/PSCSX-7050
tchauviere Oct 14, 2015
c140d7a
[-] FO : Fix performances issue with SpecificPrice (PSCSX-6942)
jocel1 Oct 1, 2015
b6126cd
Merge pull request #4150 from jocel1/hotfix-PSCSX-6942
Oct 21, 2015
21ba323
//Fix d81b70a - category must be an object, not an array
Oct 22, 2015
b868dfb
Merge pull request #4325 from maximebiloe/1.6.1.x
julienbourdeau Oct 22, 2015
d030025
// HELPER: Add brackets to multiple select name field
tchauviere Oct 22, 2015
f950f8b
Merge pull request #4324 from tchauviere/fix/helper-multiple-select
julienbourdeau Oct 22, 2015
107091c
[*] CORE : SpecificPriceRule without conditions to id_product 0 inste…
gRoussac Oct 5, 2015
dff7548
Merge pull request #4171 from gRoussac/specif-f
Oct 22, 2015
9f692c6
Merge pull request #4248 from gRoussac/PSCSX-7021
julienbourdeau Oct 22, 2015
68d052a
[*] BO : #PSCFV-12359 #PSCSX-1257 product tab async loading
gRoussac Oct 15, 2015
d696628
// CORE: Only clean compare_product table if entry older than 1 week
julienbourdeau Oct 23, 2015
108442d
Merge pull request #4330 from PrestaShop/fix/slow-product-page
julienbourdeau Oct 23, 2015
6c53344
Merge pull request #4331 from julienbourdeau/fix/compareProductClearC…
Quetzacoalt91 Oct 23, 2015
25fda84
// Check PHP syntax error with travis
julienbourdeau Oct 23, 2015
69a4db7
Merge pull request #4332 from julienbourdeau/fatal-travis
julienbourdeau Oct 26, 2015
8b9ef15
[-] FO : Fix wrong date check in specific price (PSCSX-6942)
jocel1 Oct 28, 2015
99b5cf5
Merge pull request #4350 from jocel1/hotfix-specificprice
Oct 28, 2015
ce7bb3c
// Release 1.6.1.2
Oct 29, 2015
2480e5d
Performance is better when fetching all rows at once instead of itera…
studiokiwik Oct 30, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -6,7 +6,7 @@ php:
- 5.5
- 5.6
- 7.0

matrix:
fast_finish: true
allow_failures:
Expand All @@ -30,5 +30,6 @@ notifications:
slack: prestashop:Eovjydk55zPrwPkoQIOF0cZn
hipchat: ec4e21c5eb82066ba8be5fd1afefde@1184657
script:
- /var/www/prestashop.unit.test/tests/check_php_parse_errors.sh
- php /var/www/prestashop.unit.test/install-dev/index_cli.php --language=en --country=us --domain=localhost --base_uri=/prestashop.unit.test --db_name=prestashop.unit.test --db_create=1 --name=prestashop.unit.test --password=123456789
- cd /var/www/prestashop.unit.test/tests && bash getcomposer.sh && php composer.phar install && php vendor/bin/phpunit -c .
12 changes: 12 additions & 0 deletions CONTRIBUTORS.md
Expand Up @@ -21,6 +21,7 @@ GitHub contributors:
- Alfonso Jimenez
- Alphacom IT Solutions - Macedonia
- amatosg
- Amazzing
- anat
- Anatole
- Andrew
Expand All @@ -37,6 +38,8 @@ GitHub contributors:
- Bersam Karbasion
- BigZ
- BluTiGeS
- BMS-fenaille
- brouillon
- Bruno Desprez
- Bruno Leveque
- bumbu
Expand All @@ -48,6 +51,8 @@ GitHub contributors:
- ccauw
- cedricfontaine
- cedricgeffroy
- cgordenne
- cgordenne_wepika
- Chen.Zhidong
- Chris
- Chris Gurk
Expand All @@ -73,6 +78,7 @@ GitHub contributors:
- Daniele Giachino
- danoosh
- Danoosh Mir
- David Eschmeyer
- David Gasperoni
- David Sivocha
- David-Julian BUCH
Expand All @@ -88,6 +94,7 @@ GitHub contributors:
- dlage
- doekia
- DOEO
- DogSports
- Dragan Skrbic
- Dream me up
- dreammeup
Expand Down Expand Up @@ -116,6 +123,7 @@ GitHub contributors:
- Felipe Uribe
- fetis
- fird
- firstred
- flashmaestro
- Florian Kwakkenbos
- fram
Expand Down Expand Up @@ -204,6 +212,7 @@ GitHub contributors:
- LyoNick
- Leo
- M-Mommsen
- MacRoy
- Madef
- Madman
- Mainmich
Expand All @@ -212,6 +221,7 @@ GitHub contributors:
- marcinsz101
- Marco Cervellin
- Marcos
- Marius
- matiasiglesias
- Mats Rynge
- Matteo
Expand All @@ -224,6 +234,8 @@ GitHub contributors:
- mchelh
- mchojnacki
- mdomenjoud
- Mehdi BOUZIDI
- Michael Dekker
- Michael Hjulskov
- Michel Courtade
- Mickael Desgranges
Expand Down
Expand Up @@ -47,7 +47,7 @@
{foreach from=$js_files item=js_uri}
<script type="text/javascript" src="{$js_uri}"></script>
{/foreach}
<script type="text/javascript" src="../js/admin/login.js?{$smarty.now}"></script>
<script type="text/javascript" src="../js/admin/login.js?v={$smarty.const._PS_VERSION_|escape:'html':'UTF-8'}"></script>

{if (isset($js_def) && count($js_def) || isset($js_files) && count($js_files))}
{include file=$smarty.const._PS_ALL_THEMES_DIR_|cat:"javascript.tpl"}
Expand Down
Expand Up @@ -73,15 +73,14 @@
</div>
</div>
<script type="text/javascript">
var id_product = {if isset($product->id)}{$product->id}{else}0{/if};
var id_lang_default = {$id_lang_default};
var product_type_pack = {Product::PTYPE_PACK};
var product_type_virtual = {Product::PTYPE_VIRTUAL};
var product_type_simple = {Product::PTYPE_SIMPLE};
var id_product = {if isset($product->id)}{$product->id|intval}{else}0{/if};
var id_lang_default = {$id_lang_default|intval};
var product_type_pack = {Product::PTYPE_PACK|intval};
var product_type_virtual = {Product::PTYPE_VIRTUAL|intval};
var product_type_simple = {Product::PTYPE_SIMPLE|intval};

var has_combinations = {$has_combinations};
var has_combinations = {$has_combinations|intval};

var toload = new Array();
var empty_pack_msg = '{l s='This pack is empty. You will need to add at least one product to the pack before you can save.' js=1}';
var empty_name_msg = '{l s='The product name is empty. You will at least need to enter a name for the default language before you can save the product.' js=1}';
var empty_link_rewrite_msg = '{l s='The friendly URL is empty. You will at least need to enter a friendly URL for the default language before you can save the product.' slashes=1}';
Expand All @@ -102,7 +101,6 @@
var display_multishop_checkboxes = false;
{/if}

var tabs_preloaded = new Array();
var tabs_to_preload = new Array();
var mod_evasive = {if isset($mod_evasive) && $mod_evasive}true{else}false{/if};
var mod_security = {if isset($mod_security) && $mod_security}true{else}false{/if};
Expand Down Expand Up @@ -224,8 +222,7 @@
tabs_to_preload.push('{$tab_name}');
{/if}
{/foreach}

// Recursively load tabs starting with the first element of stack
tabs_manager.tabs_to_preload = tabs_to_preload.slice(0);
tabs_manager.displayBulk(tabs_to_preload);
$('.productTabs').show();
$('#product-tab-content-wait').hide();
Expand Down
Expand Up @@ -173,6 +173,7 @@
return $1 ? $1 + path : $0;
});
line = line.replace(/image_path/g, path);
line = line.replace(/\.jpg"\s/g, '.jpg?time=' + new Date().getTime() + '" ');
line = line.replace(/image_position/g, position);
line = line.replace(/legend/g, legend);
line = line.replace(/icon-check-empty/g, cover);
Expand Down
2 changes: 1 addition & 1 deletion admin-dev/themes/default/template/helpers/form/form.tpl
Expand Up @@ -337,7 +337,7 @@
{$input.required = false}
{$input.desc = null}
{else}
<select name="{$input.name|escape:'html':'utf-8'}{if isset($input.multiple) && $input.multiple}[]{/if}"
<select name="{$input.name|escape:'html':'utf-8'}"
class="{if isset($input.class)}{$input.class|escape:'html':'utf-8'}{/if} fixed-width-xl"
id="{if isset($input.id)}{$input.id|escape:'html':'utf-8'}{else}{$input.name|escape:'html':'utf-8'}{/if}"
{if isset($input.multiple) && $input.multiple} multiple="multiple"{/if}
Expand Down
5 changes: 2 additions & 3 deletions classes/Category.php
Expand Up @@ -771,8 +771,7 @@ public function getProducts($id_lang, $p, $n, $order_by = null, $order_way = nul
AND cp.`id_category` = '.(int)$this->id
.($active ? ' AND product_shop.`active` = 1' : '')
.($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '')
.($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '')
.' GROUP BY cp.id_product';
.($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '');

if ($random === true) {
$sql .= ' ORDER BY RAND() LIMIT '.(int)$random_number_products;
Expand Down Expand Up @@ -1387,7 +1386,7 @@ public function updatePosition($way, $position)
c.`date_upd` = "'.date('Y-m-d H:i:s').'"
WHERE c.`id_parent` = '.(int)$moved_category['id_parent'].'
AND c.`id_category`='.(int)$moved_category['id_category']));
Hook::exec('actionCategoryUpdate', array('category' => $moved_category));
Hook::exec('actionCategoryUpdate', array('category' => new Category($moved_category['id_category'])));
return $result;
}

Expand Down
20 changes: 6 additions & 14 deletions classes/CompareProduct.php
Expand Up @@ -136,23 +136,15 @@ public static function getNumberProducts($id_compare)
* @param string $period
* @return void
*/
public static function cleanCompareProducts($period = 'week')
public static function cleanCompareProducts($period = null)
{
if ($period === 'week') {
$interval = '1 WEEK';
} elseif ($period === 'month') {
$interval = '1 MONTH';
} elseif ($period === 'year') {
$interval = '1 YEAR';
} else {
return;
if ($period !== null) {
Tools::displayParameterAsDeprecated('period');
}

if ($interval != null) {
Db::getInstance()->execute('
DELETE cp, c FROM `'._DB_PREFIX_.'compare_product` cp, `'._DB_PREFIX_.'compare` c
WHERE cp.date_upd < DATE_SUB(NOW(), INTERVAL 1 WEEK) AND c.`id_compare`=cp.`id_compare`');
}
Db::getInstance()->execute('
DELETE cp, c FROM `'._DB_PREFIX_.'compare_product` cp, `'._DB_PREFIX_.'compare` c
WHERE cp.date_upd < DATE_SUB(NOW(), INTERVAL 1 WEEK) AND c.`id_compare`=cp.`id_compare`');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions classes/Configuration.php
Expand Up @@ -145,8 +145,8 @@ public static function loadConfiguration()
FROM `'._DB_PREFIX_.bqSQL(self::$definition['table']).'` c
LEFT JOIN `'._DB_PREFIX_.bqSQL(self::$definition['table']).'_lang` cl ON (c.`'.bqSQL(self::$definition['primary']).'` = cl.`'.bqSQL(self::$definition['primary']).'`)';
$db = Db::getInstance();
$result = $db->executeS($sql, false);
while ($row = $db->nextRow($result)) {
$result = $db->executeS($sql);
foreach ($result as $row) {
$lang = ($row['id_lang']) ? $row['id_lang'] : 0;
self::$types[$row['name']] = ($lang) ? 'lang' : 'normal';
if (!isset(self::$_cache[self::$definition['table']][$lang])) {
Expand Down
17 changes: 8 additions & 9 deletions classes/Product.php
Expand Up @@ -2269,7 +2269,7 @@ public static function getNewProducts($id_lang, $page_number = 0, $nb_products =
$order_way = 'DESC';
}
if ($order_by == 'id_product' || $order_by == 'price' || $order_by == 'date_add' || $order_by == 'date_upd') {
$order_by_prefix = 'p';
$order_by_prefix = 'product_shop';
} elseif ($order_by == 'name') {
$order_by_prefix = 'pl';
}
Expand Down Expand Up @@ -2325,11 +2325,11 @@ public static function getNewProducts($id_lang, $page_number = 0, $nb_products =
}
$sql->where('product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'"');
if (Group::isFeatureActive()) {
$sql->join('JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = p.id_product)');
$sql->join('JOIN '._DB_PREFIX_.'category_group cg ON (cg.id_category = cp.id_category)');
$sql->where('cg.`id_group` '.(count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1'));
$groups = FrontController::getCurrentCustomerGroups();
$sql->where('EXISTS(SELECT 1 FROM `'._DB_PREFIX_.'category_product` cp
JOIN `'._DB_PREFIX_.'category_group` cg ON (cp.id_category = cg.id_category AND cg.`id_group` '.(count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1').')
WHERE cp.`id_product` = p.`id_product`)');
}
$sql->groupBy('product_shop.id_product');

$sql->orderBy((isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way));
$sql->limit($nb_products, $page_number * $nb_products);
Expand Down Expand Up @@ -2398,7 +2398,7 @@ public static function getRandomSpecial($id_lang, $beginning = false, $ending =
$front = false;
}

$current_date = date('Y-m-d H:i:s');
$current_date = date('Y-m-d H:i:00');
$product_reductions = Product::_getProductIdByDate((!$beginning ? $current_date : $beginning), (!$ending ? $current_date : $ending), $context, true);

if ($product_reductions) {
Expand Down Expand Up @@ -2502,14 +2502,14 @@ public static function getPricesDrop($id_lang, $page_number = 0, $nb_products =
$order_way = 'DESC';
}
if ($order_by == 'id_product' || $order_by == 'price' || $order_by == 'date_add' || $order_by == 'date_upd') {
$order_by_prefix = 'p';
$order_by_prefix = 'product_shop';
} elseif ($order_by == 'name') {
$order_by_prefix = 'pl';
}
if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) {
die(Tools::displayError());
}
$current_date = date('Y-m-d H:i:s');
$current_date = date('Y-m-d H:i:00');
$ids_product = Product::_getProductIdByDate((!$beginning ? $current_date : $beginning), (!$ending ? $current_date : $ending), $context);

$tab_id_product = array();
Expand Down Expand Up @@ -2582,7 +2582,6 @@ public static function getPricesDrop($id_lang, $page_number = 0, $nb_products =
'.($front ? ' AND p.`visibility` IN ("both", "catalog")' : '').'
'.((!$beginning && !$ending) ? ' AND p.`id_product` IN ('.((is_array($tab_id_product) && count($tab_id_product)) ? implode(', ', $tab_id_product) : 0).')' : '').'
'.$sql_groups.'
GROUP BY p.id_product
ORDER BY '.(isset($order_by_prefix) ? pSQL($order_by_prefix).'.' : '').pSQL($order_by).' '.pSQL($order_way).'
LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products;

Expand Down