2013-08-08 13 views
5

sto usando questa tabella (MySQL/Motore: MyISAM):Perché GROUP BY sul FULLTEXT INDEX utilizzando temporanea?

CREATE TABLE `activities` (
    `id_activity` int(10) unsigned NOT NULL AUTO_INCREMENT, 
    `id_doc` int(10) unsigned NOT NULL DEFAULT '0', 
    `node_id` tinytext NOT NULL, 
    `title` tinytext NOT NULL, 
    `name` tinytext NOT NULL, 
    `keywords` tinytext NOT NULL, 
    `page_type` tinytext NOT NULL, 
    `page_screen_id` tinytext NOT NULL, 
    `page_screen_question` tinytext NOT NULL, 
    PRIMARY KEY (`id_activity`), 
    KEY `name` (`name`(255)), 
    FULLTEXT KEY `node_id` (`node_id`,`title`,`name`,`keywords`,`page_type`,`page_screen_id`,`page_screen_question`) 
) ENGINE=MyISAM DEFAULT CHARSET=latin1; 

(ci sono circa 100.000 righe)

Ecco la mia domanda:

EXPLAIN SELECT 1 
FROM `activities` 
GROUP BY `node_id`, `title`, `name`, `keywords`, `page_type`, `page_screen_id`, `page_screen_question`; 
  • ID: 1
  • select_type: SIMPLE
  • tabella: attività
  • Tipo: TUTTI
  • possible_keys: NULL
  • chiave: NULL
  • key_len: NULL
  • ref: NULL
  • righe: 613.011
  • Extra: Utilizzo temporaneo; Uso filesort

Non capisco perché il mio query utilizza temporanea ... e non so come evitare questo ... Grazie

+0

[ 'In alcuni casi, MySQL è in grado di fare molto di meglio e per evitare la creazione di tabelle temporanee utilizzando Index access.'] (http://dev.mysql.com/doc/refman/5.1/en /group-by-optimization.html) –

+0

@DavidStarkey ho letto questo argomento, ma v'è in realtà un indice sul mio 'GROUP clausola BY' –

+0

c'è una ragione temporanea è un problema? –

risposta

1

dovrebbe piuttosto essere un commento, ma è più leggibile questo modo:

Si prega di eseguire questa query

SELECT CONCAT(table_schema, '.', table_name) AS tablename, 
    CONCAT(ROUND(table_rows/1000000, 2), 'M')         rows, 
    CONCAT(ROUND(data_length/(1024 * 1024 * 1024), 2), 'G')     data, 
    CONCAT(ROUND(index_length/(1024 * 1024 * 1024), 2), 'G')     idx, 
    CONCAT(ROUND((data_length + index_length)/(1024 * 1024 * 1024), 2), 'G') total_size, 
    ROUND(index_length/data_length, 2)           idxfrac 
FROM information_schema.TABLES 
WHERE TABLE_SCHEMA = database() 
AND TABLE_NAME = 'your_table_name' 

e verificare se la tabella o l'indice si inserisce in realtà in memoria. Se non ... hai la risposta.

+0

Grazie mille, è molto consigli ! Ho provato e avere questo risultato: nometabella: elw_e-doceo.activities - \t righe: 0.61M - \t dati: 0.06g - IDX: 0.06g - TOTAL_SIZE: 0.11G - \t idxfrac: 0,99 ... Hai detto: "verificare se il tavolo o l'indice actuallyfits nella memoria". Stai parlando della mia memoria del computer o di un parametro del mio 'my.ini'? –

+0

Dai un'occhiata al tuo file di configurazione. Potrebbe essere che 'key_buffer_size' non sia della giusta dimensione. Si prega di dare un'occhiata a questo inserimento manuale: http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_key_buffer_size – fancyPants

+0

Grazie! Ho provato 'key_buffer_size = 1024M' e ... (cattive notizie) "Utilizzo temporaneo; Usando FileSort". Davvero non capisco :(... –