Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2006
    Location
    SF Bay Area
    Posts
    867
    Plugin Contributions
    1

    Default Requesting two rows of data generates almost 100 extra queries?

    Looking at the query log dosent seem right, or am I missing something?

    When I execute this code:

    Code:
    		$md_sql = "select * from m_data where md_ID = " . $master_ID;
    
    		$movie_data = $db->Execute($md_sql);
    
    		if ($movie_data->RecordCount() > 0)
    			{
    			while (!$movie_data->EOF)
    				{
    				echo '<p>Title: ' . $movie_data->fields['md_title'] . '</p>';
    				$movie_data->MoveNext();
     		 		}
    			}
    it returns two records from a table that has only 7 records in it, yet the #of queries reported jumps from 336 to 423

    Does it really take 87 queries to select two records out of seven? Or is the way the queries are counted wrong? Or am I doing something wrong?

    Yes, the table is properly indexed.

    If it's true, is there any way to make this more reasonable?

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Requesting two rows of data generates almost 100 extra queries?

    I think you're doing something wrong with how you're structuring the use of your custom code ... perhaps you've got your query stuck in the middle of a loop, thus causing it to run multiple times.
    .

    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.

  3. #3
    Join Date
    Jul 2006
    Location
    SF Bay Area
    Posts
    867
    Plugin Contributions
    1

    Default Re: Requesting two rows of data generates almost 100 extra queries?

    Well, if it was looping and executing more than once, the test-echo stmnt would fire in each iteration through the loop and make the problem obvious.

    Its copied almost verbatim from the example in the wiki with the exception of the table/field names.

    The snippit in question executes in includes/modules/pages/product_info/main_template_vars.php to pull in some data from an additional table in the ZC database.

    It runs immediately after the main select at about line 46-ish

    If it matters, it does return the expected data. The echo stmnt is just for testing.

    The results have me worried as this table will eventually contain ~100,000 rows.

    Would it be more efficient to just use $result=mysql_query(...)?

    Thanks for your expert eye.
    Last edited by kiddo; 15 Nov 2009 at 04:16 AM. Reason: typo

  4. #4
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Requesting two rows of data generates almost 100 extra queries?

    The code you posted is just one single query. Unless you've done other changes which you've not mentioned.

    Anything else that's changing must be related to other things happening on the page ... perhaps you have a New Products box enabled, and certain products are on sale but others aren't, and when the ones on-sale appear they require additional queries to calculate/display appropriate details, etc.
    .

    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.

 

 

Similar Threads

  1. Extra Images are stacking instead of rows.
    By Ralyn in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 12 Mar 2015, 06:39 PM
  2. Almost have my two-factor authentication working...
    By veryveryinteresting in forum General Questions
    Replies: 3
    Last Post: 5 Sep 2013, 12:51 AM
  3. Product List Columns - Extra Rows
    By coxdabd in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 29 Nov 2010, 03:41 PM
  4. Almost 100% successful...
    By jenpen in forum Upgrading from 1.3.x to 1.3.9
    Replies: 0
    Last Post: 11 Aug 2010, 07:17 AM
  5. Payment Module that generates XML-based data?
    By Liquid Inc. in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 13 Aug 2008, 07:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg