you are not signed in | sign in or register
Anton Titov's blog
Programming / server administration / databases
Feed & Web Facts
10
Feed Item Count
29 May 12 01:26
Last Reading
2.0
RSS/XML Version
(en)
Feed Language
UTF-8
Feed Encoding
Page-Views
 
Weekly People
Week
titov.net
Anton Titov's blog
Newest Posts in Feed
Date and time addition and substraction
Real life example: SELECT username FROM users WHERE (ADDDATE( last_in_chat, INTERVAL 2 MINUTE) > NOW()) ORDER BY username LIMIT 30 NEVER do that. The user in question runs this query on table with 3000+ rows, which means, that SQL server (MySQL in this case) is doing 3000+ date/time additions and will never use any index. If you [...]
Front page extensions without mod_frontpage
If you have apache server on linux and want to be able to activate front page extensions for virtual hosts but do not want to install mod_frontpage, than you can download this file http://www.titov.net/downloads/frontpage.tar.gz extract it to /usr/local withtar -xzf frontpage.tar.gz -C /usr/local and than you can install front page extensions like (on a single line): /usr/local/frontpage/install /...
“Do not use ORDER BY RAND()” or “How to get random rows from table?”
Quite often people use queries like: SELECT quote FROM quotes ORDER BY RAND() LIMIT 1 to get a random row (rows) from a table. That’s quite bad idea. For big tables, if your table have just 50-100 rows, use whatever you want. What happens when you run such a query? Let’s say you run this query on a [...]