Jump to content

Mysql SELECT speeds


algarve4me

Recommended Posts

I normally use the Mysql query wildcard for searching my table. After recent modifications to my table, I am now concerned about the search speed and tying up the available memory.

Is there a general concensus on which method is the quickest to return the results from a table, assuming that the table has around 200 columns?

Does it make a difference depending upon the number of columns that are searched?

SELECT * FROM table WHERE a=b and c=d and e=f.

Would I be better off using

SELECT column1, column2, column3 FROM table WHERE a=b and c=d and e=f

Link to comment
Share on other sites

SELECT * is slower because it transfers data from all 200 columns back to your client. If you're not using all 200, you shouldn't transfer all 200.

If you ARE going to use all 200, SELECT * is fine.

Of course, make sure your WHERE conditions use indexes. That's the biggest issue.
Link to comment
Share on other sites

Hi Wickning, thank you for your prompt reply.

If I use the query below, should I create an index on a4m?
If the column a4m is a primary, do I still need to create an index?
Should the columns be listed in the order that they appear in the table?

[code]
$result = mysql_query("select propertyname, propertytype, country, region, propertylocation from table where a4m='$a4m' ");

while($r=mysql_fetch_array($result)){
    $formpropertyname=$r["propertyname"];
    $formpropertytype=$r["propertytype"];
    $formcountry=$r["country"];
    $formregion=$r["region"];
    $formpropertylocation=$r["propertylocation"];
}
[/code]
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.