MySQL Forums
Forum List  »  Optimizer & Parser

Help to optimize my query
Posted by: björn spiegel
Date: June 04, 2006 09:34AM

hello,
I'm new to this forum, so I say: hello all ;)
I want to optimize my query. I have already rtied to optimize it as far as I was able to.
but now, the rows in the database grow and grow, and I feel the procss slowing down from time to time.

here is my database:
--------------------
DROP TABLE IF EXISTS `link_cats`;
CREATE TABLE `link_cats` (
`id` tinyint(2) unsigned NOT NULL,
`name` varchar(100) NOT NULL default '',
`cflag` tinyint(2) NOT NULL default '1',
PRIMARY KEY (`id`),
KEY `flag` (`cflag`)
) TYPE=MyISAM AUTO_INCREMENT=13 ;

DROP TABLE IF EXISTS `link_entries`;
CREATE TABLE `link_entries` (
`id` smallint(11) unsigned NOT NULL,
`flag` tinyint(2) NOT NULL default '-1',
`eingetragen` int(10) unsigned NOT NULL default '0',
`freigeschaltet` int(10) unsigned NOT NULL default '0',
`cat_id` tinyint(2) unsigned NOT NULL default '0',
`beschreibung` varchar(100) NOT NULL default '',
`link` varchar(255) NOT NULL default '',
`extern` tinyint(2) NOT NULL default '1',
`previewPic` varchar(255) NOT NULL,
`hits` int(11) NOT NULL default '0',
`voteAnzahl` smallint(10) unsigned NOT NULL default '0',
`VoteSumme` mediumint(10) unsigned NOT NULL default '0',
`poster` varchar(100) NOT NULL default '',
`poster_hp` varchar(100) NOT NULL default '',
`ip` varchar(15) NOT NULL default '',
`mail` varchar(100) NOT NULL default '',
PRIMARY KEY (`id`),
KEY `cat_id` (`cat_id`),
KEY `flag` (`flag`),
KEY `link` (`link`),
KEY `freigeschaltet` (`freigeschaltet`)
) TYPE=MyISAM AUTO_INCREMENT=6062 ;

here is the query:
------------------
SELECT e.id, c.name, c.id AS cat_id, e.freigeschaltet, e.beschreibung, e.poster, e.poster_hp, (e.voteSumme / e.voteAnzahl) AS roundedRating, e.extern, e.link
FROM link_entries e
LEFT JOIN link_cats AS c ON e.cat_id = c.id
WHERE flag =1 and c.id = 11
AND freigeschaltet <1149434121
ORDER BY freigeschaltet DESC
LIMIT 0 , 30

so, what can I do? I heard, that a GROUP BY statement slows down the query. the strange thing is: I tried it, and the query was faster, but only on localhost. On my webspace, the execution time of the query was 3 times the one without GROUP BY.

please help me, thanks!!

Options: Reply• Quote


Subject
Views
Written By
Posted
Help to optimize my query
2705
June 04, 2006 09:34AM


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.