Monthly Archives: July 2009

MySQL Slow Query Optimization Tips

Slow Query Example SELECT widget_id , widget_name , COUNT(DISTINCT type) AS num_types FROM widget GROUP BY type ORDER BY num_types DESC With lots (>100K) of rows, this query will get slow because it orders on an aggregate COUNT DISTINCT function. … Continue reading

Leave a comment

How to Convert Seconds to Minutes in BASH

This is how to convert seconds into HH:MM:SS in bash: $ date -d ’1970-01-01 100 sec’ +’%H:%M:%S’ 00:01:40

Leave a comment

How to fix: error while loading shared libraries: liblwres.so.50

To fix this error: # nslookup mydomain.com nslookup: error while loading shared libraries: liblwres.so.50: cannot open shared object file: No such file or directory Do this: # ldconfig # dig mydomain.com ; DiG 9.6.1-RedHat-9.6.1-2.fc11 mydomain.com … From the ldconfig manpage: … Continue reading

Posted in Linux, Troubleshooting | Leave a comment

How to Optimize MySQL Queries Using Indexes

When optimizing a query, the order of fields matter in a multi-field index. In general, you should use the most selective fields first. For example, in a hypothetical location index, use zip, city, state, rather than the reverse. Source: MySQL … Continue reading

Leave a comment