Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / Site slowed by database query to "archive" and "share_moods" tables?

Site slowed by database query to "archive" and "share_moods" tables?

Locked
This thread is locked. New replies are disabled.
22 Feb 2010, 10:48 PM
#1
djculture avatar

djculture

New Zenner

Join Date:
Feb 2010
Posts:
5
Plugin Contributions:
0

Post #1 by djculture

Using: Zen Cart 1.3.8a - MySQL 5.0.67-log

my site https://www.shop.djculture.com is running extremely slow.
After several go arounds with my hosting site, here is the last response... I am clueless on Mysql stuff...

"I checked your slow logs, and this sort of stuff shows up:

Query_time: 203 Lock_time: 0 Rows_sent: 1 Rows_examined: 6938548 use share; SET timestamp=1266849274; SELECT sum(m.mood_value) / count(a.id), count(a.id) from archive as a, share_moods as m where a.mood = m.mood_key and a.uid=3328 and to_days(a.time) = to_days(now());

Please note the rows_examined... thats nearly 7 million rows... that is quite a lot. I dont know what the heck that line does (something with moods and archives?), but you may want to visit Zencart and see if there is anyway to not get that line to execute..."

22 Feb 2010, 11:08 PM
#2
kobra avatar

kobra

Black Belt

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

Post #2 by kobra

Using: Zen Cart 1.3.8a - MySQL 5.0.67-log
With what addon modules?

Searched all of default install files for "mood" and it returned nothing

Zen-Venom Get Bitten

23 Feb 2010, 6:03 AM
#3
djculture avatar

djculture

New Zenner

Join Date:
Feb 2010
Posts:
5
Plugin Contributions:
0

Post #3 by djculture

addons I think you mean... I used "sage" template from zen-cart.com, paypal, UPS, & USPS but I think those are built in... this all happened when i upgraded to 1.3.8. And Thanks for inquiring... hope you can help!

23 Feb 2010, 6:15 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #4 by drbyte

Zen Cart doesn't have any tables named "archive" or "share_moods", so whatever your problem is isn't coming from Zen Cart.
Maybe some other software you've installed on your site outside Zen Cart.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

23 Feb 2010, 6:48 AM
#5
djculture avatar

djculture

New Zenner

Join Date:
Feb 2010
Posts:
5
Plugin Contributions:
0

Post #5 by djculture

What about this part???

"Please note the rows_examined... thats nearly 7 million rows... that is quite a lot. I dont know what the heck that line does (something with moods and archives?), but you may want to visit Zencart and see if there is anyway to not get that line to execute...""

23 Feb 2010, 7:05 AM
#6
djculture avatar

djculture

New Zenner

Join Date:
Feb 2010
Posts:
5
Plugin Contributions:
0

Post #6 by djculture

I meant this part... "Please note the rows_examined... thats nearly 7 million rows..."

23 Feb 2010, 7:25 AM
#7
djculture avatar

djculture

New Zenner

Join Date:
Feb 2010
Posts:
5
Plugin Contributions:
0

Post #7 by djculture

and no, i have only zen cart installed on that website

23 Feb 2010, 8:07 AM
#8
kobra avatar

kobra

Black Belt

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

Post #8 by kobra

Please understand that ZenCart does not have ant tables with those names nor any code that accesses them

Unless you have a 3rd party addon module that created those tables,
This is not a ZenCart issue

Zen-Venom Get Bitten

23 Feb 2010, 9:14 AM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #9 by drbyte

The 7 million rows are from tables that have nothing to do with Zen Cart.

So, you're host is right: 7 million is a LOT, and that's likely where your problem is. But, it's got nothing to do with Zen Cart.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

24 Feb 2010, 7:38 PM
#10
slawsonb avatar

slawsonb

New Zenner

Join Date:
Feb 2010
Posts:
1
Plugin Contributions:
0

Post #10 by slawsonb

7 million is a lot of rows but not necessarily something that should bring mysql to it's knees. Did this problem happen suddenly or has it been slowly getting worse as the db grew? Do you have a dedicated mysql box or is it shared with other users? It may be other databases slowing you down. Does the mysql box have enough free disk space including swap space?

24 Feb 2010, 8:07 PM
#11
hhrowal avatar

hhrowal

New Zenner

Join Date:
Feb 2010
Posts:
1
Plugin Contributions:
0

Post #11 by hhrowal

You say everything slowed down when you upgraded. Did anything change in the DB schema as a result of the upgrade? Did the table have 7 mil rows before and all worked fine? Are the columns used in the condition indexed?

28 Feb 2010, 1:31 AM
#12
astrozomby avatar

astrozomby

New Zenner

Join Date:
Feb 2010
Posts:
4
Plugin Contributions:
0

Post #12 by astrozomby

The host provider's support replied with what makes it look like a performance issue caused by another customer's bad query on a shared host or database?

The previous tech was mistaken and sent you a query that did not belong to you, hence why zencart says those tables don't exist. It looks like you are running the newest version of zencart.

I'll work on fixing up that bad query that belongs to another customer, and check for any other queries on the mysql server that could be an issue. Otherwise I cannot find any problems with the database setup or mysql server issues at this time.

Based on that, it seems like this slowness may be caused by some runaway query from another user on the same shared DB host.

hhrowal:

You say everything slowed down when you upgraded. Did anything change in the DB schema as a result of the upgrade? Did the table have 7 mil rows before and all worked fine? Are the columns used in the condition indexed?

It is probably coincidence that this slowdown happened after the upgrade since things were running as normal with the site for a couple weeks after upgrading the version of ZenCart - and is more likely caused by other performance issues on the same shared db host.

I'm not sure how we would go about comparing the DB Schema from before and after the upgrade.

slawsonb:

7 million is a lot of rows but not necessarily something that should bring mysql to it's knees. Did this problem happen suddenly or has it been slowly getting worse as the db grew? Do you have a dedicated mysql box or is it shared with other users? It may be other databases slowing you down. Does the mysql box have enough free disk space including swap space?

The DB is a shared hosting account, virtual host, and likely has multiple DBs on the same physical hardware. Not sure how we'll be able to go about checking if the MySQL box has enough free / swap space -- probably need to be bringing these up with the hosting support guys.

Regarding when it happened, from talking to djculture personally, it sounds like things were running fine for a couple weeks after the version of ZenCart was upgraded, then the site got SLOW, gradually.

So, it does sound like maybe another user's db on the same shared host was growing out of control or something?

If that's the case, there may be nothing to do on the djculture side, outside of maybe getting the db moved to another host that is not having the same performance hit.

28 Feb 2010, 7:37 PM
#13
astrozomby avatar

astrozomby

New Zenner

Join Date:
Feb 2010
Posts:
4
Plugin Contributions:
0

Post #13 by astrozomby

astrozomby:

The DB is a shared hosting account, virtual host, and likely has multiple DBs on the same physical hardware. Not sure how we'll be able to go about checking if the MySQL box has enough free / swap space -- probably need to be bringing these up with the hosting support guys.

Just discovered that for shared hosting (aka: not dedicated server) with the provider, they don't provide access to the MySQL log files and such, so we really need plenty of help from the provider's support team on this.

Ugh.

28 Feb 2010, 9:27 PM
#14
astrozomby avatar

astrozomby

New Zenner

Join Date:
Feb 2010
Posts:
4
Plugin Contributions:
0

Post #14 by astrozomby

Just for a little further detail...

Running a query for all products on the DB shows 1531 records, and a query time of just over 3 seconds. I'm using Navicat Lite for my DB queries at the moment.

select * from `djcwebshop_zc`.`zen_products` ORDER BY PRODUCTS_QUANTITY
...
Query Time:3.36 sec

I wrote a shell script that attempts to load a few of the pages in the online store and report the load times. Basically it just uses curl to hit three URLs and report the times it finds.

It's pretty much like this.
curl -s -w "%{time_total}" <url>

Following is the result of 10 sequential requests for the three URLs we wanted to test load times for on the site.

  1. the main index page
  2. the Vinyl dept page
  3. the Vinyl/Record Lots sub category page
Index   Vinyl  Record Lots  Date
3.505   1.937  11.961       20100228-131657
3.320   2.048  4.975        20100228-131714
2.414   2.144  4.760        20100228-131725
3.867   1.894  5.967        20100228-131734
3.453   2.783  4.827        20100228-131746
2.918   4.219  4.647        20100228-131757
1.828   4.764  7.567        20100228-131809
2.997   4.825  6.715        20100228-131823
10.232  8.158  24.025       20100228-131837
7.097   8.577  19.479       20100228-131920

It is notable that during this run, we also were attempting to browse the site from another computer. It seems like the very high load times seen here coincided approximately with the time that the second computer was also trying to browse the site.

28 Feb 2010, 10:15 PM
#15
astrozomby avatar

astrozomby

New Zenner

Join Date:
Feb 2010
Posts:
4
Plugin Contributions:
0

Post #15 by astrozomby

Ran the page load time script a couple more times for 10 loads in succession each time.

Load times are all over the place.

$ sh djc_time.sh 10
Index  Vinyl  Record Lots  Date
6.318  4.633  16.202       20100228-135130
5.143  5.874  19.944       20100228-135157
6.656  7.402  18.919       20100228-135228
4.158  5.027  9.055        20100228-135301
1.229  2.999  17.398       20100228-135319
4.878  4.043  13.923       20100228-135341
5.516  3.873  14.035       20100228-135404
4.219  3.139  13.673       20100228-135427
5.208  3.691  16.573       20100228-135448
1.773  3.507  5.725        20100228-135514

$ sh djc_time.sh 10
Index  Vinyl  Record Lots  Date
2.025  1.004  6.722        20100228-140631
5.350  3.641  3.750        20100228-140641
1.925  2.194  3.393        20100228-140653
2.109  1.551  4.574        20100228-140701
3.549  2.591  7.091        20100228-140709
2.123  2.449  4.254        20100228-140722
2.107  1.163  6.848        20100228-140731
1.813  4.431  4.276        20100228-140741
2.230  3.255  3.296        20100228-140752
2.217  1.249  2.554        20100228-140801