gpt4 book ai didi

php - 慢速 x-cart 购物车页面

转载 作者:行者123 更新时间:2023-11-29 15:28:05 26 4
gpt4 key购买 nike

我在 cart.php 中有一个使用 PHP 5.3 的 x-cart 4.1.3 网上商店,您有 2 个使用 LEFT JOIN 的请求,是否可以将其更改为 INNER JOIN?

或者还有其他可能的优化吗?

代码如下:

$products_array = func_query_first("SELECT $sql_tbl[products].*, MIN($sql_tbl[pricing].price) as price, IF($sql_tbl[images_T].id IS NULL, '', 'Y') as is_thumbnail, $sql_tbl[images_T].image_path, $sql_tbl[images_T].image_x, $sql_tbl[images_T].image_y, IF($sql_tbl[images_P].id IS NULL, '', 'P') as is_pimage, $sql_tbl[images_P].image_path as pimage_path, $sql_tbl[images_P].image_x as pimage_x, $sql_tbl[images_P].image_y as pimage_y FROM $sql_tbl[pricing],$sql_tbl[products] LEFT JOIN $sql_tbl[images_T] ON $sql_tbl[images_T].id = $sql_tbl[products].productid LEFT JOIN $sql_tbl[images_P] ON $sql_tbl[images_P].id = $sql_tbl[products].productid WHERE $sql_tbl[products].productid=$sql_tbl[pricing].productid AND $sql_tbl[products].forsale != 'N' AND $sql_tbl[products].productid='$productid' AND $avail_condition $sql_tbl[pricing].quantity<='$amount' AND $sql_tbl[pricing].membershipid IN('$membershipid', 0) AND $sql_tbl[pricing].variantid = '$variantid' GROUP BY $sql_tbl[products].productid ORDER BY $sql_tbl[pricing].quantity DESC");

并且:

$discount_info = func_query_first("SELECT $sql_tbl[discounts].*, $max_discount_str FROM $sql_tbl[discounts] LEFT JOIN $sql_tbl[discount_memberships] ON $sql_tbl[discounts].discountid = $sql_tbl[discount_memberships].discountid WHERE minprice<='$avail_discount_total' $provider_condition AND ($sql_tbl[discount_memberships].membershipid IS NULL OR $sql_tbl[discount_memberships].membershipid = '$membershipid') ORDER BY max_discount DESC");

最佳答案

1) 对于第一个,如果您上传了所有产品的产品/缩略图,则可以,否则它们将从店面中消失。

2)至于第二个,您必须确保 xcart_discount_memberships 中的每一行至少有一行

为此,请在代码后添加适当的 INSERT...xcart_discount_memberships

provider/discounts.php:128:         $_id = func_array2insert("discounts",
provider/discounts.php-129- array(
provider/discounts.php-130- "minprice" => $minprice_new,
provider/discounts.php-131- "discount" => $discount_new,
provider/discounts.php-132- "discount_type" => $discount_type_new,
provider/discounts.php-133- "provider" => $login

作为替代方案,您可以添加 SQL 触发器以自动方式向 xcart_discount_memberships 表插入/删除行。

一般建议

1) 使用解释 https://dev.mysql.com/doc/refman/8.0/en/explain.html找出应该在哪里添加索引。

2) 应用性能技巧 https://help.x-cart.com/X-Cart:Performance_tips

3) 使用内部 X-Cart 工作台功能,由补丁激活寻找瓶颈。

index 7020274df6..2e3166b97d 100644
--- a/top.inc.php
+++ b/top.inc.php
@@ -50,17 +50,17 @@ define('LOG_WITH_BACKTRACE', false);
#
# Switching on the internal performance measurement mechanism
#
-define('BENCH', false);
+define('BENCH', true);

#
# Do not display the performance report
#
-define('BENCH_SIMPLE', true);
+define('BENCH_SIMPLE', false);

#
# Show tracing
#
-define('BENCH_BACKTRACE', false);
+define('BENCH_BACKTRACE', true);

#
# Disable creation of binary files with results of performance tests
@@ -92,7 +92,7 @@ define('BENCH_LOG_TYPE_LIMIT', "");
# T - only total values
# F - full report
# A - advanced report
-define('BENCH_DISPLAY_TYPE', "T");
+define('BENCH_DISPLAY_TYPE', "A");

#
# Code execution time, threshold value

这是一个如何应用补丁的人 https://help.x-cart.com/X-Cart:Applying_Patches#To_apply_a_patch_manually

关于php - 慢速 x-cart 购物车页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58928593/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com