感觉自连接条件要是在索引上的话  没什么额外消耗的  消耗是线性的

解决方案 »

  1.   

    没什么差别,和连接五个不同的表性能上差异应该并不大。
      

  2.   


    您不支持一楼的观点吗如果和链接5个不同的表性能上差异不大的话 那就太可怕了恩,我抽时间验证一下您的观点   希望不是这样  
      

  3.   


    您认为消耗是线性的   您否详细描述一下   
      

  4.   


    这个查询我封装到存储过程里了-- 首先涉及三张表
    -- 表1 Paper(paperID,content)-- 表2 Tag(tagID,tagName)-- 表3 TestTag(paperID,tagID) 表1和表2 之间为多对多关系此为关系表  
    -- 下面是存储过程中的部分内容:select concat('select SQL_CALC_FOUND_ROWS a.* from TestTag b 
    join TestTag c on b.paperID=c.paperID and b.tagID<>c.tagID
    join TestTag d on b.paperID=d.paperID and b.tagID<>c.tagID and b.tagID<>d.tagID
    join TestTag e on b.paperID=e.paperID and b.tagID<>c.tagID and b.tagID<>d.tagID and b.tagID<>e.tagID
    join TestTag f on b.paperID=f.paperID and b.tagID<>c.tagID and b.tagID<>d.tagID and b.tagID<>e.tagID and b.tagID<>f.tagID
    join paper a on a.paperID=b.paperID where b.tagID=? and c.tagID=? and d.tagID=? and e.tagID=? and f.tagID=? ',conditions,'  ',orderBy,' ',orderType,' limit ?,?') into @sqlstr;
    PREPARE stmt1 FROM @sqlstr;
    EXECUTE stmt1 USING @t1,@t2,@t3,@t4,@t5,@a,@b;