Eric,

> I have a query which I did several months ago, it recently caught my
> attention since it seems to be very slow when done a lot of times, which 
> causes a very loaded server.

> The query I used looks like this:
> SELECT files.file_id, filename FROM  access, files WHERE 
> directory_id="0" AND lang_id="1" AND ( files.file_id=access.conn_id AND 
> access.group_id IN (1) AND access.class_id="4" AND class_tbl="file" ) 
> group by file_id order by filename;

Just a short note on your query: If you compare integers in a text
context (like lang_id="1"), MySQL cannot use indexes that it could
possibly otherwise use. So rewrite those parts (e.g. lang_id=1).

Another advice would be to try a LEFT JOIN of access and files.

And, of course, you could add some indexes, on the filename and the
file columns.

Regards,
--
  Stefan Hinz <[EMAIL PROTECTED]>
  iConnect GmbH <http://iConnect.de>
  Heesestr. 6, 12169 Berlin (Germany)
  Telefon: +49 30 7970948-0  Fax: +49 30 7970948-3

[filter fodder: sql, mysql, query]


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to