| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
insert_productsonline() can be a major resource hog | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
insert_productsonline() can be a major resource hog
I was doing some profiling on Xcart and discovered that insert_productsonline() can take upwards of 15,000 milliseconds to execute, making up about 60% of the shopping cart's resource usage. This happens when MySQL hasn't stored and optimized the query for future use. Most of the time the calling of this function takes an average of 740 ms and about 11% of the shopping cart's execution time & resource usage.
I have found a simple remedy to this problem that produces the same results as the original code, but uses up only an average of 120 ms. Note that our site holds over 65,000 products, so it is no wonder this takes up a lot of processing power to gather the statistics. Replace the return line in insert_productsonline() in include/func.php with the following code: Code:
The key to this code speed increase is the usage of COUNT(*) instead of COUNT($sql_tbl[products].productid). Please note that your must be using a version of Xcart that has the func_query_first_cell() function available. If not, then simply use array_pop(func_query_first()) in its place.
__________________
X-Cart Pro 4.5.5 Platinum X-Payments 1.0.6 PHP 5.3.14 MySQL 5.1.68 Apache 2.2.23 |
|||||||
#2
|
|||||||||
|
|||||||||
Whole crap... nice catch. Big difference made....
Thanks. |
|||||||||
#3
|
|||||||
|
|||||||
I tried this MOD and my site only loads a blank white page.
Original code from func.php Code:
Modded code from func.php Code:
Am I missing or doing something wrong? Thanks ps. NuAlpha, thanks for all of your mods and posts. They are much apprecited.
__________________
CopperB XCart Gold -> v4.0.11 PHP -> v4.3.10 MySQL -> v4.0.22 Apache -> v1.3.33 Smarty -> v2.6.3 |
|||||||
#4
|
|||||||||
|
|||||||||
The original post states:
Quote:
If you look at your original code, you see that the function is: Code:
therefore this modification is not for you. You do not need it. COUNT(*) is already written into that function in your version of X-Cart. |
|||||||||
#5
|
|||||||
|
|||||||
Quote:
You have a double "return return" in your modified code instead of just one "return". Also, as TeleFirma stated, you wouldn't really need this code change as this code already appears to be in effect with Xcart 4.0.11.
__________________
X-Cart Pro 4.5.5 Platinum X-Payments 1.0.6 PHP 5.3.14 MySQL 5.1.68 Apache 2.2.23 |
|||||||
#6
|
|||||||
|
|||||||
Thanks for the replies guys. It was getting late and obviously I wasn't thinking or reading very clearly. I'm also a newbie and still getting the hang of x-cart.
__________________
CopperB XCart Gold -> v4.0.11 PHP -> v4.3.10 MySQL -> v4.0.22 Apache -> v1.3.33 Smarty -> v2.6.3 |
|||||||
|
|||
X-Cart forums © 2001-2020
|