优势数据库LEFT JOIN非常慢

时间:2015-04-22 16:02:38

标签: sql join advantage-database-server

抱歉,我的英文

我有以下查询连接两个表

选择t1.cod1,t2.xcod为xcod1,        t1.cod2,t2.xcod为xcod2,        t1.cod3,t2.xcod为xcod3

FROM TABLE1 t1
     LE1 JOIN TABLE2 t2 on t1.cod1 = t2.cod      LE1 JOIN TABLE2 t3 on t1.cod2 = t3.cod      LE1 JOIN TABLE2 t4 on t1.cod3 = t4.cod

查询正确返回连接表,但查询运行速度非常慢

实际上我的表有超过200,000条记录

我认为通过子查询或左连接(选择..)...

正确

任何想法都谢谢..

                   TABLE1                            TABLE2
      +---------+-------- +---------+             +-----+-----+
      |  cod1   |   cod2  |   cod3  |             | cod | xcod|
      +---------+------ --+---------+             +-----+-----+
      |    A    |         |    F    |             |  A  |  1  |
      |    D    |    B    |         |             |  B  |  2  |
      |    C    |         |         |             |  C  |  3  |
      |    F    |    A    |    D    |             |  D  |  4  | 
      +---------+---------+---------+             +-----+-----+



      RESULT:

      +---------+-------- +---------+---------+---------+---------+
      |  cod1   |  xcod1  |   cod2  |  xcod2  |  cod3   |  xcod3  |
      +---------+---------+---------+---------+---------+---------+
      |    A    |    1    |         |         |    F    |         |
      |    D    |    4    |    B    |    2    |         |         |
      |    C    |    3    |         |         |         |         |
      |    F    |         |    A    |    1    |    D    |    4    |
      +---------+---------+---------+---------+---------+---------+             

0 个答案:

没有答案