MySQL Forums
Forum List  »  Optimizer & Parser

Optimizing a query
Posted by: Ryan Smith
Date: November 28, 2006 10:37AM

Hello MySQL forum.

I'm pretty good when it comes to simple database functionality, but I don't even know where to begin with optimizing queries that run slow.

I have a table that looks like:
+------------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+----------+------+-----+---------+----------------+
| counter_id | int(11) | | PRI | NULL | auto_increment |
| referer | text | YES | | NULL | |
| ip | text | YES | | NULL | |
| agent | text | YES | | NULL | |
| time | datetime | YES | | NULL | |
| page | text | YES | | NULL | |
+------------+----------+------+-----+---------+----------------+

The query that I need to run against it looks like:

select count(distinct(page)) as hits, page FROM counter GROUP BY page ORDER BY hits

This is running extremely slow with about 60000+ records. What is the best way to start optimizing this?

Thanks.

Options: ReplyQuote


Subject
Views
Written By
Posted
Optimizing a query
2906
November 28, 2006 10:37AM
1931
November 28, 2006 06:28PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.