2017-08-09 77 views
0

where子句和order by子句不同,那麼甲骨文沒有識別索引如何在使用Order by子句時強制執行索引?

INNER JOIN ORG_ACCOUNTING_PERIODS p 
ON p.ORG_ROADMARK = c.ORG_ROADMARK 
AND p.ACCOUNTING_PERIOD = c.SERVICE_PERIOD 
     where (c.ORG_ROADMARK =:roadMark) 
     and c.ORG_ROADMARK = c.move_road 
     ORDER BY EVENT_DATETIME; 
+2

我們就需要知道很多有關你的表,索引,統計等方面提供幫助。 –

回答

0

使用索引和順序時通過,以便通過應分集的where子句,因爲索引直接施加到where子句。

所以添加--->

INNER JOIN ORG_ACCOUNTING_PERIODS p ON p.ORG_ROADMARK = c.ORG_ROADMARK AND p.ACCOUNTING_PERIOD = c.SERVICE_PERIOD 
     where (c.ORG_ROADMARK =:roadMark) 
     and c.ORG_ROADMARK = c.move_road   
     and c.EVENT_DATETIME between :eventFrom AND :eventTo 
     ORDER BY EVENT_DATETIME ; 

create index --> `CREATE INDEX "CARHIRE_EVENTS_IX" ON "CARHIRE_EVENTS" ("EVENT_DATETIME", "MOVE_ROAD", "ORG_ROADMARK") ;`