Hello experts,
I developped sometimes ago an indexer + search engine with mysql.
Now the database weight is 15Go and the query on it became sometimes very long.
For today on 75 request 24 are longer than 2 seconds :
SELECT * FROM vtpLog
where timeResponse
> 2 order by date desc; Time ResultCountvétérinaire 126.35 54482perte d’identité 8.76 948%de femmes vétérinaires 9.04 73pancreatite rat 3.23 23dépilation chinchilla 3.75 1trichophyton 3.2 319tumeur de la prostate 8.63 96pathologies du dindon 2.26 15Hypothyroidie canine 3.62 274gestation de la chienne 18.49 363vermifugation chienne 4.53 26vermifugation chienne gestante 6.33 9hypothyroidie 5.07 1032acupuncture 18.33 11association antibiotiques 26.63 1055pyothorax chat 5.68 45
When mysql takes long time to respond the servers state seems ok :
cpu : 20 - 40 %
mem : 1.7Go used, 2Go Page cache, 300mo free
hdd : reading only
I documented myself, tuned-up mysql, re-check indexes for month but no real progress confused: so I’d like an mysql expert advice to tell me what I’ve done stupid )
I don’t plan (for now) to recode all to use “full text”.
So here are the informations :
Server :
This server is dedicated for this search engine; there are only apache + mysql with maximum memory allocated on mysql.
[B]Quote:[/B] |
CPU : Core(TM)2 E8400 @3.00GHz GenuineIntel MEM : 4 Go DDR2 HDD : 2x 750 Go - SATA2 (RAID 1) |
Script :
[B]Quote:[/B] |
/*================================================= ========= ====*/
create table vtpCategory
(
Id int not null auto_increment,
Parent_Id int,
Value varchar(254),
primary key (Id)
)
type = MyISAM;
/================================================= ========= ====/ /================================================= ========= ====/ /================================================= ========= ====/ /================================================= ========= ====/ /================================================= ========= ====/ /================================================= ========= ====/ alter table vtpCategory add constraint FK_CategoryCategory foreign key (Parent_Id) alter table vtpDomain add constraint FK_DomainCategory foreign key (vtpCategory_Id) alter table vtpHtmlSource add constraint FK_HtmlSourceUri foreign key (Uri_Id) alter table vtpUri add constraint FK_UriDomain foreign key (Domain_Id) alter table vtpUriOutsideDomain add constraint FK_OutsideDomainDomain foreign key (Domain_Id) alter table vtpWordScore add constraint FK_Uri foreign key (Uri_Id) alter table vtpWordScore add constraint FK_Word foreign key (Word_Id) |
Query in two times :
1- get WordIds
[B]Quote:[/B] |
SELECT Id FROM vtpWord WHERE (CAST(vtpWord.Value AS CHAR CHARACTER SET utf8) = ‘vétérinaire’); |
2- sort by scores
[B]Quote:[/B] |
SET SESSION SQL_BIG_SELECTS = 1; SELECT SQL_CALC_FOUND_ROWS vtpUri.Id as UriId, SUM( ws0.Score) * (vtpDomain.Rank + vtpUri.Rank) as uriScore, vtpUri.Domain_Id FROM vtpUri INNER JOIN vtpWordScore AS ws0 ON (ws0.Uri_Id = vtpUri.Id) INNER JOIN vtpDomain ON (vtpDomain.Id = vtpUri.Domain_Id) where ws0.Word_Id = 41 AND vtpDomain.vtpCategory_Id != 2 AND vtpDomain.IsOff != 1 GROUP BY ws0.Uri_Id ORDER BY uriScore desc LIMIT 0,400 |
Mysql States :
[B]Quote:[/B] |
MySQL work since 35 Days 5 hours 16 minutes 15 seconds. Slow_queries 4 304 Handler_read_rnd 1 670 k Handler_read_rnd_next 19 G Created_tmp_disk_tables 1 765 Opened_tables 157 Table_locks_waited 829 k |
my.cnf :
I hope you can show me the light