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
Share on other sites

no... length of the query doesnt cause the speed issue... but the amount of information that that query unloads... if its too long of a loading time you'd either need to a) suck it up and wait... or b) find another way of further sorting your table... :D

Link to comment
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? ;)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.