Jump to content

[SOLVED] Cleaning up a QUERY


JSHINER

Recommended Posts

$limitvalue = $page * $limit - ($limit);  
    $query  = "SELECT * FROM Feed_3PT_SF, View_Member, View_Office WHERE Feed_3PT_SF.TOWN_NUM = '$id' AND Feed_3PT_SF.LIST_AGENT = View_Member.MLS_ID AND Feed_3PT_SF.LIST_OFFICE = View_Office.MLS_Number ORDER BY LIST_PRICE ASC LIMIT $limitvalue, $limit";         
    $result = mysql_query($query) or die("Error: " . mysql_error());

 

Is there anyway I can clean up this query? It takes way too long for 100 or so results to display on the page.

Link to comment
https://forums.phpfreaks.com/topic/52688-solved-cleaning-up-a-query/
Share on other sites

$limitvalue = $page * $limit - ($limit);  
    $query  = "SELECT * FROM Feed_3PT_SF, View_Member, View_Office WHERE Feed_3PT_SF.TOWN_NUM = '$id' AND Feed_3PT_SF.LIST_AGENT = View_Member.MLS_ID AND Feed_3PT_SF.LIST_OFFICE = View_Office.MLS_Number ORDER BY LIST_PRICE ASC LIMIT $limitvalue, $limit";         
    $result = mysql_query($query) or die("Error: " . mysql_error());

 

Is there anyway I can clean up this query? It takes way too long for 100 or so results to display on the page.

 

Ja

 

See if all those fields in the WHERE statement are indexed.

 

Indexing them will increase performance a lot.

 

You know what are keys and index fields, right? ;)

first go to the table structure page.

 

in the left bottom corner of the page there's an "Indexes" table.

 

Check what's there...

 

Maybe you will find a "no indexes" message there.

 

to define new indexes click on the yellow thunder icons corresponding to the fields you wanna index.

 

That will probably sove your problem... after, look for some tut explaining about primary keys, keys, unique fields and indexes.

First index the id columns and you will notice a greater performance.

 

Indexing speeds up seaching, so do it in the fields used in conditions. in the WHERE and in the JOIN statements.

 

It would be great for you seraching in the google for indexing... as frost recommended.

 

;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.