SELECT * FROM forums ORDER BY forum_order
or
SELECT id, title, desc, forum_order FROM forums ORDER BY forum_order
is there a difference between speeds?
SQL is by far one of my fav languages, theres some stuff I don't know in it but I would like to learn how to use it as efficiently as possible.
any of you guys use it in jobs etc?
It's good practice to select only fields you're going to use, to avoid useless data transfers.
I have sqlphobia.
what if you need to use all cols in the table, like the above query? (only 4 columns in the forums table)
I think the more specific the query the faster it acts. Wildcarding isn't always the quickest. But in this case if all the attributes are; id, title, desc, forum_order then it might be a trivial difference. I think best practice is the latter option. It still depends though because what if you want the query to persist and always select all regardless of attribute additions or changes?
which sql are you using? mysql and postgre will respond differently to optimizations.
mysql is pretty stupid. speak loudly and slowly. for example, often times the order of joins will make a query execute in 0.01 seconds as opposed to 20.01 seconds.
i would guess that dannyp is correct that it's a trivial difference. find out for yourself and look at the execution time.
also, you might want to get a book on mysql optimization (assuming that's what you're using).
why are you using mysql and not postgresql then :P
yeah I heard MySQL was really slow, I'm developing stuff for a website which has a slow shared SQL server. I had a look into SQLite but it dosen't have any management tools I can get used to like phpMyAdmin.
> I heard MySQL was really slow
to be sure, mysql can be faster, depending on the operation and platform.
> why are you using mysql and not postgresql then
:) mysql is more widely used. also, it happens to be what i started with. if i were begin again, i'd take a serious look at postgre.
weird:
$sql = "SELECT conf_name, conf_value FROM config";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
$config[$row['conf_name']] = $row['conf_value'];
}
gives me:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in D:\footforum\inc\common.php on line 32
fixed nm :)