我有3个表交易者,city_state,city_present。Oracle SQL查询性能
我在交易员表中有400万行,我的查询至少需要20秒。 city_present和cities表中几乎没有记录。
以下是我的查询。
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秒左右服用..它是外部查询较少。
有人可以帮助我如何减少查询时间。
对于初学者来说,显示解释计划将有所帮助。 – OldProgrammer
您的查询返回了多少行? –