Hello,
I’m working a database that will contain a bunch of releases (movie-titles if you will) and each release (movie) will get a few tags depending on what type of movie it is, eg. english, pal, ntsc etc…
When i list these it takes about 2s (100 rows) and as EXPLAIN has explained, it uses filesort and im guessing thats why its slow.
I’ve tried to use indexes as far as i know but i haven’t really understood how to use them just yet i guess.
Anyway, here is the structure:
CREATE TABLE releases
( r_id
int(11) NOT NULL auto_increment, rel_name
text NOT NULL, rel_title
text NOT NULL, rel_date
int(11) NOT NULL default ‘0’, add_date
int(11) NOT NULL default ‘0’, imdb
text NOT NULL, group_id
int(11) NOT NULL default ‘0’, section_id
int(11) NOT NULL default ‘0’, add_nickhost
text NOT NULL, PRIMARY KEY (r_id
), KEY section_id
(section_id
), KEY group_id
(group_id
), KEY rel_date
(rel_date
)) ENGINE=MyISAM DEFAULT CHARSET=latin1;CREATE TABLE sections
( s_id
tinyint(4) NOT NULL auto_increment, section
text NOT NULL, PRIMARY KEY (s_id
), KEY section
(section
(8))) ENGINE=MyISAM DEFAULT CHARSET=latin1;CREATE TABLE sections
( s_id
tinyint(4) NOT NULL auto_increment, section
text NOT NULL, PRIMARY KEY (s_id
), KEY section
(section
(8))) ENGINE=MyISAM DEFAULT CHARSET=latin1;CREATE TABLE groups
( g_id
int(11) NOT NULL auto_increment, group_name
text NOT NULL, PRIMARY KEY (g_id
)) ENGINE=MyISAM DEFAULT CHARSET=latin1;
releases has about 80000 rows at this point and tags about 10000.
query i use is:
SELECT r_id, rel_date, rel_name, rel_title, group_name , imdb, section, GROUP_CONCAT( DISTINCT tag SEPARATOR ’ ’ ) as tags FROM tags INNER JOIN releases ON releases.r_id = tags.rel_id INNER JOIN groups ON releases.group_id = groups.g_id INNER JOIN sections ON releases.section_id = sections.s_id WHERE section = ‘dvdr’ GROUP BY rel_id ORDER BY rel_date DESC LIMIT 0,100
I’m pretty much stuck here and i hope you can at least point me in the right direction.
Thanks.
Best Regards, Patrik.