You are here: Re: Lots of small queries vs one big query « PHP Programming Language « IT news, forums, messages
Re: Lots of small queries vs one big query

Posted by Peter H. Coffin on 11/22/06 15:18

On 21 Nov 2006 16:09:29 -0800, listerofsmeg01@hotmail.com wrote:
> Hi,
>
> Pretty new to PHP and MySQL.
>
> I have a page on my site that displays a lot of information from
> various tables. Currently I have lots of small PHP wrapper functions
> around SQL queries to get each bit of information. This results in
> maybe 10 queries to display one page, but they are all very small and
> simple, and it keeps the PHP looking nice too as they are simple
> function calls to get each piece of info, which can be called from any
> page in my site.
>
> However, after reading up on SQL a bit, I am wondering whether I should
> be looking at just generating one large query at the start, and using
> joins etc to lump all the relevant info together. This complicates the
> PHP as this means a custom query for each page of my site depending on
> what needs to be displayed, but I am wondering if it is worth it if I
> get a fair performance gain.
>
> Can any gurus point me in the right direction? Is there a "proper" way
> to do this sort of thing?

Premature optimization is the Root of Evil in programming. Do you
foresee having enough load on your little ten queries to cause a
problem? (And bear in mind, that's probably a much bigger load than you
think, and that your actual usage will seldom reach your wildest
expectations.) If the ten-query version works for any reasonably
expectation of usage *AND* is clean and easier to read as a result of
the design, then don't change it.

--
66. My security keypad will actually be a fingerprint scanner. Anyone who
watches someone press a sequence of buttons or dusts the pad for
fingerprints then subsequently tries to enter by repeating that sequence
will trigger the alarm system. --Peter Anspach's Evil Overlord List

 

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

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