You are here: Re: Is foreach the fastest way to do this? « PHP Programming Language « IT news, forums, messages
Re: Is foreach the fastest way to do this?

Posted by Jerry Stuckle on 08/09/06 00:24

Colin McKinnon wrote:
> Jerry Stuckle wrote:
>
>
>>david wrote:
>>
>>>On 2006-08-06 09:46:02 -0700, s a n j a y <sanjay.debian@gmail.com> said:
>>>
>>>
>>>>david wrote:
>>>>
>>>>
>>>>>I need 5 queries from the database, which I display in a php foreach
>>>>>loop the following way.
>>>>>
>>>>>$query1 = $DB->query("SELECT ... DESC LIMIT 20");
>>>>>$query2 = $DB->query("SELECT ... DESC LIMIT 20");
>>>>>$query3 = $DB->query("SELECT ... DESC LIMIT 30");
>>>>>$query4 = $DB->query("SELECT ... DESC LIMIT 9");
>>>>>$query5 = $DB->query("SELECT ... DESC LIMIT 9");
>>>>>
>>>>
>>>>Why do you want to split hairs? How does 8 ms different than 12 ms in
>>>>practical sense?
>>>
>>>
>>>Well, when you have hundreds of requests coming in within a short period
>>>of time, those ms add up. This is why I am trying to optimize this
>>>function. Any ideas on how to make this the quickest?
>>
>>David,
>>
>>What do you mean by a "short period"? 1 second? 10 seconds?
>>
>>Even 100 page requests in 10 seconds would be over 860K requests/day,
>>which would make your site one of the busiest on the internet. And if
>>that's the case you'll have a lot more things to worry about -
>>bandwidth, for instance.
>>
>
>
> No need to *&(% all over his post - how do you know he's NOT doing that
> volume?
>
> Faster is not the same thing as more scalable though - its kind of tortoise
> and hare thing.
>
> ...but if I had to fix the code I'd be looking to do a single query (UNION?)
> rather than worrying about which loop construct to use.
>
> C.

First of all, I didn't "*&(% all over his post" - I pointed out that
he's probably wasting his time trying to save a very little bit of time.

And if he's doing over 800K page views a day (for this one page), he
would have one of the busiest sites on the internet probably on the
order of 20-50M hits a day minimum. He wouldn't be running PHP on a
single server, and probably would not be using MySQL. Rather he would
be running multiple servers with a heavy-duty database such as SQL
Server, Oracle or DB2.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация