Speeding up MySQL query
- From: EmmettPower@xxxxxxxxx
- Date: 8 Sep 2005 04:03:13 -0700
Hi,
I am reusing the results of a MySQL query on a PHP page. The code works
fine but it is taking about 4 to 5 seconds to load the page so I am
wondering if there is a way to make the code more efficient and the
page load more quickly.
At the top of the page I am running the query with the following code.
$id loads through a session variable:
<?
ini_set('max_execution_time', 86400);
$link = mysql_connect($host, $uid, $pwd);
mysql_select_db('Database');
$query = "SELECT DISTINCT `Table`.`Field` FROM `Table` WHERE
`Table`.`ID` = $id ORDER BY Table`.`Field`";
$result = mysql_query($query) or die (mysql_error());
?>
When I want to access the query data I run the following code.
<?php
$i=0;
mysql_data_seek($result,0);
while ($array= mysql_fetch_array($result)) {
?>
HTML
<?php echo $array[Field] ?>">
HTML
<?php
$i++;
}
?>
This code is repeated about four times on the page.
I'd appreciate any suggestions as to how to speed this up.
Regards
Emmett
.
- Follow-Ups:
- Re: Speeding up MySQL query
- From: Kris Peeters
- Re: Speeding up MySQL query
- From: Erwin Moller
- Re: Speeding up MySQL query
- Prev by Date: REPORT GENERATION
- Next by Date: Re: Speeding up MySQL query
- Previous by thread: REPORT GENERATION
- Next by thread: Re: Speeding up MySQL query
- Index(es):
Relevant Pages
|