SELECT cms_plaintext.tid AS tid1, cms_text.tid AS tid2 FROM cms_plaintext, cms_text WHERE ( cms_plaintext.hid='tytul' AND cms_plaintext.text LIKE '%".addslashes($szukaj)."%') OR ( cms_text.hid='wstep' AND cms_text.text LIKE '%".addslashes($szukaj)."%') AND cms_plaintext.tid != ".$_GET['id']." AND cms_text.tid != ".$_GET['id']." ORDER BY cms_plaintext.id DESC LIMIT 10
struktury tabel
Kod
CREATE TABLE `cms_plaintext` (
`id` int(11) unsigned NOT NULL auto_increment,
`pid` int(10) unsigned NOT NULL default '0',
`tid` int(11) unsigned NOT NULL default '0',
`text` text NOT NULL,
PRIMARY KEY (`id`),
KEY `id` (`id`),
KEY `tid` (`tid`)
) ENGINE=MyISAM
`id` int(11) unsigned NOT NULL auto_increment,
`pid` int(10) unsigned NOT NULL default '0',
`tid` int(11) unsigned NOT NULL default '0',
`text` text NOT NULL,
PRIMARY KEY (`id`),
KEY `id` (`id`),
KEY `tid` (`tid`)
) ENGINE=MyISAM
Kod
CREATE TABLE `cms_text` (
`id` int(11) unsigned NOT NULL auto_increment,
`pid` int(10) unsigned NOT NULL default '0',
`tid` int(11) unsigned NOT NULL default '0',
`text` text NOT NULL,
PRIMARY KEY (`id`),
KEY `id` (`id`),
KEY `tid` (`tid`)
) ENGINE=MyISAM
`id` int(11) unsigned NOT NULL auto_increment,
`pid` int(10) unsigned NOT NULL default '0',
`tid` int(11) unsigned NOT NULL default '0',
`text` text NOT NULL,
PRIMARY KEY (`id`),
KEY `id` (`id`),
KEY `tid` (`tid`)
) ENGINE=MyISAM
plus pare innych kolumn nie mającuch tu znaczenia.
Obie tabele zawierająpo kilka tysięcy rekordów
Zapytanie to wykonywało się się średnio przez 170sekund!!!
NIe bardzo wiem, jak możnaby je zoptymalizować, macie jakieś pomysły?