我需要知道是否可以将子查询的结果编入索引以便与其他结果进行连接。 我有查询:索引加入查询的结果
Select A.*, B.* from (select * from table1 where condition1 = 1) A join (select * from table2 where condition2 = 0) A on A.c1 = B.c1 and A.c2 = B.c2
我认为我需要指数的子查询的结果,以提高响应速度:
select * from table1 where condition1 = 1 (Id like to index the fields c1, c2)
select * from table2 where condition2 = 0 (Id like to index the fields c1, c2)
这可能吗?我想通过索引子查询来完成。 谢谢
当我执行的连接查询,时间超过40分钟再予。这两个查询的结果有70000条记录。我相信在执行连接之前必须有一种方法来索引这两个结果。在foxpro它只需要少于五分钟,我确定我需要索引它们。 – 2014-10-31 21:09:23
正如我所说的,您可以添加额外的表来存储子查询并在这些表上添加索引。但是为子查询添加索引是没有意义的。 – andy 2014-10-31 21:13:56
安迪感谢您的回复。请不要忘记,如果没有任何意义,可以索引? – 2014-10-31 21:19:07