From: Dathan Pattishall Date: January 18 2005 11:34pm Subject: RE: Doubt about Performance List-Archive: http://lists.mysql.com/mysql/178687 Message-Id: <62D6B7C12242244DA66D9A4428688D922E0863@fiexchange.friendster.local> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable =20 > -----Original Message----- > From: Ronan Lucio [mailto:ronanl@stripped]=20 > Sent: Tuesday, January 18, 2005 10:13 AM > To: mysql@stripped > Subject: Doubt about Performance >=20 > Hello, >=20 > Trying to keep the database and the application fast, I=B4d=20 > like to clearify my mind about it. >=20 > 1) Is a SELECT DISTINCT over 5,000 records a weight > query? (Supposing it has about 20 different option the the > DISTINCT key). This is not bad, it's a mysql function that uses a KEY if a key exist. >=20 > 2) Is SELECT ORDER BY RAND() over 1,500 records > a weight query? >=20 > I need to put these two queries in the first page of our site. > So, I=B4ve been worried if it can slow down our site in the pics. DO SELECT ORDER BY RAND() LIMIT <<< 1500=20 Such that <<< means much less then 1500 on the order of 10. This is a rather expensive operation and should be used with care. I've gotten around this by generating a random number in my app and = trying to match it to a known id by making multiple selects. This was = less intensive then ORDER BY RAND. -- DVP >=20 > Thanks, > Ronan >=20 >=20 >=20 > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: =20 > http://lists.mysql.com/mysql?unsub=3Ddathan@stripped >=20 >=20