Re: Speeding up MySQL query



EmmettPower@xxxxxxxxx wrote:

> 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


Just guessing: are the fields Table.Field and Table.ID indexed in MySQL ??


--
Kris.
.



Relevant Pages

  • Speeding up MySQL query
    ... I am reusing the results of a MySQL query on a PHP page. ... page load more quickly. ... At the top of the page I am running the query with the following code. ... HTML ...
    (php.general)
  • Re: PSP
    ... % Suciu and Pusztai ... Furthermore, if a query fails, it does not ... look like it allows the programmer to directly mix the Prolog and HTML. ...
    (comp.lang.prolog)
  • [NEWS] IBM Informix Web DataBlade Vulnerability Allows SQL Injection
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... When a user makes a page request, webdriver executes a query that will ... This query is vulnerable to SQL injection ... returns some processed HTML. ...
    (Securiteam)
  • Re: To load or not to load
    ... First, write a query like ... >it should be 1 and therefore load. ... what you are looking for, chr, is not in this string... ... shouldn't the DCount solution work - you are right, ...
    (microsoft.public.access.formscoding)
  • IBM Informix Web DataBlade: SQL injection
    ... SQL code is executed under the uid that webdriver connects as. ... This query is vulnerable to SQL ... processed HTML. ...
    (Bugtraq)