PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Index Join without temporary tables
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Index Join without temporary tables

Réponse
 
LinkBack Outils de la discussion
Vieux 19/09/2007, 14h06   #1
Christoph Krammer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Index Join without temporary tables

Hello everybody,

I have two rather large table with TEXT fields where I need to do a
JOIN. All fields that are used in the JOIN and should be part of the
result are covered in an index, but the JOIN still uses temporary
tables and takes three hours (!) to complete.

This is my schema:

-- Table "spam_archive" DDL

CREATE TABLE `spam_archive` (
`id` int(10) unsigned NOT NULL auto_increment,
`source` varchar(50) default NULL,
`message` longtext NOT NULL,
`md5` varchar(32) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `HASH` (`md5`),
KEY `SOURCE` (`source`)
) ENGINE=MyISAM AUTO_INCREMENT=1960857 DEFAULT CHARSET=latin1;

-- Table "spam_plaintext" DDL

CREATE TABLE `spam_plaintext` (
`id` int(10) unsigned NOT NULL auto_increment,
`msghash` varchar(32) character set latin1 NOT NULL,
`plaintext` mediumtext character set latin1 NOT NULL,
`stockspam` tinyint(1) default NULL,
`images` tinyint(1) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `MSGHASH` USING BTREE (`msghash`,`stockspam`,`images`)
) ENGINE=MyISAM AUTO_INCREMENT=1768865 DEFAULT CHARSET=latin1
COLLATE=latin1_bin ROW_FORMAT=DYNAMIC;


And this is the query I want to run together with the servers
explaination:

mysql> EXPLAIN EXTENDED SELECT a.source, s.stockspam, s.images,
count(*)
-> FROM spam_archive a JOIN spam_plaintext s ON a.md5=s.msghash
-> GROUP BY source, stockspam, images\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: s
type: index
possible_keys: MSGHASH
key: MSGHASH
key_len: 38
ref: NULL
rows: 1699942
Extra: Using index; Using temporary; Using filesort
*************************** 2. row ***************************
id: 1
select_type: SIMPLE
table: a
type: eq_ref
possible_keys: HASH
key: HASH
key_len: 34
ref: spam.s.msghash
rows: 1
Extra:
2 rows in set, 1 warning (0.00 sec)

spam_archive cover 1.7 million rows and 11 gb of data
spam_plaintexts cover the same number of rows with 4 gb of data

Both tables use the MyISAM engine, and the MySQL version is 5.0.37
My system has 2GB of RAM, for MySQL there are 768MB key buffer and
256MB sort buffer

I would appreciate any , why this query takes so long.

Thanks and regards,
Christoph

  Réponse avec citation
Vieux 22/09/2007, 03h09   #2
Charles Polisher
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Index Join without temporary tables

On 2007-09-19, Christoph Krammer <redtiger84@googlemail.com> wrote:
> Hello everybody,
>
> I have two rather large table with TEXT fields where I need to do a
> JOIN. All fields that are used in the JOIN and should be part of the
> result are covered in an index, but the JOIN still uses temporary
> tables and takes three hours (!) to complete.
>
> This is my schema:


<snip>

Try forcing the index use:
http://dev.mysql.com/doc/refman/5.0/en/index-hints.html


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h13.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07424 seconds with 10 queries