Friday 03 October 2008 5:43:20 am
I've solved my problem !!
In fact the trouble was the table structure herself ! In my operator, I use a request like :
SELECT count(*) as nb_acces FROM tbl_stats WHERE object_id = My_ID
and the table structure was :
CREATE TABLE `tbl_stats` (
`id` int(11) NOT NULL auto_increment,
`nom_contenu` varchar(127) collate utf8_unicode_ci NOT NULL default '',
`action` varchar(50) collate utf8_unicode_ci NOT NULL default '',
`uri` varchar(255) collate utf8_unicode_ci NOT NULL default '',
`user_id` int(11) NOT NULL default '0',
`date_enregistrement` int(11) NOT NULL default '0',
`object_id` int(11) NOT NULL default '0',
PRIMARY KEY (`id`),
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2958188 ;
I've solved the problem by adding a key on the object_id column like that :
CREATE TABLE `tbl_stats_zi` (
`id` int(11) NOT NULL auto_increment,
`nom_contenu` varchar(127) collate utf8_unicode_ci NOT NULL default '',
`action` varchar(50) collate utf8_unicode_ci NOT NULL default '',
`uri` varchar(255) collate utf8_unicode_ci NOT NULL default '',
`user_id` int(11) NOT NULL default '0',
`date_enregistrement` int(11) NOT NULL default '0',
`object_id` int(11) NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `object_id` (`object_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2958188 ;
.... and I've ordered the table on the object_id column. And now when I run my SELECT I've got the result about 10 time faster than it used to be before the keying and the ordering action ! Many thanks for the time you've spend on this post André.
Regards
Alex.
--------------------------------------------------------------
Personnal website : http://www.alex-design.fr
|