-1

I am a SQL guy, but am doing a stint in ORACLE land. Nothing wrong w/ expanding one's boundaries....

I have been given a view to a table. I do have permission to delete from that view.

Delete from vwGregsViewOnTable where SEQ = 12345 

this takes 12 minutes. There are ~20M rows in the table, but 12 minutes? I got a DBA involved and they confirmed that I am doing a table scan.

We scripted the table and that follows here in part...

CREATE TABLE SYT_SYALERTQUEUE
(
  IDRECMAIN          VARCHAR2(32 BYTE),
  IDRECPARENT        VARCHAR2(32 BYTE),
  IDREC              VARCHAR2(32 BYTE),
  SEQ                NUMBER(10),
.
.
.


CREATE INDEX SYNDX00000000000000000002277 ON SYT_SYALERTQUEUE
(SEQ)
LOGGING
TABLESPACE WV90NDX

It does appear that there is an index on the column I was told I should use.

in this case, vwGregsViewOnTable is the view on SYT_SYALERTQUEUE

My question is - how can I coax ORACLE into using the index. It doesnt seem to want to by default.

4

1 回答 1

2

回答您的问题:您可以强制 Oracle 的 SQL 优化器使用某个索引:

SELECT /*+ INDEX (table indexname)*/ col1, col2
  FROM table
  WHERE blabla ;

这个东西在这里/*+ INDEX (table indexname)*/被称为优化器提示。大多数时候使用它并不明智。

于 2013-08-21T20:29:01.697 回答