If this is your first visit, check our documentation. To post, register or login.
Forums / Upgrading Your Zen Cart / Upgrading from 1.3.x to 1.3.9 / 34 queries to mySQL per second, is this too high?

34 queries to mySQL per second, is this too high?

Locked

Started by tamya on 1 Nov 2011, 1:08 PM · Views: 10,193

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
1 Nov 2011, 1:08 PM
#1
tamya avatar

tamya

Zen Follower

Join Date:
Feb 2007
Posts:
336
Plugin Contributions:
0

Post #1 by tamya

I received an email from my host saying that i am using too much resources on the server, below is the email i got i am only replacing sensitive data with xxxxxxxxxx.

System administration has been monitoring high resource usage on your server and has traced it back to your account, xxxxxxxx. Upon review of your account, you are querying the mySQL server at an average rate of 34 queries per second. This is very intensive on the server, and we may be forced to suspend your account in order to prevent you from affecting other customers.

this is a sample of the log file they send me, it is huge and i selected a few lines as a sample

11143385 Query       select * from ezpages where status_footer = 1 and footer_sort_order > 0 order by footer_sort_order, pages_title
		11143385 Query       select banners_id, banners_title, banners_image, banners_html_text, banners_open_new_windows, banners_url
                           from banners
                               where status = 1  and ( banners_group = 'Wide-Banners') order by rand()
		11143385 Query       select categories_name from categories_description where categories_id = '29'
		11143385 Query       insert into user_tracking (customer_id, full_name, session_id, ip_address, time_entry, time_last_click, last_page_url, referer_url, page_desc, customers_host_address) values ('0', 'Guest', '', '207.46.13.96', '1320096002', '1320096002', '/xxxxxxxxxxxxxxxxxxxxx', '/xxxxxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;- ', 'msnbot-207-46-13-96.search.msn.com')
		11143385 Quit       
111031 14:20:46	11143961 Connect     xxxxxxxxxxx@localhost on 
		11143961 Init DB     xxxxxxxxxxxx
		11143961 Query       select configuration_key as cfgkey, configuration_value as cfgvalue
                                 from configuration
		11143961 Query       select configuration_key as cfgkey, configuration_value as cfgvalue
                          from product_type_layout
		11143961 Query       select code, title, symbol_left, symbol_right, decimal_point,
                                  thousands_point, decimal_places, value
                          from currencies
		11143961 Query       select languages_id, name, code, image, directory
                          from languages 
                          order by sort_order
		11143961 Query       select template_dir
            from template_select
            where template_language = 0
		11143961 Query       select template_dir
            from template_select
            where template_language = '1'
		11143961 Query       select code
                      from currencies
                      where code = 'USD' LIMIT 1
		11143961 Query       delete from whos_online
          where time_last_click < '1320095146'
		11143961 Query       select count(*) as count
                              from whos_online
                              where session_id = '' and ip_address='208.83.156.156'
		11143961 Query       update whos_online
              set customer_id = '0',
                  full_name = '¥Spider',
                  ip_address = '208.83.156.156',
                  time_last_click = '1320096046',
                  last_page_url = '/index.php?cPath=xxxxxxxxxxxxxxxxxxxxxxx',
                  host_address = 's14.fatlens.com',
                  user_agent = 'Mozilla/5.0 (compatible; FatBot 2.0; http://www.thefind.com/crawler)'
              where session_id = '' and ip_address='208.83.156.156'
		11143961 Query       select banners_id, date_scheduled
                      from banners
                      where date_scheduled != 'NULL'
		11143961 Query       select b.banners_id, b.expires_date, b.expires_impressions,
                             sum(bh.banners_shown) as banners_shown
                      from banners b, banners_history bh
                      where b.status = 1
                      and b.banners_id = bh.banners_id
                      group by b.banners_id, b.expires_date, b.expires_impressions
		11143961 Query       select specials_id, products_id
                       from specials
                       where status = '0'
                       and (((specials_date_available <= 20111031 and specials_date_available != '0001-01-01') and (expires_date > 20111031))
                       or ((specials_date_available <= 20111031 and specials_date_available != '0001-01-01') and (expires_date = '0001-01-01'))
                       or (specials_date_available = '0001-01-01' and expires_date > 20111031))
		11143961 Query       select specials_id, products_id
                       from specials
                       where status = '1'
                       and (20111031 < specials_date_available and specials_date_available != '0001-01-01')
		11143961 Query       select specials_id, products_id
                       from specials
                       where status = '1'
                       and ((20111031 >= expires_date and expires_date != '0001-01-01')
                       or (20111031 < specials_date_available and specials_date_available != '0001-01-01'))
		11143961 Query       select featured_id
                       from featured
                       where status = '0'
                       and (((featured_date_available <= 20111031 and featured_date_available != '0001-01-01') and (expires_date > 20111031))
                       or ((featured_date_available <= 20111031 and featured_date_available != '0001-01-01') and (expires_date = '0001-01-01'))
                       or (featured_date_available = '0001-01-01' and expires_date > 20111031))
		11143961 Query       select featured_id
                       from featured
                       where status = '1'
                       and (20111031 < featured_date_available and featured_date_available != '0001-01-01')
		11143961 Query       select featured_id
                       from featured
                       where status = '1'
                       and ((20111031 >= expires_date and expires_date != '0001-01-01')
                       or (20111031 < featured_date_available and featured_date_available != '0001-01-01'))
		11143961 Query       select sale_id
                       from salemaker_sales
                       where sale_status = '0'
                       and (((sale_date_start <= 20111031 and sale_date_start != '0001-01-01') and (sale_date_end > 20111031))
                       or ((sale_date_start <= 20111031 and sale_date_start != '0001-01-01') and (sale_date_end = '0001-01-01'))
                       or (sale_date_start = '0001-01-01' and sale_date_end > 20111031))
		11143961 Query       select sale_id
                       from salemaker_sales
                       where sale_status = '1'
                       and (20111031 < sale_date_start and sale_date_start != '0001-01-01')
		11143961 Query       select sale_id
                       from salemaker_sales
                       where sale_status = '1'
                       and ((20111031 >= sale_date_end and sale_date_end != '0001-01-01')
                       or (20111031 < sale_date_start and sale_date_start != '0001-01-01'))
		11143961 Query       select categories_name
                           from categories_description
                           where categories_id = '49'
                           and language_id = '1'
		11143961 Query       select categories_name
                           from categories_description
                           where categories_id = '127'
                           and language_id = '1'
		11143961 Query       select categories_name
                           from categories_description
                           where categories_id = '56'
                           and language_id = '1'
		11143961 Query       select *
        from get_terms_to_filter

I am using zen cart 1.3.9h
Parse Time: 0.167 - Number of Queries: 245 - Query Time: 0.0508309648895

My questions are:

Is 34 queries a second too much?
i do not have any banners but the log shows that the banners database has been accessed, why?
Any Ideas?

Thanks

1 Nov 2011, 8:24 PM
#2
drbyte avatar

drbyte

Sensei

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

Post #2 by drbyte

The idea of "34 queries per second" is a meaningless statistic. When your site's pages are being drawn, you want it to be able to do thousands of queries per second, but only for a fraction of a second total.
The only time that would be a problem is if you're getting hit with hundreds of customers at one time.
Or maybe you've got a search engine spidering (indexing) your site, and it's "clicking" too fast.

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

1 Nov 2011, 11:46 PM
#3
tamya avatar

tamya

Zen Follower

Join Date:
Feb 2007
Posts:
336
Plugin Contributions:
0

Post #3 by tamya

Thanks DrByte,

Parse Time: 0.214 - Number of Queries: 248 - Query Time: 0.0732615336761

based on the number of queries above 248/34 = 7.3, so if a page get clicked every 7.3 seconds then we have an average of 34 queries a second assuming all pages will have 248 queries and the server will be dragging based on the hosting company status.

my question is is this zen cart has a faulty code from me updating and installing modes, etc. or is it normal?

2 Nov 2011, 2:28 AM
#4
drbyte avatar

drbyte

Sensei

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

Post #4 by drbyte

Every page has a different number of queries, depending on what page it is, what products are shown in sideboxes or anywhere else, what sales or specials might affect price, how many sideboxes or other blocks of content are being displayed, etc. It's not surprising to see upwards of 800 or more even on the home page in some cases, with ZC v1.x. That in itself is not a problem, and most hosts don't complain about it because they have built their servers to handle database-driven websites.

Some people have complained that ZC has too many queries, and all the people making those complaints are typically people reporting that they've got 700-1500 queries on every page. Clearly your site isn't falling into that category. There are some known inefficiencies that the developers are fixing by rebuilding the code for v2.0, but that's irrelevant at this stage for your site.

If your host doesn't want to allow you to serve up pages based on database-driven content, then obviously you've got the wrong host for your business needs.

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