Zen Cart Logo
Forums / General Questions / Database queries - too many?

Database queries - too many?

Locked

Views: 2,336

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
6 Dec 2008, 4:32 AM
#1
anna718 avatar

anna718

New Zenner

Join Date:
Dec 2008
Location:
Tasmania. Australia
Posts:
35
Plugin Contributions:
0

Database queries - too many?

I am currently in the process of setting up my site, but one thing I have notice is that the number of database queries on a product page are through the roof.

I only have two products listed right now, though more will follow and on the product pages I am seeing 570 and 672 database queries, depending on which product I go to.

I also run an Invision forum, and the worst page on that site, with a lot of extras, only results in about 60 queries per pageload.

Why are there so many queries on a product page load for zen cart? 672 queries is a little over the top.

I run image handler 2, have downloads turned off, and also have category counts turned off. I really want to reduce this before I go live.

You can check out my site at RT Gallery username "Tester" password "user" (without quotes) both are case sensitive

Any suggestions would be appreciated. Thanks

6 Dec 2008, 4:37 AM
#2
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Database queries - too many?

Anna718:

I am currently in the process of setting up my site, but one thing I have notice is that the number of database queries on a product page are through the roof.

I only have two products listed right now, though more will follow and on the product pages I am seeing 570 and 672 database queries, depending on which product I go to.

I also run an Invision forum, and the worst page on that site, with a lot of extras, only results in about 60 queries per pageload.

Why are there so many queries on a product page load for zen cart? 672 queries is a little over the top.

I run image handler 2, have downloads turned off, and also have category counts turned off. I really want to reduce this before I go live.

You can check out my site at RT Gallery username "Tester" password "user" (without quotes) both are case sensitive

Any suggestions would be appreciated. Thanks

This will be addressed in v1.4.0 releasing this month (or so I heard)

6 Dec 2008, 4:42 AM
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Database queries - too many?

Version 1.4 (theoretically due out this year - we'll see) addresses this in a big way.
See the roadmap in the Zen Cart Release Announcements forum.

6 Dec 2008, 4:42 AM
#4
anna718 avatar

anna718

New Zenner

Join Date:
Dec 2008
Location:
Tasmania. Australia
Posts:
35
Plugin Contributions:
0

Re: Database queries - too many?

Thanks yellow1912.

I certainly hope it is, as this is over the top.

6 Dec 2008, 5:10 AM
#5
drbyte avatar

drbyte

Sensei

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

Re: Database queries - too many?

LOL ... keep in mind ... unlike a forum, with an ecommerce site you're dealing with display and calculation of sales, specials, taxes, extra sideboxes for displaying different pieces of information in different ways, product listings, categories, images, etc.

That said, it's a well-known fact that v1.3 and earlier inherited some bad query structures from the initial code base. A huge amount of that has been rewritten for 1.4, as explained above, and detailed in the roadmap.

6 Dec 2008, 5:36 AM
#6
anna718 avatar

anna718

New Zenner

Join Date:
Dec 2008
Location:
Tasmania. Australia
Posts:
35
Plugin Contributions:
0

Re: Database queries - too many?

Understandable Sensei, but on my forum, which is very heavily modified, there are probably more individual pieces of data being displayed that I see on my product pages. As for images, they do not cause database queries, or at least they should not, and my forum has heavy graphics, with images up to 10Mb each in place sometimes 30 to a page.

I have zero tax rates, no specials, zero reviews, and only two products in one category right now. I shudder to think what will happen once the store is fully populated.

IT worries me as my hosts have a limit on 20,000 database queries per hour, and with 670+ queries on a single page load, that limit can be reached far too quickly. No page requires 670 database queries, especially when 99.9999999% of the information is static, the only thing that might change is the stock level.

6 Dec 2008, 6:02 AM
#7
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Database queries - too many?

The category tree is the main cause for the current number of queries. Especially if you have too many categories.

You may consider caching it and other blocks that may use too many queries
http://www.zen-cart.com/forum/showthread.php?t=109160&highlight=cache

Or use an alternative category tree that uses less query.
This one for example, using a single query along with caching as well:
http://www.zen-cart.com/forum/showthread.php?t=88215&highlight=simple+category+tree

Or you can wait till 1.4 coming out, please make it an XMAS gift for us, DrByte

6 Dec 2008, 12:13 PM
#8
anna718 avatar

anna718

New Zenner

Join Date:
Dec 2008
Location:
Tasmania. Australia
Posts:
35
Plugin Contributions:
0

Re: Database queries - too many?

Thanks yellow1912, but I would prefer to avoid caching the product pages as stock levels will be strictly limited, and although I could manage that with cron, I just prefer not to.

One thing that I do not understand is that if you look at the two product pages I currently have in place, the first has 8 options for attributes and the second has 6 options. Why would there be around 100 extra database queries for the first than the second, when all other page details are identical? Two more options creates 100 database queries does not make programming logic sense????

Please bring on 1.4

6 Dec 2008, 2:14 PM
#9
drbyte avatar

drbyte

Sensei

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

Re: Database queries - too many?

Again, you can thank the folks over at the other shopping cart that wrote the original attributes code with a weak database structure and bloated inefficient coding.
The 1.4 version will make a huge difference in performance in these areas.

6 Dec 2008, 7:13 PM
#10
stonecoldinc avatar

stonecoldinc

New Zenner

Join Date:
Nov 2008
Location:
New Jersey, USA
Posts:
14
Plugin Contributions:
0

Re: Database queries - too many?

Cool Website, What tool did you use to handle your Pics?

6 Dec 2008, 10:34 PM
#11
anna718 avatar

anna718

New Zenner

Join Date:
Dec 2008
Location:
Tasmania. Australia
Posts:
35
Plugin Contributions:
0

Re: Database queries - too many?

Thanks all for teh responses. I was not planning to go live with this site until January, so hopefully 1.4 will be out by then. I still like this software far better than others I have tried.

stonecoldinc, The images were originally optimized in photoshop, but I have since added image handler 2. The front entry page though was done entirely in photoshop. I also use zen lightbox for the larger view. Glad you like the look.