带有文本fileds的MYSQL索引

时间:2015-07-08 10:30:01

标签: mysql

我尝试为 article(own_a)表构建索引,因为不能使用现有索引。

SELECT包含来自文章表的6个文件,3个整数,1个varchar(30)和2个文本。如果我从查询中删除了2个文本,请成功使用索引。但如何用2大文本提交构建索引?我会收到错误:“指定密钥太长;最大密钥长度为1000字节”。

SELECT
                                own_a.id AS article_id,
                                own_a.article_number,
                                own_d.id AS dealer_id,
                                own_d.name AS dealer,
                                own_a.tecdoc_article_id,
                                own_a.description,
                                own_a.extra_description,
                                'art' AS type,
                                al.genart_id,
                                1 AS own
                        FROM own_db.article AS own_a
                        JOIN own_db.dealer AS own_d ON own_a.dealer_id = own_d.id

                 JOIN `common_db`.`article` AS a ON a.id = own_a.t_article_id
                 JOIN `common_db`.`article_linkage` AS al ON al.article_id = a.id
                        WHERE
                                own_a.id IS NOT NULL
                                AND 1=1
                                AND al.genart_id IN (273,251,2462,3229,1334,1080,854,919,188,1632,1626,1213,12,3845,51,191,1547,653,2070,572,654,188,854)
                                AND ( 1=0 OR a.dealer_id IN (10,101,110,134,140,156,161,192,301,316,317,32,35,55,6,85,89,9,95) )
                                AND al.type_type = 2
                                AND al.type_id = 19799
                        GROUP BY own_a.id
                        ORDER BY  own_a.id 

解释SELECT ...:

    id  select_type table   type    possible_keys                                           key     key_len ref     rows    Extra
    1   SIMPLE      own_a   ALL     PRIMARY,article_number,id,idx_id_an,idx_id_did,idx...   NULL    NULL    NULL    20088   Using where; Using temporary; Using filesort
    1   SIMPLE      al      ref     ArtId                                                   ArtId   17      commondb.own_a.t_article_id,const,con...    2   Using where
    1   SIMPLE      own_d   eq_ref  PRIMARY                                                 PRIMARY 8       own_db.own_a.dealer_id  
    1   SIMPLE      a       eq_ref  PRIMARY,dealer_id,dealer_id_index                       PRIMARY 8       own_db.own_a.t_article_id   1   Using where

USE INDEX(..)不起作用。

寻求帮助

0 个答案:

没有答案