Ronan Lucio wrote:
Hello,

Trying to keep the database and the application fast,
IŽd like to clearify my mind about it.

Ronan:

I assume you mean "has serious performance impact" when you say "weight". If this is not what you meant, please correct/clarify.


1) Is a SELECT DISTINCT over 5,000 records a weight query? (Supposing it has about 20 different option the the DISTINCT key).

This query will most likely result in a creation of a temporary table with 20 columns and a key over all of them that will have no more than 5000 records, and will take 5000 attempted inserts to populate. Assuming that your WHERE clause is ok, this query should take no more than 3 seconds or so on modern hardware. However, this could be bad if you are doing this frequently and there is other activity going on. On the other hand, the query cache could save you. If it does not, consider creating and maintaining a summary table.



2) Is SELECT ORDER BY RAND() over 1,500 records a weight query?

Does the table have only 1,500 records, and is it going to stay that way? Are you selecting only a few reasonably sized columns? If yes, unless you are Yahoo or Google, you'll do fine on modern hardware - this query under those curcumstances should take the order of maginitude of 0.01 s. However, if you have more records in the table, and the WHERE clause is not optimized, things could get bad, and this time the query cache does not save you.



-- Sasha Pachev Create online surveys at http://www.surveyz.com/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to