MySQL Forums
Forum List  »  MyISAM

Slow Queries Optimization
Posted by: maximiliam daniel
Date: December 01, 2010 02:42PM

I got this queries on one Web Application, in this order on 1 php file.I'm getting a lot of CPU load from MySQL.

SELECT pic,nombre,habilitado,idioma from Users_App WHERE id = 214341;
UPDATE Users_App SET cont=cont+1,contPopular=contPopular+1 WHERE id=214341;
SELECT id from Frases where app_id=214341;
SELECT frase from Frases where id=245 (random Id);


SELECT appid FROM Top_App WHERE idioma like 'es' LIMIT  0,18;
Inside while (18 times)
SELECT User_id,pic,nombre FROM Users_App WHERE NumFrases=1 AND id=214341;

The id, can be any from 1-600k, Here's the
SHOW CREATE TABLE Users_App;
SHOW CREATE TABLE Frases;

CREATE TABLE `Users_App` (
`id` int(10) unsigned NOT NULL auto_increment,
`User_id` varchar(25) NOT NULL,
`nombre` varchar(100) NOT NULL,
`pic` varchar(200) NOT NULL,
`cont` int(10) unsigned NOT NULL default '0',
`contPopular` int(10) unsigned NOT NULL default '0',
`NumFrases` tinyint(2) NOT NULL default '0',
`habilitado` smallint(2) NOT NULL default '0',
`idioma` varchar(2) NOT NULL default 'nn',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=669427 DEFAULT CHARSET=utf8 |


CREATE TABLE `Frases` (
`id` int(10) unsigned NOT NULL auto_increment,
`app_id` int(11) NOT NULL,
`frase` varchar(200) NOT NULL,
PRIMARY KEY (`id`),
KEY `app_id` (`app_id`)
) ENGINE=MyISAM AUTO_INCREMENT=6890373 DEFAULT CHARSET=utf8 |

CREATE TABLE `Top_App` (
`id` int(10) unsigned NOT NULL auto_increment,
`appid` int(11) NOT NULL,
`idioma` varchar(2) NOT NULL,
PRIMARY KEY (`id`),
KEY `appid` (`appid`)
) ENGINE=MyISAM AUTO_INCREMENT=1833 DEFAULT CHARSET=latin1 |

Options: ReplyQuote


Subject
Views
Written By
Posted
Slow Queries Optimization
2821
December 01, 2010 02:42PM
1238
December 02, 2010 11:34PM


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.