Unix Technical Forum

how to optimize the dbase

This is a discussion on how to optimize the dbase within the MySQL forums, part of the Database Server Software category; --> Hi on my website home page there's an heavy and repetitive number of query that slow down the speed ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 11:25 AM
Mark
 
Posts: n/a
Default how to optimize the dbase

Hi
on my website home page there's an heavy and repetitive number of query
that slow down the speed of the page opening.
Could you suggest me some link or 'how to' to optimize the queries or to
improve the page loading time?

Regards.

Mark - Italy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 11:25 AM
Peter H. Coffin
 
Posts: n/a
Default Re: how to optimize the dbase

On Thu, 09 Aug 2007 19:56:00 +0200, Mark wrote:
> Hi
> on my website home page there's an heavy and repetitive number of query
> that slow down the speed of the page opening.
> Could you suggest me some link or 'how to' to optimize the queries or to
> improve the page loading time?


More RAM, better indexing, prebuilding "dynamic" pages that are actually
semi-static. That's roughly in order of simplicity, though the last is
actually fiendishly powerful done right.

--
6. I will not gloat over my enemies' predicament before killing them.
--Peter Anspach's list of things to do as an Evil Overlord
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 11:25 AM
Mark
 
Posts: n/a
Default Re: how to optimize the dbase

> Peter H. Coffin ha scritto:
>> On Thu, 09 Aug 2007 19:56:00 +0200, Mark wrote:
>>> Hi
>>> on my website home page there's an heavy and repetitive number of query
>>> that slow down the speed of the page opening.
>>> Could you suggest me some link or 'how to' to optimize the queries or to
>>> improve the page loading time?

>>
>> More RAM, better indexing, prebuilding "dynamic" pages that are actually
>> semi-static. That's roughly in order of simplicity, though the last is
>> actually fiendishly powerful done right.
>>

>


For example whith these queries:

$qtot="SELECT COUNT(id) FROM news WHERE argomento='alfa' AND mostra='si'";
$qtotb=mysql_query($qtot) or die('errore'.mysql_error());
$indc=mysql_fetch_array($qtotb);
mysql_free_result($qtotb);

$qtot="SELECT COUNT(id) FROM news WHERE argomento='beta' AND mostra='si'";
$qtotb=mysql_query($qtot) or die('errore');
$indd=mysql_fetch_array($qtotb);
mysql_free_result($qtotb);

$qtot="SELECT COUNT(id) FROM news WHERE argomento='gamma' AND mostra='si'";
$qtotb=mysql_query($qtot) or die('errore');
$inde=mysql_fetch_array($qtotb);
mysql_free_result($qtotb);

$qtot="SELECT COUNT(id) FROM news WHERE argomento='delta' AND mostra='si'";
$qtotb=mysql_query($qtot) or die('errore');
$indf=mysql_fetch_array($qtotb);
mysql_free_result($qtotb);

$qtot="SELECT COUNT(id) FROM news WHERE argomento='eta' AND mostra='si'";
$qtotb=mysql_query($qtot) or die('errore');
$indg=mysql_fetch_array($qtotb);
mysql_free_result($qtotb);

$qtot="SELECT COUNT(id) FROM news WHERE argomento='teta' AND mostra='si'";
$qtotb=mysql_query($qtot) or die('errore');
$indh=mysql_fetch_array($qtotb);
mysql_free_result($qtotb);

is there a way to optimize or unite them in a single faster query?
I'm a beginner with MySQL so please have patience.

Regards

Mark
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 11:25 AM
Luuk
 
Posts: n/a
Default Re: how to optimize the dbase


"Mark" <mccartney@emiggeas.it> schreef in bericht
news:46bb611e$0$37205$4fafbaef@reader3.news.tin.it ...
>> Peter H. Coffin ha scritto:
>>> On Thu, 09 Aug 2007 19:56:00 +0200, Mark wrote:
>>>> Hi
>>>> on my website home page there's an heavy and repetitive number of query
>>>> that slow down the speed of the page opening.
>>>> Could you suggest me some link or 'how to' to optimize the queries or
>>>> to improve the page loading time?
>>>
>>> More RAM, better indexing, prebuilding "dynamic" pages that are actually
>>> semi-static. That's roughly in order of simplicity, though the last is
>>> actually fiendishly powerful done right.
>>>

>>

>
> For example whith these queries:
>
> $qtot="SELECT COUNT(id) FROM news WHERE argomento='alfa' AND mostra='si'";
> $qtotb=mysql_query($qtot) or die('errore'.mysql_error());
> $indc=mysql_fetch_array($qtotb);
> mysql_free_result($qtotb);
>
> $qtot="SELECT COUNT(id) FROM news WHERE argomento='beta' AND mostra='si'";
> $qtotb=mysql_query($qtot) or die('errore');
> $indd=mysql_fetch_array($qtotb);
> mysql_free_result($qtotb);
>
> $qtot="SELECT COUNT(id) FROM news WHERE argomento='gamma' AND
> mostra='si'";
> $qtotb=mysql_query($qtot) or die('errore');
> $inde=mysql_fetch_array($qtotb);
> mysql_free_result($qtotb);
>
> $qtot="SELECT COUNT(id) FROM news WHERE argomento='delta' AND
> mostra='si'";
> $qtotb=mysql_query($qtot) or die('errore');
> $indf=mysql_fetch_array($qtotb);
> mysql_free_result($qtotb);
>
> $qtot="SELECT COUNT(id) FROM news WHERE argomento='eta' AND mostra='si'";
> $qtotb=mysql_query($qtot) or die('errore');
> $indg=mysql_fetch_array($qtotb);
> mysql_free_result($qtotb);
>
> $qtot="SELECT COUNT(id) FROM news WHERE argomento='teta' AND mostra='si'";
> $qtotb=mysql_query($qtot) or die('errore');
> $indh=mysql_fetch_array($qtotb);
> mysql_free_result($qtotb);
>
> is there a way to optimize or unite them in a single faster query?
> I'm a beginner with MySQL so please have patience.
>
> Regards
>
> Mark


you could add an INDEX on 'argomento' and/or on 'mostra'.....




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


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


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com