【发布时间】:2013-05-28 18:20:08
【问题描述】:
我有 3 个表 trader,city_state,city_present。
我在交易者表中有 400 万行,我的查询至少需要 20 秒。 city_present 和城市表中的记录很少。
以下是我的查询。
select t.trader_id, t.name, t.city, t.state from
(
SELECT distinct c.city, c.state
FROM city_present p,city_state c
WHERE p.name = 'TEST_TEST'
AND c.city = p.city
AND c.state = p.state
)
cs, trader t
where
AND t.city = cs.city
AND t.state = cs.state
AND t.name = 'john test'
AND t.is_valid= 1
我有客户索引(城市、州、姓名、valid_customer) 子查询耗时不到一秒.. 外部查询耗时约 20 秒。
谁能帮我减少查询时间。
【问题讨论】:
-
对于初学者来说,显示解释计划会有所帮助。
-
您的查询返回了多少行?
标签: oracle