Forums / General Questions / 45,000 queries to load my categories? Horrid performance

45,000 queries to load my categories? Horrid performance

Locked

Views: 2,385

Results 1 to 20 of 26
This thread is locked. New replies are disabled.
10 Jun 2008, 7:10 PM
#1
motodelta avatar

motodelta

Zen Follower

Join Date:
Jan 2006
Posts:
119
Plugin Contributions:
0

45,000 queries to load my categories? Horrid performance

I'm setting up a new store with a very broad category heirarchy.

Loading the 1st and second level categories has been VERY problematic. When I click on one category from the top level it takes nearly 2 minutes to load and shows 45k+ queries executed!

How is that possible? Is it preloading all the sub-categories? It's making usage of the store infeasible. Any way to tweak it?

Thanks!!!

10 Jun 2008, 7:16 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: 45,000 queries to load my categories? Horrid performance

What version of Zen Cart?
What addons do you have installed?
How many categories do you have?
Have you tried turning off category counts? Admin->Configuration->My Store->Show Category Counts (It's very intensive calculating children through all levels when you have huge numbers of categories)

.
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.

10 Jun 2008, 7:25 PM
#3
motodelta avatar

motodelta

Zen Follower

Join Date:
Jan 2006
Posts:
119
Plugin Contributions:
0

Re: 45,000 queries to load my categories? Horrid performance

It's version 1.3.8. I AM on a shared hosting environment (soon to change) but relatively speaking most response times are good, it's just the first/second level category clicks that seem to be terribly inefficient. Once I get to level 3 of the tree the number of queries goes down to sub 500 and performance is acceptable.

I have turned off Category counts. I also turned on GZIP but I doubt this would make a difference because the page being loaded only has images for 2-3 of the 35 subcategories.

I can't tell you exactly how many categories I have, but as reference if I export using Easypopulate I have 17k category rows. (That will include parents though, so this particular branch probably has over 7000).

Mods installed are:

  1. Easypopulate
  2. Multi-site
  3. Sales report
  4. Dual Pricing.
  5. Supplier interface.

I'm an experienced systems guy but woefully short on PHP and MySQL knowledge.

Thanks for the quick reply.

10 Jun 2008, 7:27 PM
#4
drbyte avatar

drbyte

Sensei

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

Re: 45,000 queries to load my categories? Horrid performance

Forgive the slightly altered topic of this question ... but ... how exactly are you trying to display 7000 categories on a page?

.
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.

10 Jun 2008, 9:50 PM
#5
kobra avatar

kobra

Black Belt

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

Re: 45,000 queries to load my categories? Horrid performance

Give us a link to see your site

Zen-Venom Get Bitten

11 Jun 2008, 1:12 AM
#6
motodelta avatar

motodelta

Zen Follower

Join Date:
Jan 2006
Posts:
119
Plugin Contributions:
0

Re: 45,000 queries to load my categories? Horrid performance

DrByte:

Forgive the slightly altered topic of this question ... but ... how exactly are you trying to display 7000 categories on a page?

I misunderstood. I have 17k TOTAL. However the category I am trying to expand has about 35. (with a total of 7000 on this branch at all levels beneath it The breakdowns are:

Level 1 - 5 categories
Level 2 - 35 categories for each level 1
Level 3 - 20 categories for each level 2
Level 4 - 4 categories for each level 3

So when I click on the level 1 category, it does 45k queries to expand to level 2. I cannot post a link to the site unfortunately because it is under Non-Disclosure at the moment. My question really is, why when I am only expanding out to 35 categories is the system doing 45k queries. I can only assume it is reading all categories beneath it.

11 Jun 2008, 1:26 AM
#7
kobra avatar

kobra

Black Belt

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

Re: 45,000 queries to load my categories? Horrid performance

MotoDelta,

Can not really expound without seeing what and how you are organized...

I have done sites with 100,000+ products and parse times are normally sub-second on a fast optimized server

Zen-Venom Get Bitten

11 Jun 2008, 1:29 AM
#8
vger avatar

vger

Past Contributor

Join Date:
Nov 2004
Location:
Norfolk, United Kingdom
Posts:
3,189
Plugin Contributions:
0

Re: 45,000 queries to load my categories? Horrid performance

Under Configuration --> logging you can turn off Store Page Parse Time, Display Page Parse Time and Store Database Queries - but the big user of mysql resources as Dr Byte has said is to turn off Category Counts.

Vger

11 Jun 2008, 2:22 AM
#9
motodelta avatar

motodelta

Zen Follower

Join Date:
Jan 2006
Posts:
119
Plugin Contributions:
0

Re: 45,000 queries to load my categories? Horrid performance

kobra/DrByte, I've PM'd you the address.

Thanks for the assist!

11 Jun 2008, 3:45 AM
#10
motodelta avatar

motodelta

Zen Follower

Join Date:
Jan 2006
Posts:
119
Plugin Contributions:
0

Re: 45,000 queries to load my categories? Horrid performance

I thought I had it figured, but didn't.

11 Jun 2008, 3:53 AM
#11
drbyte avatar

drbyte

Sensei

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

Re: 45,000 queries to load my categories? Horrid performance

Do any of your products use attributes? Are any products set to priced-by-attributes?
Do you have any Specials or Salemaker sales active?
Does the performance change if you're logged in as a discounted customer (ie: using the dual-pricing feature you added)?
Do you have the store configured for tax-included pricing? or the normal tax-is-added-afterward mode?

.
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.

11 Jun 2008, 4:01 AM
#12
motodelta avatar

motodelta

Zen Follower

Join Date:
Jan 2006
Posts:
119
Plugin Contributions:
0

Re: 45,000 queries to load my categories? Horrid performance

DrByte:

Do any of your products use attributes? Are any products set to priced-by-attributes?
Do you have any Specials or Salemaker sales active?
Does the performance change if you're logged in as a discounted customer (ie: using the dual-pricing feature you added)?
Do you have the store configured for tax-included pricing? or the normal tax-is-added-afterward mode?

No attributes yet.
No sales yet
I'll check on discounted customer.
I used normal tax-added pricing.

I've just whacked the data to load ONLY the categories (no products) because there was an issue with the product-to-category mapping. This won't help the performance (saw this same issue before products were added) but will help me narrow down some queries.

11 Jun 2008, 4:07 AM
#13
drbyte avatar

drbyte

Sensei

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

Re: 45,000 queries to load my categories? Horrid performance

Well, since a big part of building the page that's seen when a given category is selected is the identifying and retrieving of products related thereto, I would expect to see a performance change if you have no products.

.
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.

11 Jun 2008, 4:09 AM
#14
motodelta avatar

motodelta

Zen Follower

Join Date:
Jan 2006
Posts:
119
Plugin Contributions:
0

Re: 45,000 queries to load my categories? Horrid performance

True,

But if there are no products in the category I am selected, just more categories, then would it still matter?

11 Jun 2008, 4:43 AM
#15
drbyte avatar

drbyte

Sensei

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

Re: 45,000 queries to load my categories? Horrid performance

Well if the problem is with how your products are linked to the categories and it's getting stuck recalculating things for some reason, then some bottlenecking wouldn't be a surprise.

It seems to be operating quite speedily right now, without the products.

How exactly did you add all your categories and products?

.
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.

11 Jun 2008, 4:56 AM
#16
motodelta avatar

motodelta

Zen Follower

Join Date:
Jan 2006
Posts:
119
Plugin Contributions:
0

Re: 45,000 queries to load my categories? Horrid performance

Even with no products loaded I am seeing the bad performance so I don't think it's related to product linking. I am using easypopulate to load data.

If you click on "Racing" category off of home, I get a 2 minute load time, but it has 28 categories in the next level.

The "New" category has 90 categories in the next level and it loads faster.

THe difference? New has 900 total categories in it's "tree". Racing has 7k categories in it's tree.

It appears that the subcategories are being read and not displayed I would think. The "depth" of the category tree seems to impact performance hinting at perhaps some sub-optimal SQL?

11 Jun 2008, 5:01 AM
#17
motodelta avatar

motodelta

Zen Follower

Join Date:
Jan 2006
Posts:
119
Plugin Contributions:
0

Re: 45,000 queries to load my categories? Horrid performance

It's only the first level expansion of categories that is really giving me performance fits. Everything else is "reasonable" based on my slow host.

11 Jun 2008, 5:15 AM
#18
drbyte avatar

drbyte

Sensei

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

Re: 45,000 queries to load my categories? Horrid performance

MotoDelta:

If you click on "Racing" category off of home, I get a 2 minute load time, but it has 28 categories in the next level.
The page is loading in about 1.5 seconds for me, for that category.

.
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.

11 Jun 2008, 5:17 AM
#19
drbyte avatar

drbyte

Sensei

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

Re: 45,000 queries to load my categories? Horrid performance

MotoDelta:

The "depth" of the category tree seems to impact performance hinting at perhaps some sub-optimal SQL?
That's quite possible. That part of the code has been completely rewritten for v1.4.0, along with refactoring how products are loaded by using some factory classes ... all equating to huge performance improvements.
Alas, that code isn't available for public consumption yet. But the comment is noted and already addressed.

.
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.

11 Jun 2008, 5:29 AM
#20
drbyte avatar

drbyte

Sensei

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

Re: 45,000 queries to load my categories? Horrid performance

DrByte:

That's quite possible. That part of the code has been completely rewritten for v1.4.0, along with refactoring how products are loaded by using some factory classes ... all equating to huge performance improvements.
Alas, that code isn't available for public consumption yet. But the comment is noted and already addressed.

I take that back. While the comments about optimization are correct, the SQL that builds the category list is extremely simple. It's a simple join between 2 tables with a where clause indicating the parent id. That should be quick, even on a slow server. An additional lookup is done for each category in that resultset to generate its proper full cPath value, thus generating a few more queries.

.
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.