也许这是一个基本问题,但无法回答,希望您的帮助:)
我在 MySQL 中有下表:
create table anotation
(
chromosome enum
(
'Chr1',
'Chr2',
'Chr3',
'Chr4',
'Chr5',
'ChrC',
'ChrM'
),
version varchar(10),
type enum
(
'CDS',
'chromosome',
'exon',
'five_prime_UTR',
'gene',
'mRNA',
'mRNA_TE_gene',
'miRNA',
'ncRNA',
'protein',
'pseudogene',
'pseudogenic_exon',
'pseudogenic_transcript',
'rRNA',
'snRNA',
'snoRNA',
'tRNA',
'three_prime_UTR',
'transposable_element_gene'
),
strand enum
(
'+',
'-'
),
phase tinyint,
atrributes text
);`
它有大约 600,000 个值,我正在执行以下查询:
select distinct
anot_1.chromosome,
anot_1.start,
anot_1.end,
anot_1.atrributes
from
anotation anot_1,
anotation anot_2
where
anot_1.type='CDS'
and
anot_2.type='protein'
and
anot_1.chromosome!='ChrM'
and
anot_1.chromosome!='ChrC'
and
anot_1.chromosome=anot_2.chromosome
and
(
(
anot_2.start=anot_1.start
and
anot_1.end!=anot_2.end
and
anot_2.strand='+'
)
or
(
anot_2.start!=anot_1.start
and
anot_1.end=anot_2.end
and
anot_2.strand='-'
)
);
并且实际上需要很长时间才能完成,但是当我进行查询时(相同的查询,但我从 OR 中删除了其中一个条件),它几乎立即运行:
select distinct
anot_1.chromosome,
anot_1.start,
anot_1.end,
anot_1.atrributes
from
anotation anot_1,
anotation anot_2
where
anot_1.type='CDS'
and
anot_2.type='protein'
and
anot_1.chromosome!='ChrM'
and
anot_1.chromosome!='ChrC'
and
anot_1.chromosome=anot_2.chromosome
and
anot_2.start=anot_1.start
and
anot_1.end!=anot_2.end
and
anot_2.strand='+';`
任何人都知道发生了什么,如果是这样,我该如何解决?谢谢!!!