Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / How to improve performance of Zen Cart v1.3.X up to 25%

How to improve performance of Zen Cart v1.3.X up to 25%

Locked

Started by data_digger on 8 Jan 2009, 10:43 AM · Views: 2,320

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
8 Jan 2009, 10:43 AM
#1
data_digger avatar

data_digger

Zen Follower

Join Date:
Jan 2009
Posts:
222
Plugin Contributions:
2

Post #1 by data_digger

Hi,

I'm not sure if it's the right place to post such kind of stuff, but I haven't found 'Tips&Tricks' forum ;).

I was curious how Zen Cart will behave on InnoDB tables, so I prepared little test and checked how much queries per second can MySQL perform using InnoDB and MyISAM storage engine. I turned out that InnoDB tables are about 25% faster then MyISAM. Also, InnoDB uses row level locking (read about locking on wikipedia), so it should scale better.

In my test I used MySQL ver. 5.0.41. I haven't tested 4.x versions, but if someone wants I can do it. I can't guarantee that InnoDB will outperform MyISAM storage engine in earlier versions of MySQL, but it's worth to try.

How to change MyISAM table to InnoDB?
To change storage engine of table X You have to execute following SQL code:

ALTER TABLE X ENGINE = InnoDB

If You wish to change all zen cart tables I suggest using this contribution:
http://www.zen-cart.com/forum/showthread.php?t=117053

If anyone wants to read more, please visit my blog:
InnoDB vs MyISAM performance in Zen Cart. Which is better?

8 Jan 2009, 10:50 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #2 by kobra

InnoDB tables are about 25% faster then MyISAM
In addition to percentages how about some parse times & # of querries?

Zen-Venom Get Bitten

8 Jan 2009, 11:46 AM
#3
data_digger avatar

data_digger

Zen Follower

Join Date:
Jan 2009
Posts:
222
Plugin Contributions:
2

Post #3 by data_digger

I checked raw database performance only, because this is what this 'tip' tries to improve. When measuring page parse time You have to take into account that it consists of two elements:
page pare time = php time + mysql time
As changing storage engine has nothing to do with php side, I was not measuring it. But, if page parse times are around 2.0 sec, and database queries take about 1.5 of that, You can predict that changing MyISAM will decrease page parse time by:
1.5 * 0.25 = 0.375 sec on average.

In addition to percentages how about some parse times & # of querries?
Changing storage engine will not change number of queries!

8 Jan 2009, 12:16 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #4 by kobra

But, if page parse times are around 2.0 sec, and database queries take about 1.5 of that
Thanks - But this IMO is misleading as Full parse at 2.0sec the mysql should never be 3/4 of that value and should be more like 1/2 to 1/10 of that value.

Interesting, albeit not the subject of innodb, from your Demos for sql cache:

Without
Parse Time: 0.242 - Number of Queries: 912 - Query Time: 0.131467451828
Parse Time: 0.219 - Number of Queries: 885 - Query Time: 0.11567739700317
Parse Time: 0.214 - Number of Queries: 926 - Query Time: 0.13447992201233
Avg         0.225                      908               0.127208256 9478 

With
Parse Time: 0.244 - Number of Queries: 515 - Query Time: 0.11135396286011
Parse Time: 0.223 - Number of Queries: 507 - Query Time: 0.11417229046631
Parse Time: 0.198 - Number of Queries: 497 - Query Time: 0.10736983879089
Avg         0.222                      506               0.1100653640391

Diff        0.003                      402               0.0171428929087
% Improv    1.33%                       44.27%          13.48% 

Your mysql cache does in fact reduce the #of querries by a good bit - but mysql is still taking time to do something as the % improvement in query time is not in scale with the reduction of the # of querries. Great job! and I will have to investigate in more depth.

Zen-Venom Get Bitten

8 Jan 2009, 12:42 PM
#5
data_digger avatar

data_digger

Zen Follower

Join Date:
Jan 2009
Posts:
222
Plugin Contributions:
2

Post #5 by data_digger

kobra:

Thanks - But this IMO is misleading as Full parse at 2.0sec the mysql should never be 3/4 of that value and should be more like 1/2 to 1/10 of that value.
It's true, but I checked few stores from showcase and it's not so uncommon to see that db takes over 50% of page generation time.

Your mysql cache does in fact reduce the #of querries by a good bit - but mysql is still taking time to do something as the % improvement in query time is not in scale with the reduction of the # of querries. Great job! and I will have to investigate in more depth.

Hmm, I didn't paid attention to that. It's possible that my hosting company uses query cache built in MySQL and therefore results are similar. I'll also take look soon on my code to check if it's optimized. Thank You for pointing it out.

Note #1: Even if parse times seems similar it's better to have lower query count. Each query (even the simplest one or one that uses primary key) can potentially take long time (due to table/row locking).

Note #2: Demo stores on my site use MyISAM tables. I don't want to mix many features in particular demo store.

Note #3: I managed to reduce query count with my query cache by another 150 queries (simple change in code is needed). I expect to lower it further by 50-100 queries.

8 Jan 2009, 1:30 PM
#6
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #6 by kobra

Great Work no matter and probably overdue. Zen Community should be thankful you are contributing your time and assisting many shop owners.

Zen-Venom Get Bitten

8 Jan 2009, 3:05 PM
#8
data_digger avatar

data_digger

Zen Follower

Join Date:
Jan 2009
Posts:
222
Plugin Contributions:
2

Post #8 by data_digger

Yeah, I saw it. But since We're about 3-4 months from official release of Zen Cart 2.0 this might still be useful. Plus some people won't switch from 1.3.x to 2.0 for various reasons (custom changes to source code, they will be waiting for kind of 'service pack' to official release, they'll wait for compatible versions of contributions etc.).

8 Jan 2009, 3:09 PM
#9
data_digger avatar

data_digger

Zen Follower

Join Date:
Jan 2009
Posts:
222
Plugin Contributions:
2

Post #9 by data_digger

data_digger:

. I'll also take look soon on my code to check if it's optimized.

Ok, I used Profiler Class to profile my code and it seems that it's quite fast. On my local machine I get page generation times around 0.8 - 0.9 sec, and Query Cache runs for 0.08 average. Some optimization can be done, but it isn't worth it.

8 Jan 2009, 8:43 PM
#10
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #10 by kobra

Some optimization can be done, but it isn't worth it.
Was only pointing out the relationship(My "annal retentive"). This will be beneficial for the many in reducing #of querries

Zen-Venom Get Bitten