Home » Performance » MySQL » Preventing filesort in a simple (but big) query?
Preventing filesort in a simple (but big) query? [message #1366] Tue, 05 June 2007 16:45
Raegis  is currently offline Raegis
Messages: 1
Registered: June 2007
Junior Member
I think I'm missing something. Any help would be appreciated.

I've got a large database (2+M records) with about 40 fields. It's doing very enhanced log analysis. One of the fields is the title of an article, defined as a VARCHAR(255). The field is indexed. The engine is InnoDB. I have a logID field as the primary key.

When I a very simple query, the process takes forever:

SELECT articleTitle, count(*) from logdata group by articleTitle order by count(*) desc

Explain says it's using filesort, which I know is bad, but I'm not sure how to prevent that. Here's the explain:

*************************** 1. row ************************
id: 1
select_type: SIMPLE
table: logdata
type: index
possible_keys: NULL
key: articleTitle_index
key_len: 258
ref: NULL
rows: 1955105
Extra: Using index; Using temporary; Using filesort

Sadly, I don't have an articleID that's shorter because this is derived data. And I have a bunch of other related queries, like a list of the most popular authors, that also takes forever (we're talking an hour or more).

So, what can I do to make this (and all the searches like it) fast enough to be useful?

Thanks in advance!

[Updated on: Tue, 05 June 2007 16:45]

Previous Topic:Perl Mysql
Next Topic:should a count with an index take this long?
Goto Forum:
  


Current Time: Sat Jul 4 18:36:36 EDT 2009

Total time taken to generate the page: 0.03068 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.