Author Topic: DB Queries Issue  (Read 5840 times)

0 Members and 1 Guest are viewing this topic.

Offline Fastian

  • Full Member
  • ***
  • Posts: 199
    • View Profile
DB Queries Issue
« on: September 07, 2006, 04:21:37 PM »
I have another thread here about my DB problem.
V@no replied to disable "random" images on pages but I do need this thing so I don’t want to disable it.

No I am trying to investigate the issue if REALLY my site is making 50,000 queries per hour even with 50-60 page views per hour.
So please help me do so. My questions are:

1) When I enable to show queries from constans.php, Along with the line telling no. of queries per hour, I also get the detail of timing spent on each query. ( becomes a long long page) How can I disable to show this timing?

2) Please tell me that when a search engine spider is crawling my site, do they also add toward no. queries on each page?? (like normal users)  And if they do, does Caching effect the spider as well ??

(I am on v1.7.1 & has enabled Cache feature with timeout 30 minutes)
I m not a  Programmer.
          But
I m a Good Learner.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: DB Queries Issue
« Reply #1 on: September 08, 2006, 12:38:42 AM »
1) in includes/page_footer.php replace
Code: [Select]
  printf("<p align=\"center\"><font size=\"-2\">Page generated in %f seconds with ".$site_db->query_count." queries, spending %f seconds doing MySQL queries and %f doing PHP things. $gzip_text</font></p>", $total_time, $sql_time, $php_time);
with:
Code: [Select]
  printf("<p align=\"center\"><font size=\"-2\">Page generated in %f seconds with ".$site_db->query_count." queries, spending %f doing PHP things. $gzip_text</font></p>", $total_time, $php_time);

2) spiders for 4images are the same visitors as anybody else, so yes, spiders will see exactly the same what anyone else does.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Fastian

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: DB Queries Issue
« Reply #2 on: September 08, 2006, 03:51:42 PM »
Ok.
That means that i am having problem on my site coz of search engine spiders.
I can see Google, MSN & Yahoo sitting on my site for most of the time. Yesterday Google-bot was there for around 6-8 hours. (Kinda like my site)

Is there any way i can limit access of Bots to save Queries limit. I mean, they can crawl the site but only for limited time. (Max 2 hours)

BTW, V@no, would u please tell me what should be the average queries per page for a big site. Like yours.
I m not a  Programmer.
          But
I m a Good Learner.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: DB Queries Issue
« Reply #3 on: September 09, 2006, 01:49:50 AM »
Ok.
That means that i am having problem on my site coz of search engine spiders.
I can see Google, MSN & Yahoo sitting on my site for most of the time. Yesterday Google-bot was there for around 6-8 hours. (Kinda like my site)

Is there any way i can limit access of Bots to save Queries limit. I mean, they can crawl the site but only for limited time. (Max 2 hours)
I dont know, maybe you can do something like that with robots.txt (google around for more info ;))

BTW, V@no, would u please tell me what should be the average queries per page for a big site. Like yours.

The site size is irrelevant, its the code that metters...the default 4images code uses probably 10-15 queries per page...so, if you have bunch of stuff in page_header.php that only used on one/two pages, then its just waste of server resources and you should move that code into specific for the page file...(i.e. if you have statistics that displayed only on home page but the code is located in page_header.php then obviosly its not the correct place for the code, its belong in index.php instead)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Fastian

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: DB Queries Issue
« Reply #4 on: September 11, 2006, 08:31:28 PM »
The site size is irrelevant, its the code that metters...the default 4images code uses probably 10-15 queries per page...so, if you have bunch of stuff in page_header.php that only used on one/two pages, then its just waste of server resources and you should move that code into specific for the page file...(i.e. if you have statistics that displayed only on home page but the code is located in page_header.php then obviosly its not the correct place for the code, its belong in index.php instead)

Good point V@no. I found that i can move 3/4 different mod codes to index.php & details.php instead keeping them in page_header.php.
Can i ask that here one by one that where to move the block of code or should I ask that to the actual threads of the Mods..

"Mod=Last active User"                     --- Move the block of code to index.php
"Mod= MOD DOWNLOAD LIMIT "       --- Move the block of code to details.php
"Mod= Votes saved in DB"                ---- Move the block of code to details.php
 
I m not a  Programmer.
          But
I m a Good Learner.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: DB Queries Issue
« Reply #5 on: September 11, 2006, 10:56:59 PM »
I'd say move them below
Code: [Select]
include(ROOT_PATH.'includes/page_header.php');(if you have anything that needed to be in head.html template, then place it above that line ;)

I dont know what mods do you have, but if you have some statistics mod, then make sure its not in page_header.php (unless its displaying on every page)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Fastian

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: DB Queries Issue
« Reply #6 on: September 13, 2006, 08:41:53 PM »
I'd say move them below
Code: [Select]
include(ROOT_PATH.'includes/page_header.php');(if you have anything that needed to be in head.html template, then place it above that line ;)

I dont know what mods do you have, but if you have some statistics mod, then make sure its not in page_header.php (unless its displaying on every page)

I can’t understand first part of your message. I was trying to move a block of code from my page_header.php to other file. So what difference it makes if I add above or below this line
Code: [Select]
include(ROOT_PATH.'includes/page_header.php');
Anyway, I don’t think my page_header.php has so many thing in it that is causing this trouble. If you want i can send it to you and you can have a look yourself.

The statistic mode i am using contains no modification in page_header.php so this is not the problem as well.

I am indexed by Google for the word "max_questions" (2nd/3rd page) That’s too bad  :(
I m not a  Programmer.
          But
I m a Good Learner.