List:General Discussion« Previous MessageNext Message »
From:Sasha Pachev Date:June 24 1999 11:00am
Subject:Re: A problem with a query.
View as plain text  
msan wrote:
> Hallo.
> There is anyone using php3 under a linux system?
> I use php3 as an apache module and MySQL database on a linux (Debian
> 2.1) system.
> In my database I have a table of about 30Mb big.
> I use to connect to my database in this manner:
> $hostname=myhost;
> $database=mydatabase:
> $table=mytable;
> $user=myuser;
> $query="select * from $table where field1=aValue and
> field2=anotherValue";
> $dblink=mysql_pconnect($hostname,$username);
> if(!mysql_select_db($database,$dblink){
>   $error=mysql_error($dblink);
> }
> $result=mysql_query($query,$dblink);
> $row=mysql_fetch_array($result);
> etc.
> It's all right. Query is very fast.
> But if I add "order by" in the query, so it is "select * from $table
> where field1=aValue and field2=anotherValue order by field3,field4",
> the query is very very slow.
> It is not a problem of MySQL because if I execute the same query using
> the MySQL interface it is very fast.
> So why with php3 the query with "order by" is so slow?
> Thanks.

Are you sure you are running the same query? Enable logging in mysqld,
then run the query from the web, go to the log, copy and paste it into
mysql client and see if it runs any faster.

Sasha Pachev (home) (work)
A problem with a query.msan24 Jun
  • Re: A problem with a query.Sasha Pachev24 Jun