<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1013541" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1013541</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/optimize-php-snippet#comment-1078689</link>
    <description> &lt;p&gt;ShinNathan,&lt;/p&gt;
&lt;p&gt;Anytime you make reference to an external object (ADO, COM, etc) the page is going to be slower then if their was no reference to it. Having said that, making connections to a SQL db using ADO is very efficient. Here&#039;s some tips to keep your pages fast:&lt;/p&gt;
&lt;p&gt;1. Only make one connection per page, if you need to make more than one call to the database on the page re-use your existing connection.&lt;/p&gt;
&lt;p&gt;2. Close your connections/recordsets as soon as possible and set them to nothing.&lt;/p&gt;
&lt;p&gt;3. Don&#039;t pull more data than you need (don&#039;t use SELECT *)&lt;/p&gt;
&lt;p&gt;4. Use stored procedures if possible, they&#039;re faster than SQL inside the ASP.&lt;/p&gt;
&lt;p&gt;Have fun with ASP &amp;amp; SQL!&lt;/p&gt;
 </description>
     <pubDate>Tue, 27 Feb 2001 13:53:55 +0000</pubDate>
 <dc:creator>Peter J. Boettcher</dc:creator>
 <guid isPermaLink="false">comment 1078689 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/optimize-php-snippet#comment-1078687</link>
    <description> &lt;p&gt;While we are on the subject...&lt;/p&gt;
&lt;p&gt;I am working on my first asp site now.  It&#039;s a massive task to take first up, but it is going quite well.&lt;/p&gt;
&lt;p&gt;To the point, how much of a performence hit do you think a database call makes (SQL) ?  In this site;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://ww.domaindlx.com/shinnathan/index.asp&quot; class=&quot;bb-url&quot;&gt;http://ww.domaindlx.com/shinnathan/index.asp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;... I must make several hundred calls to the database.  As the database gets bigger, that number will easily go into the thousands.  The site does not seem to load slowly...&lt;/p&gt;
 </description>
     <pubDate>Tue, 27 Feb 2001 12:31:59 +0000</pubDate>
 <dc:creator>ShinNathan</dc:creator>
 <guid isPermaLink="false">comment 1078687 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/optimize-php-snippet#comment-1078541</link>
    <description> &lt;p&gt;It&#039;s all inside one code block, perfect!&lt;/p&gt;
 </description>
     <pubDate>Fri, 23 Feb 2001 14:27:18 +0000</pubDate>
 <dc:creator>Peter J. Boettcher</dc:creator>
 <guid isPermaLink="false">comment 1078541 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/optimize-php-snippet#comment-1078510</link>
    <description> &lt;p&gt;Would this revision be better?&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;## Example 1 (revision) ##&lt;br /&gt;&amp;lt;select name=hour&amp;gt;&lt;br /&gt;&amp;lt;?&lt;br /&gt;for ($i=1; $i &amp;lt; date(&amp;quot;G&amp;quot;,time()); $i++) {&lt;br /&gt;&amp;nbsp; echo &amp;quot;&amp;lt;option value=&amp;#039;$i&amp;#039;&amp;gt;$i&amp;lt;/option&amp;gt;&amp;quot;;&lt;br /&gt;}&lt;br /&gt;&amp;nbsp; echo &amp;quot;&amp;lt;option value=&amp;#039;$i&amp;#039; SELECTED&amp;gt;$i&amp;lt;/option&amp;gt;&amp;quot;;&lt;br /&gt;for ($i=date(&amp;quot;G&amp;quot;,time())+1; $i &amp;lt; 24; $i++) {&lt;br /&gt;&amp;nbsp; echo &amp;quot;&amp;lt;option value=&amp;#039;$i&amp;#039;&amp;gt;$i&amp;lt;/option&amp;gt;&amp;quot;;&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&amp;nbsp; &lt;br /&gt;&amp;lt;/select&amp;gt;&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
 </description>
     <pubDate>Thu, 22 Feb 2001 22:30:08 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1078510 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/optimize-php-snippet#comment-1078492</link>
    <description> &lt;p&gt;I don&#039;t have a lot of experience with PHP but I do with ASP, and I know for a fact that everytime you invoke server-side processing (&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt; &lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt; for asp &amp;amp; &amp;lt;? ?&amp;gt; for PHP) the server takes a performance hit. While it&#039;s hard it&#039;s always better to try and write code inside one server-side block of code rather than multiple blocks.&lt;/p&gt;
&lt;p&gt;Even though the other examples look efficient (and they are) they still make at least 2 call&#039;s to server-side processing per line compared to 1 call in example 3.&lt;/p&gt;
&lt;p&gt;As for which has more load, a FOR LOOP or IF statement, if they were both inside one block of code then I would probably say the IF statement requires more CPU since it requires logic, the FOR LOOP is basically a counter. A loop is definately more efficient when it&#039;s setup to exit when it reaches or finds a certain value. The whole IF statement has to be processed even if it found the right value, that&#039;s why I try to stick with SELECT CASE when possible.&lt;/p&gt;
 </description>
     <pubDate>Thu, 22 Feb 2001 13:54:31 +0000</pubDate>
 <dc:creator>Peter J. Boettcher</dc:creator>
 <guid isPermaLink="false">comment 1078492 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/optimize-php-snippet#comment-1078480</link>
    <description> &lt;p&gt;wouldn&#039;t you think that example 1 would be the best?&lt;br /&gt;
if only has to do 2 FOR loops, but example has to do 23 IF statements?&lt;/p&gt;
&lt;p&gt;I&#039;m curious... which is more of a load? a FOR loop that repeats 23 times? or 23 IF statements?&lt;/p&gt;
&lt;p&gt;maybe I&#039;ll time it... but with a thousand or so...&lt;br /&gt;
...maybe I&#039;ll write it in PHP and Perl and compare the two... hmmm...&lt;/p&gt;
 </description>
     <pubDate>Thu, 22 Feb 2001 07:21:09 +0000</pubDate>
 <dc:creator>Mark Hensler</dc:creator>
 <guid isPermaLink="false">comment 1078480 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/optimize-php-snippet#comment-1078468</link>
    <description> &lt;p&gt;I HATE getting the database value of a select field. It always involves too much work. I wish we could just do  and that would bring up the correct option. Would save me lots of time...&lt;/p&gt;
 </description>
     <pubDate>Thu, 22 Feb 2001 00:44:44 +0000</pubDate>
 <dc:creator>Gil</dc:creator>
 <guid isPermaLink="false">comment 1078468 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/optimize-php-snippet#comment-1078462</link>
    <description> &lt;p&gt;The code is to small for there to be any measurable difference between the 3. Maybe if there were 2300 items in the select field instead of 23 you would notice a difference.&lt;/p&gt;
&lt;p&gt;I would probably pick number 3 to be the fastest since there is only 1 call per item to server-side processing, although this is not the easiest from a coding standpoint since someone has to hardcode all those 2300 items &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/sad.png&quot; title=&quot;Sad&quot; alt=&quot;Sad&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The quickest and easiest way would be to keep the whole select box server-side until it&#039;s populated then send it to the client.&lt;/p&gt;
 </description>
     <pubDate>Wed, 21 Feb 2001 20:20:52 +0000</pubDate>
 <dc:creator>Peter J. Boettcher</dc:creator>
 <guid isPermaLink="false">comment 1078462 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
