vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Queries = bandwidth? (https://vborg.vbsupport.ru/showthread.php?t=45224)

Kathy 10-30-2002 11:21 PM

Queries = bandwidth?
 
Hi Guys,

I'm working on re-designing the main page of my domain to include more includes.

Currently I have a few includes for my php banner system (dotbanner).

I also have two includes...both similar but for the latest 5 posts from two topic different forums.....

I also have another include that pulls the latest post from our "kudos" forum

Now i plan on adding a log-in include...

and 2 more includes for fresh content daily. (One include will be a thread that I choose weekly for "hot topic" but I didn't want it based on replies...but on best content.)

My question? Does this kind of query set up with includes cause a problem for bandwidth?

I'm asking because I am php challenged, server admin challenged, and except for the fact that I understand that bandwidth is costly...and larger/more graphics cost more money per visitor, I'm wondering if I'm creating a monster by redesigning my main page of my domain based on includes. Does it matter?

Any thoughts or advise? thanks!

Erwin 10-31-2002 01:18 AM

Query and bandwidth are not the same. Queries in general increase your server load by increasing access to the database, hard disk and CPU. Bandwidth is more related to the number of bytes being downloaded from your server, which has an effect on server load too, but is more generic, depending on how much graphics and other large files you have.

Kathy 10-31-2002 01:38 AM

Thanks Erwin. I had assumed that more queries = increase server load = bandwidth usage....

but if they are unrelated, is it okay to assume that if my server is set for queries okay...and my server load has been averaging 1.2 with my boards, then I'm okay for additional includes on my domain index page? Thanks!

Erwin 10-31-2002 01:54 AM

Your index page shouldn't have over 30 queries ideally. Remember, each include will add all the queries of the included php file into your index.php file as well.

Kathy 10-31-2002 02:19 AM

So can you help me with this math?

If an include asks to print the last 5 posts of a certain forum in part...with name/title/post up to 60 characters...

Is that 5 queries or is that more?

Erwin 10-31-2002 02:27 AM

No, it doesn't work that way. It depends on the PHP code used to retrieve and print the 5 posts. It may be 1 query only. Post the code here - usually (but not always) as a general rule if there is only 1 line that says "query ->" then that's only 1 query.

Velocd 10-31-2002 02:45 AM

If loading-speed of your pages is an issue, then how you use queries can become an important factor as well. Sometimes calling 2 queries that could have been combined in one bigger query is more efficient, since they will process faster resulting in your page being outputted quicker. Usually it depends on how you are querying the database though, so don't do anything drastically redundant.

Although, if your main goal is to lower server load, try combining similar queries and getting them ideally in the 20's or below for each PHP page.

Kathy 10-31-2002 02:55 AM

I have two includes set up side by side/top to bottom in a column on my index page.

they are only different in the forum they are pulling the posts from:

Code:

<?php


require("/usr/local/apache/sites/hystersisters.com/httpdocs/vb2/admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassword);
mysql_select_db($dbname);

        $num_active = 4;
        $num_chars  = 65;

        $db=mysql_connect($servername,$dbusername,$dbpassword);
        mysql_select_db($dbname);

        $querylatest="select * from thread where forumid='3' order by lastpost desc limit $num_active";

        $resultlatest = mysql_query($querylatest,$db);

        print("<center><table width=\"100%%\" cellspacing=\"0\" cellpadding=\"2\">");

        while ($latest_array = mysql_fetch_array($resultlatest)) {
       
        // Get Forum Infomation
        $query_forum = "select * from forum where forumid='$latest_array[forumid]'";
        $result_forum = mysql_query($query_forum,$db);
        $forum_info_array = mysql_fetch_array($result_forum);
       
        printf("<tr><td colspan=\"2\" bgcolor=\"#DCDEED\"><b><font color=\"#000000\" size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">%s: %s</font></b></td></tr>",$forum_info_array["title"],$latest_array["title"]);

        // split the date up a bit
        $datestr1 = substr($latest_array["dateline"],0,10);
        $datetime = substr($latest_array["dateline"],11,8);       
        printf ("<tr valign=\"top\"><td width=\"15%%\" bgcolor=\"#ffffff\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><b>%s</b><br>Updated: %s<br>Replies: %s</font></td>", $latest_array["postusername"], $datetime, $latest_array["replycount"]);

        $querythread="select * from post where threadid='$latest_array[threadid]' order by dateline asc limit 1";

        $result_thread_text= mysql_query($querythread,$db);

        $result_thread_array = mysql_fetch_array($result_thread_text);
        printf ("<td width=\"85%%\" bgcolor=\"#ffffff\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\"><img src=\"/vb2/images/icons/icon%s.gif\"> Last Post By: %s<hr>%s...<br><a href=\"/vb2/showthread.php?threadid=%s\">More...</font></td></tr>",$result_thread_array["iconid"],$latest_array["lastposter"],substr(strip_tags($result_thread_array["pagetext"]),0,$num_chars),$latest_array["threadid"]);
        printf ("<tr><td colspan=\"2\" width=\"100%%\"> </td></tr>");
        }
       

        printf ("</table></center>");
?>


Logician 10-31-2002 09:27 AM

general rule is this:

Whenever you see PHP command "mysql_query" add 1 query to your server load. For vb scripts the keyword is "$DB_site->query" or "$DB_site->query_first"..

But sometimes less query doesnt mean the best performance. If your query is too advanced or badly formed, it can sometimes eat more server source than 2 independent queries. But well these are expert tips, for your needs you can count on the idea that less query = less server load.

Too much server load is not always bad for all sites. Say you are on dedicated, have a powerful computer or less site visitors, then you can go crazy with your queries. But for many people who are on shared hosting when you increase your queries, it means you are taking the shared server load from your neighbours which you hosting company wouldnt like if you consume too much power very frequently..

Kathy 10-31-2002 10:11 AM

So this include I'm using....??
I believe we got this from here or vb.com (before org was launched) 2 years ago.

I use this same include twice...with a change in forum ID.

I'm on a dedicated server...with moderate traffic: 5,000 uniques a day, 2 million page views a month. My vb has over 21,000 members and usually we average 100-125 users on the vb at one time (topped out at 165)

I have wanted to add more includes to the index page to change the look of the main page a bit.

Do I need this include re- written for better effeciency? thanks for your thoughts.


All times are GMT. The time now is 09:02 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01115 seconds
  • Memory Usage 1,750KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete