brett's blog

Group By, Order By, and Limit

So I had a question while optimizing some Mysql queries. What is the right order for the 3 commands I needed in this query: GROUP BY, ORDER BY, and LIMIT?

MySQL query optimization - indexing

Well, in school we talked so much about tuning, I even took a class that devoted part of it to MySQL tuning, but I had yet to see a need for it until today. We have a site that wanted an area to each video page that pulled in content like Amazon.com. We titled the area "People who viewed this also viewed" and we were pulling in content that was seen by other users and highly rated. So, here's the sql I came up with:

SELECT path, COUNT(path) as count FROM accesslog WHERE uid IN (SELECT uid FROM accesslog WHERE path='*****' AND uid !=0) GROUP BY path ORDER BY count

Add a visitor's IP address to the theme layer

I had a client ask me to put the visitor's IP address onto the page, and here's the process I went through to do it:

DrupalCon Boston 2008

I am in Boston this week at a Drupal conference. I am attending tons of sessions and learning all sorts of awesome stuff, and blogging about it (sometimes just dumping my notes) at http://drupalcon.brettevanson.com

Please go comment if you are there or have questions.