Using the index function in where clause of Exchange.
Hello friends,I need your help with a problem.
I have a query that uses two table Say T1 and T2, where C1 is common column with which both are joined.
C1 is the primary key in T1, but no index available in Q2 for the C1. T1C2 is the column that we want to select.
(Note that table may be a Master table)
Now let's see the query:
Select T1C2
From T1, T2
where T2. C1 = T1. C1
Here where the clause may have other conditions and From clause can have other tables as needed.
I want to know that if I have change the query as continuation of leave my query to use the index available of T1. C1.
Select T1C2
from T1, T2
where T1. C1 = T2.C1
Then, the query uses the index available of T1. and I get better performance. Even a small improvement of performance help me much because this type of query is used in a loop where clause (so it will be run several times).
Please advise on this...
Kind regards
Lifexisxnotxsoxbeautiful...
Hello
18:43:17 rel15_real_p>create table t1(c1 number primary key, c2 number);
Table created.
18:43:26 rel15_real_p>create table t2(c1 number, c2 number);
18:45:08 rel15_real_p>
18:45:09 rel15_real_p>begin
18:45:09 2 for i in 1..100
18:45:09 3 loop
18:45:09 4 insert into t1(c1,c2) values (i,i+100);
18:45:09 5 end loop;
18:45:09 6 commit;
18:45:09 7 end;
18:45:09 8 /
PL/SQL procedure successfully completed.
18:45:09 rel15_real_p>
18:45:09 rel15_real_p>
18:45:09 rel15_real_p>begin
18:45:09 2 for i in 1..100
18:45:09 3 loop
18:45:09 4 insert into t2(c1,c2) values (i,i+200);
18:45:09 5 end loop;
18:45:09 6 commit;
18:45:09 7 end;
18:45:09 8 /
18:45:23 rel15_real_p>select count(*) from t1;
COUNT(*)
----------
100
18:45:30 rel15_real_p>select count(*) from t2;
COUNT(*)
----------
100
18:45:49 rel15_real_p>select index_name,index_type from user_indexes where table
_name='T1';
INDEX_NAME INDEX_TYPE
------------------------------ ---------------------------
SYS_C0013059 NORMAL
18:48:21 rel15_real_p>set autotrace on
18:52:25 rel15_real_p>Select T1.C2
18:52:29 2 From T1, T2
18:52:29 3 where T2.C1 = T1.C1
18:52:29 4 /
C2
----------
101
102
103
104
105
.....
......
C2
----------
200
100 rows selected.
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=7 Card=100 Bytes=
900)
1 0 HASH JOIN (Cost=7 Card=100 Bytes=3900)
2 1 TABLE ACCESS (FULL) OF 'T1' (TABLE) (Cost=3 Card=100 By
es=2600)
3 1 TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 By
es=1300)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
21 consistent gets
0 physical reads
0 redo size
1393 bytes sent via SQL*Net to client
562 bytes received via SQL*Net from client
8 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
100 rows processed
18:52:31 rel15_real_p>analyze table t1 compute statistics;
Table analyzed.
18:55:35 rel15_real_p>analyze table t2 compute statistics;
18:55:38 rel15_real_p>set autotrace on
18:55:42 rel15_real_p>Select T1.C2
18:55:43 2 From T1, T2
18:55:45 3 where T2.C1 = T1.C1
18:55:46 4 /
C2
----------
101
102
103
104
105
.....
......
C2
----------
200
100 rows selected.
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=100 Bytes=7
00)
1 0 MERGE JOIN (Cost=6 Card=100 Bytes=700)
2 1 TABLE ACCESS (BY INDEX ROWID) OF 'T1' (TABLE) (Cost=2 Ca
rd=100 Bytes=500)
3 2 INDEX (FULL SCAN) OF 'SYS_C0013059' (INDEX (UNIQUE)) (
Cost=1 Card=100)
4 1 SORT (JOIN) (Cost=4 Card=100 Bytes=200)
5 4 TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 B
ytes=200)
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
23 consistent gets
0 physical reads
0 redo size
1393 bytes sent via SQL*Net to client
562 bytes received via SQL*Net from client
8 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
100 rows processed
18:56:56 rel15_real_p>Select T1.C2
18:56:56 2 From T1, T2
18:56:56 3 where T1.C1 = T2.C1
18:56:58 4 /
C2
----------
101
102
103
104
105
.....
......
C2
----------
200
100 rows selected.
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=100 Bytes=7
00)
1 0 MERGE JOIN (Cost=6 Card=100 Bytes=700)
2 1 TABLE ACCESS (BY INDEX ROWID) OF 'T1' (TABLE) (Cost=2 Ca
rd=100 Bytes=500)
3 2 INDEX (FULL SCAN) OF 'SYS_C0013059' (INDEX (UNIQUE)) (
Cost=1 Card=100)
4 1 SORT (JOIN) (Cost=4 Card=100 Bytes=200)
5 4 TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 B
ytes=200)
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
23 consistent gets
0 physical reads
0 redo size
1393 bytes sent via SQL*Net to client
562 bytes received via SQL*Net from client
8 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
100 rows processed
-Pavan Kumar N
Tags: Database
Similar Questions
-
How to use the instruction box in where clause
Hi all
I need to use cases where clause guide me please how I can do it.
AND WHEN BOX: KAPCO = "KAPCO" THEN cla. CLASS_NAME LIKE '% KAPCO % '.
WHEN: KAPCO = "NON_KAPCO" THEN SUPERIOR (cla. CLASS_NAME) NOT LIKE '% KAPCO % '.
WHEN: KAPCO = 'ALL' GOLD: KAPCO IS NULL SO SUPERIOR (cla. CLASS_NAME) LIKE '% '.
END
Concerning
Published by: user10941925 on March 4, 2012 22:31Hello
CASE expressions return a single value, for example a VARCHAR2. They do refer to code fragments.
You usually don't need (or want) an expression BOX in a WHERE clause, or any other condition. I think that you were trying to do the equivalent of:
AND ( (:KAPCO = 'KAPCO' AND cla.CLASS_NAME LIKE '%KAPCO%') -- Don't you want UPPER on this line? OR (:KAPCO = 'NON_KAPCO' AND UPPER(cla.CLASS_NAME) NOT LIKE '%KAPCO%') OR (NVL (:KAPCO, 'ALL') = 'ALL' AND cla.CLASS_NAME IS NOT NULL) )
If you would care to post some sample data (CREATE TABLE and INSERT statements) and the results desired from this data, I was able to test this.
-
Using the Case statement in Where clause with operator
Hi all
I'm doing the following work (this is just a simple version of what I'll eventually need):
Sorry, I forgot how to use the code tags...
and li. MAJOR_ACCT in case
When: prompt = 'Energy' then ('9320906 ', ' 9321471')
end
Problem is that I get a missing closing parenthesis error.
Wouldn't - that evaluate against a value(as below) it works fine:
and li. MAJOR_ACCT in case
When: prompt = 'Energy' then ('9320906')
end
Any thoughts? Is it possible to use a box (or decode) in an In clause with multiple values? I tried to use decode as well and get the same results.
Thank you.
Darren.What:
and ( case when :prompt = 'Energy' and li.MAJOR_ACCT in ('9320906', '9321471') then 1 when :prompt = 'Vehicle' and li.MAJOR_ACCT in ('9812180', '9812320') then 1 when :prompt = 'Meals' and li.MAJOR_ACCT in ('983120', '983452') then 1 end ) = 1
-
Setting the query: optimizer does not use the index function
Hello
I have a request written by a developer that I can't change.
It is here that the condition:
OÙ ( UPPER(TRIM (CODFSC)) = UPPER (TRIM ( '01923980500'))
OR UPPER(TRIM (CODUIC)) = UPPER (TRIM ( '01923980500')))
There is an index on CODFSC and on CODUIC1.
the plan is:
Plan
INSTRUCTION SELECT ALL_ROWS cost: 9 194 bytes: 3 206 502 cardinality: 15 054
ACCESS FULL ANAGRAFICA cost TABLE TABLE 1: 9 194 bytes: 3 206 502 cardinality: 15 054
So I created two new index on SUPERIOR (TRIM ()CODFSC)) and SUPERIOR (TRIM ()CODUIC)) but the plan
complete analysis of STIL.
Modifing where condition in:
OÙ ( CODFSC = UPPER (TRIM ( '01923980500'))
OR CODUIC = UPPER (TRIM ( '01923980500')))
the plan is:
SELECT STATEMENT ALL_ROWSCost: 157 bytes: 426 cardinality: 2
CONCATENATION OF 5
TABLE ACCESS BY INDEX ROWID ANAGRAFICA cost TABLE 2: cardinality of 5 bytes: 213: 1
1 INDEX RANGE SCAN INDEX ANAGRAFICA_IDX01 cost: cardinality 3: 1
TABLE ACCESS BY INDEX ROWID ANAGRAFICA cost TABLE 4: cardinality 152 bytes: 213: 1
3 INDEX SKIP SCAN INDEX ANAGRAFICA_IDX02 cost: cardinality 1: 151
Why optimizer not use my funct index?
Thank you.
Franck,
I always forget that the default value for the GOLD expansion depends on a path indexed for each branch.
2 in your use of or_predicates (2) depends on the position of complex predicate which must be expanded. If you change the order of predicate 'State = 0' to display AFTER the complex predicate, you must change the indicator of "or_predicates (1).
Outside of the current state of undocumented indicator, it also introduces the disturbing thought that, for a more complex query, a change in the transformation may result in another set of query blocks generated with a different ranking of the predicates. Yet another case to ensure that if you suggest anything suggest you (or create a SQL database).
Concerning
Jonathan Lewis
-
The INSTR function in where clause
Hello
I need to check if part of the separate past comma is there in one of the values of table column, if its present, then I need to go looking for this file in the same table.
Example of
--------
Table1:
col1 col2
-----------
01 john
Raj 02
and I'm passing '02,04,06' as the value of parameter input and according to this value, I need to check in a table and get a record.
procedure p1 (v_string varchar2)
is
Select col1, col2
in a, b
FROM table1
where instr (v_string, - here I need to apply the logic
end;
output
------
Raj 02
Please help me with this logic
RDS,
Nagainstr(','||v_string||',',','||col1||',') > 0
Nicolas.
-
If the INSTR function will not use the INDEX o?
Hi all
I have a querry as
Is simple index on column Col1. If we use the index will be used or full table scan will happen in this scenario?Select * from Tab1 Where Instr(Tab1.Col1,'XX') >0 ;
Please give me explanatory answer because I have doubts
DhabasHello
You must use the index function if you want to avoid the full table scan. Check this box
SQL> create table tab1(col1 varchar(20)) 2 / Table created. SQL> insert into tab1 values ('XXAB') 2 / 1 row created. SQL> create index col1_idx on tab1(col1); Index created. SQL> explain plan for Select * from Tab1 Where Instr(Tab1.Col1,'XX') >0; Explained. SQL> set autotrace on SQL> Select * from Tab1 Where Instr(Tab1.Col1,'XX') >0; XXAB Execution Plan ---------------------------------------------------------- 0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=5 Card=1 Bytes=12) 1 0 TABLE ACCESS (FULL) OF 'TAB1' (TABLE) (Cost=5 Card=1 Bytes =12) Statistics ---------------------------------------------------------- 4 recursive calls 0 db block gets 32 consistent gets 0 physical reads 0 redo size 234 bytes sent via SQL*Net to client 280 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed SQL> create index col1_idx2 on tab1(Instr(Col1,'XX')); Index created. SQL> Select * from Tab1 Where Instr(Tab1.Col1,'XX') >0; XXAB Execution Plan ---------------------------------------------------------- 0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=2 Card=1 Bytes=12) 1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TAB1' (TABLE) (Cost=2 Ca rd=1 Bytes=12) 2 1 INDEX (RANGE SCAN) OF 'COL1_IDX2' (INDEX) (Cost=1 Card=1 ) Statistics ---------------------------------------------------------- 28 recursive calls 0 db block gets 22 consistent gets 0 physical reads 0 redo size 234 bytes sent via SQL*Net to client 280 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed SQL>
Thank you
AJ -
Using the comparison function where 2 data tables various types
Is it possible to use the comparison function in Labview you to compare 2 arrays of types of different data (e.g. Boolean and double-precision)?
Would this work? Nested for loops of index on the TRUE values of the Boolean table.
-
Problem in the export using the QUERY functionality
Problem in the export using the QUERY functionality
I'm trying to export some rows in a table using the query functionality
and I have some errors... I'm using the syntax is
system@orcl QUERY = scott.emp expdp: '"WHERE emp_no = 123455" '
DIRECTORY = data_pump_dir DUMPFILE = data_pump.dmp
LOGFILE = data_pump_12345.log INDEX = n
Can someone tell me please the problem with that statement
I also tried to use the simple export
exp file system@orcl = orcl_export.dmp log = orcl_export.log
tables = Scott.EMP index = QUERY = n------"WHERE emp_no\ = 123455\"
and this error
EXP-00008: ORACLE error 904
ORA-00904: identify invalid
My os is Solaris
Please let me know what the problemHello
Try to create parfile and use that, otherwise, you will need to escape each clause correctly to run exp or expdp successfully.
test.par
tables=emp query="WHERE emp_no=123455" or tables=myobjects query="WHERE owner='SYS'" $> exp username/password parfile=test.par Export: Release 10.2.0.1.0 - Production on Thu Mar 19 10:17:48 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining Scoring Engine options Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set About to export specified tables via Conventional Path ... . . exporting table MYOBJECTS 22650 rows exported Export terminated successfully without warnings.
Concerning
Published by: OrionNet on March 19, 2009 10:21
-
SDO_NN cannot be assessed without using the index when put inside subquery
Hi all
I met a problem when you use the function sdo_nn to find the nearest neighbor. Here is my scenario:
_ I have 2 customer and store tables.
Customer table _ a client_ID and a 2D sdo_geom point
_ Store table has store_ID and a 2D polygon sdo_geom.
In the beginning, I have this query to find the nearest store to each customer as below:
Select s.STORE_ID, c.CLIENT_ID
store customer, s c
where sdo_nn (s.MYPOLYGON, c.MYPOINT, 'sdo_num_res = 1', 1) = "TRUE";
_It works as expected when it returns a table showing the nearest store each customer.
_Now I want to count the number of customers who have the same nearest store:
Select / * + INDEX (store store_spatial_idx, client_spatial_idx client) * / count (nearest_store. CLIENT_ID)
from (select s.STORE_ID, c.CLIENT_ID
store customer, s c
where sdo_nn (s.MYPOLYGON, c.MYPOINT, 'sdo_num_res = 1', 1) = "TRUE") nearest_store
Group of nearest_store. STORE_ID;
This query generates the following error:
Error report-
SQL error: ORA-13249: SDO_NN cannot be assessed without using the index
ORA-06512: at the 'MDSYS. MD", line 1723
ORA-06512: at the 'MDSYS. MDERR", line 17
ORA-06512: at the 'MDSYS. PRVT_IDX', line 9
13249 00000 - '%s '.
I'm pretty new to spatial databases and hope get help to go further. Thank you in advance!
Hello Pinball,
Oracle space tends to be a quite complex with many variables and moving parts. We chatted about the group to a sort of FAQ or guidelines to help people like you submit questions that actually answers. First of all, you really have to tell us the version of Oracle you are using. Particularly the problems involving the optimizer, version down to the exact defined patch number is a good idea. Secondly, you took the time to submit the question so I guess you want a response. If you really want to see the answer and then providing an example is one of the most important things that you can do. I'm going to do here for you, but in general people on this forum come and go and are often pushed into lurkitude, so if you want the coax to provide you with an example of work is the key.
DROP TABLE store1 PURGE; CREATE TABLE store1( store_id INTEGER NOT NULL ,shape MDSYS.SDO_GEOMETRY ,PRIMARY KEY(store_id) ); DROP TABLE client2 PURGE; CREATE TABLE client2( client_id INTEGER NOT NULL ,shape MDSYS.SDO_GEOMETRY ,PRIMARY KEY(client_id) ); CREATE OR REPLACE PROCEDURE seeder( p_client_count IN NUMBER ,p_store_count IN NUMBER ) AS sdo_foo MDSYS.SDO_GEOMETRY; int_counter NUMBER; FUNCTION random_point RETURN MDSYS.SDO_GEOMETRY AS num_x1 NUMBER; num_y1 NUMBER; BEGIN num_x1 := dbms_random.value(-179,179); num_y1 := dbms_random.value(-89,89); RETURN MDSYS.SDO_GEOMETRY( 2001 ,8265 ,MDSYS.SDO_POINT_TYPE( num_x1 ,num_y1 ,NULL ) ,NULL ,NULL ); END random_point; BEGIN int_counter := 1; FOR i IN 1 .. p_client_count LOOP -- Create a client point sdo_foo := random_point(); INSERT INTO client2 VALUES ( int_counter ,sdo_foo ); int_counter := int_counter + 1; END LOOP; int_counter := 1; FOR i IN 1 .. p_store_count LOOP -- Create a store polygon of some kind sdo_foo := MDSYS.SDO_GEOM.SDO_ARC_DENSIFY( MDSYS.SDO_GEOM.SDO_BUFFER( random_point() ,5000 ,0.05 ) ,0.05 ,'arc_tolerance=0.05' ); INSERT INTO store1 VALUES ( int_counter ,sdo_foo ); int_counter := int_counter + 1; END LOOP; COMMIT; END seeder; / BEGIN seeder(10000,200); END; / BEGIN INSERT INTO user_sdo_geom_metadata( table_name ,column_name ,diminfo ,srid ) VALUES ( 'STORE1' ,'SHAPE' ,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,.05),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,.05)) ,8265 ); COMMIT; EXCEPTION WHEN OTHERS THEN NULL; END; / BEGIN INSERT INTO user_sdo_geom_metadata( table_name ,column_name ,diminfo ,srid ) VALUES ( 'CLIENT2' ,'SHAPE' ,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,.05),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,.05)) ,8265 ); COMMIT; EXCEPTION WHEN OTHERS THEN NULL; END; / CREATE INDEX store1_spx ON store1 (shape) INDEXTYPE IS MDSYS.SPATIAL_INDEX NOPARALLEL; CREATE INDEX client2_spx ON client2 (shape) INDEXTYPE IS MDSYS.SPATIAL_INDEX NOPARALLEL; /* Works as expected */ SELECT s.store_id ,c.client_id ,MDSYS.SDO_NN_DISTANCE(1) FROM store1 s ,client2 c WHERE MDSYS.SDO_NN( s.shape ,c.shape ,'sdo_num_res=1' ,1 ) = 'TRUE'; /* No worky? Works for me */ SELECT ns.store_id ,COUNT(ns.client_id) FROM ( SELECT s.store_id ,c.client_id FROM store1 s ,client2 c WHERE MDSYS.SDO_NN( s.shape ,c.shape ,'sdo_num_res=1' ,1 ) = 'TRUE' ) ns GROUP BY ns.store_id ORDER BY ns.store_id;
So I wrote this about 12 c (12.1.0.2.0) and everything works fine for me. Then I moved back from 11 GR 2 (11.2.0.4.0) and of course, there are questions. So I guess that you don't use flavor of 11g. So at this point we can look at the docs and see for 11g, have you often need to specify which table is the head and that is the one that has the spatial index to use.
http://docs.Oracle.com/CD/E11882_01/AppDev.112/e11830/sdo_operat.htm#SPATL1032Its rather interesting that the optimizer of 12 c knows what you want, when I had to squint myself at your request and to play a little with the refining. Note that SDO_NN is sensitive, because the geometry of the main table should come second in the operator. I did not know that on the top of my head.
SELECT /*+ LEADING(c) INDEX(s store1_spx) */ s.store_id ,c.client_id ,MDSYS.SDO_NN_DISTANCE(1) FROM store1 s ,client2 c WHERE MDSYS.SDO_NN( s.shape ,c.shape ,'sdo_num_res=1' ,1 ) = 'TRUE'; SELECT ns.store_id ,COUNT(ns.client_id) FROM ( SELECT /*+ LEADING(c) INDEX(s store1_spx) */ s.store_id ,c.client_id ,MDSYS.SDO_NN_DISTANCE(1) FROM store1 s ,client2 c WHERE MDSYS.SDO_NN( s.shape ,c.shape ,'sdo_num_res=1' ,1 ) = 'TRUE' ) ns GROUP BY ns.store_id ORDER BY ns.store_id;
So I think that is your answer. Give it a shot and see if this fits the Bill. Of course, moving to 12 c would be useful for such things. It would be interesting to collect more examples of this kind of space thing where 12 c is the answer. Also, would be nice if we could mark somehow this discussion as applying only to 11g and earlier versions.
See you soon,.
Paul
-
I have problem with a query as follows. It does not index when I keep a function on the left side of the comparison in which the condition.
But when I remove the function is using the index.
With BLC AS Name Null? Type ----------------------------------------- -------- ---------------------------- ID NOT NULL NUMBER MASTER_VALUE NOT NULL NUMBER(8) DESC_TEXT_ID NUMBER GVM VARCHAR2(50) MASTER_LOOKUP_ID NOT NULL NUMBER WORK_SECTION_ID NUMBER AUDIT_TRAIL_NO NUMBER SQL> SELECT COUNT(*) FROM BLC; COUNT(*) ---------- 7769 SQL> SELECT COUNT(DISTINCT(GVM)) "distinct" FROM BLC; distinct ---------- 1350 SQL> SELECT COUNT(*) "nulls" FROM BLC WHERE GVM IS NULL; nulls ---------- 6419 SQL> SELECT COLUMN_NAME,INDEX_NAME FROM DBA_IND_COLUMNS WHERE TABLE_NAME='BLC'; COLUMN_NAME INDEX_NAME ---------------------------------------- ------------------------------ MASTER_LOOKUP_ID LKPCDE_MSTLKP_FK_I WORK_SECTION_ID LKPCDE_WRKSEC_FK_I GVM LKPCDE_UK MASTER_VALUE LKPCDE_MASTERID_VALUE_UK MASTER_LOOKUP_ID LKPCDE_MASTERID_VALUE_UK ID LKPCDE_PK SQL> EXPLAIN PLAN FOR SELECT ID FROM BLC WHERE UPPER ( GVM) = 'MAIN_ORG'; Explained. SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY); PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Plan hash value: 3196655606 -------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time| -------------------------------------------------------------------------------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 78 | 624 | 18 (0)| 00:00:01 | |* 1 | TABLE ACCESS FULL| BLC | 78 | 624 | 18 (0)| 00:00:01 | -------------------------------------------------------------------------------------- Predicate Information (identified by operation id): PLAN_TABLE_OUTPUT ----------------------------------------------------------------------------------------------------------------------------------- 1 - filter(UPPER("GVM")='MAIN_ORG') 13 rows selected. SQL> EXPLAIN PLAN FOR SELECT ID FROM BLC WHERE GVM = 'MAIN_ORG'; Explained. SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY); PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Plan hash value: 1620245961 -------------------------------------------------------------------------------- ---------------- | Id | Operation | Name | Rows | Bytes | Cost (% CPU)| Time | -------------------------------------------------------------------------------- ---------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 8 | 2 (0)| 00:00:01 | | 1 | TABLE ACCESS BY INDEX ROWID| BLC | 1 | 8 | 2 (0)| 00:00:01 | |* 2 | INDEX UNIQUE SCAN | LKPCDE_UK | 1 | | 1 (0)| 00:00:01 | -------------------------------------------------------------------------------- ---------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("GVM"='MAIN_ORG') 14 rows selected. SQL> EXPLAIN PLAN FOR SELECT /* INDEX(LKPCDE_UK) */ ID FROM BLC WHE RE UPPER ( GVM ) = 'MAIN_ORG'; Explained. SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY); PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Plan hash value: 3196655606 -------------------------------------------------------------------------------- ------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------- ------ PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 78 | 624 | 18 (0)| 00:0 0:01 | |* 1 | TABLE ACCESS FULL| BLC | 78 | 624 | 18 (0)| 00:0 0:01 | -------------------------------------------------------------------------------- ------ Predicate Information (identified by operation id): PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- --------------------------------------------------- 1 - filter(UPPER("GVM")='MAIN_ORG') 13 rows selected.
Please let me know how I can force it to use an index as it is causing the CPU usage.
I can't change the query in the application it is used in several places.
Thank you
And/or read: ORACLE-BASE - Oracle function index
-
How to use the NVL function to a parameter with comma delimited values
Gurus,
It is confusing to me. I am trying to use the NVL function, but the setting that I'm passing in my cursor contains multiple values with commas. The NVL function is confused when analyzing the values.
'Where' cursor clause...
and nvl (sn.c_attribute1,'x@#$%') in nvl (p_desig,'x@#$%'( )
translated parameter values...
and nvl (sn.c_attribute1,'x@#$%') in nvl ('SPRT''GOOD' 'BAD' 'x@#$%') -NVL does not parse the value correctly
Any idea on how to get NVL recognize 'x@#$%' , if p_desig is null?
Thank you
Scott
HI, Scott.
Whenever you have a problem, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables involved, so that people who want to help you can recreate the problem and test their ideas.
Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: https://forums.oracle.com/message/9362002#9362002
My best guess, based on what you posted bone is present, that your problem is discussed in the following:
-
SDO_NN giving ORA-13249: SDO_NN cannot be assessed without using the index
Hi people,
I do not understand why the SDO_NN gives ORA-13249 in circumstances.
SQL > SELECT SlavaTest WHERE SDO_NN s s.title (s.geometry, SDO_GEOMETRY (2001, 4326, SDO_POINT (14.0, 49.0, NULL), null, null)) = 'TRUE' and title like '%' and rownum < 10;
TITLE
--------------------------------------------------------------------------------
MultiPoint_305199
LineString_691779
MultiPolygon_180478
MultiPolygon_358113
MultiPolygon_53008
MultiPolygon_249905
MultiPolygon_204076
MultiPolygon_636994
MultiPoint_464514
9 selected lines.
SQL > SELECT SlavaTest WHERE SDO_NN s s.title (s.geometry, SDO_GEOMETRY (2001, 4326, SDO_POINT (14.0, 49.0, NULL), null, null)) = 'TRUE' and timestamp > = to_timestamp (January 6, 2011 ', ' dd/mm/yyyy') and rownum < 10;
SELECT SlavaTest WHERE SDO_NN s s.title (s.geometry, SDO_GEOMETRY (2001, 4326, SDO_POINT (14.0, 49.0, NULL), null, null)) = 'TRUE' and timestamp > = to_timestamp (January 6, 2011 ', ' dd/mm/yyyy') and rownum < 10
*
ERROR on line 1:
ORA-13249: SDO_NN cannot be assessed without using the index
ORA-06512: at the 'MDSYS. MD", line 1723
ORA-06512: at the 'MDSYS. MDERR", line 17
ORA-06512: at the 'MDSYS. PRVT_IDX', line 49
The spatial index is created with:
CREATE the INDEX SlavaTest_geometry_idx_spatial ON SlavaTest (geometry) INDEXTYPE IS mdsys.spatial_index;
'Title' and 'timestamp' columns have an index.
Note the query comes from Hibernate and I can't change it's arbitrary.Slava2 wrote:
What this means - there is a bug in Oracle?Well, it could probably be considered a, but [url http://docs.oracle.com/cd/E11882_01/appdev.112/e11830/sdo_operat.htm#i78067] documentation on SDO_NN warns you:
Documentation says:
However, if the column in the WHERE clause predicate specifies a non-space column in the table for geometry1 with an associated index, make sure that this index is not used by specifying the NO_INDEX indicator for this index.See you soon,.
Stefan -
SELECT on a table in the INSERT statement uses the INDEX
Hello world
I have a strange problem with EA Oracle 10 g (64-bit) running on a Linux system. The situation is, I developed a Java program to migrate one client system to another. One of the steps in the migration fills a new table with the data from the old system. Given that the data on the old system structure is fundamentally different from that new, I have to check each time I read a line from the old system, if I have already created an entity on the new table, and if so, update certain attributes. The WHERE clause of this audit uses a key of the company indexed on the new table. The problem is now, that Oracle does not use the index on the key attribute of the company, but it makes table scans complete to select the line. As you can imagine, the lines first thousand or so go fast, but the amount increases, the program becomes slower and slower.
If I do a "scan" when executing the migration program, Oracle change the execution plan and use the index on the attribute key and everything works fast and smooth. However, if I do the analysis on the empty table first, nothing changes (which I understand it perfectly, since there is nothing to analyze, at this point). By integrating a hint of 'INDEX' (table) in the statement SELECT does not change the full implementation plan (also table scans).
Is it possible to change this behavior, in order to SELECT it uses the index of key business from the beginning?
Greetings from Cologne,
Thorsten.
Published by: thkitz on 13.03.2012 18:27thkitz wrote:
SELECT STATEMENT ALL_ROWSCost: 2 Bytes: 76 Cardinality: 2 7 TABLE ACCESS BY INDEX ROWID TABLE AIDATINT.PRVVSSCHADENKORRESPONDENZ Cost: 2 Bytes: 76 Cardinality: 2 6 BITMAP CONVERSION TO ROWIDS 5 BITMAP OR 2 BITMAP CONVERSION FROM ROWIDS 1 INDEX RANGE SCAN INDEX AIDATINT.I_PRVVSSCHADENKORRESPONDENZ_1 Cost: 1 4 BITMAP CONVERSION FROM ROWIDS 3 INDEX RANGE SCAN INDEX AIDATINT.I_PRVVSSCHADENKORRESPONDENZ_2 Cost: 1
I would have thought that as a plan as possible. It is not a concatenation, is a btree/bitmap conversion.
Allude to this plan you need / * + index_combine (table_alias index1 index2) * /.
For 10g and later the index can be specified by name or by descriptionI'm a bit puzzled why the plan changes after truncate - but maybe my comment about not cleared statistics is no longer true. It is easy enough to check if I'm right or wrong on your version of Oracle.
Concerning
Jonathan Lewis
http://jonathanlewis.WordPress.com
Author: core Oracle -
How to copy an image that is in format .pdf using the paint function paste in Word?
I would like to copy a table that is in a non-protected PDF document using the paint function in accessories to paste it in a Word document that I'm working on. Please help as soon as POSSIBLE.
Hello, Edward Namalima,.
1. first open the pdf page you want to copy.
2. when the page is displayed on your screen, press prtscrn on your keyboard.
3. a copy of the screen has now sent in the windows clipboard.
4. now open Paint.
5. on the Paint toolbar, click on edit and then click on paste. The image will now be pasted in a Paint window. You may need to accept a dialog resize if the image is larger than the current document.
6. now, from the toolbar to the left of your screen, click on the Selection (the oblong dotted box) tool. With the selection tool, select the entire surface of the table you want to copy. Once selected, click on modifier change again, then select Copy.
7. now, open Microsoft Word.
8. then place the cursor where you want the table to set, and then press the CTRL and V together on your keyboard.
9. the image of the table should now be pasted into your Word document.
Alternatively, you can use the cutting tool (click on the Start button and type snipping tool in the search field). Select the table you want in the pdf page using the cutting tool and then open word and paste the table in word.
This forum post is my own opinion and does not necessarily reflect the opinion or the opinion of Microsoft, its employees or other MVPS.
John Barnett MVP: Windows XP Expert associated with: Windows Expert - consumer: www.winuser.co.uk | vistasupport.mvps.org | xphelpandsupport.mvps.org | www.silversurfer-Guide.com
-
I installed lightroom on a new computer (windows 10) cc. I copied all of my original photos on a hard drive and them imported by adding them on the new computer using the import function. I have a catalog to date backed on thehard drive and have tried to insert into the new folder to lightroom. Unfortunately none of my changes, collections etc. seem to be present on the new computer. I still work lightroom with any changes on the old computer where all the photos. Help
He seemed to have solved this problem - the catalogue of the old computer has been saved as a zip file. Once extracted, it could be used as the primary catalog for lightroom on the new computer
Maybe you are looking for
-
I have 18 installed Firefox. This is the third time that Firefox has stopped opening. I ran Malwarebytes and Microsoft Security Essentials all three times and each time found any problems. The only thing that worked was (using Revo Uninstaller) unins
-
Satellite A100-847 - Virtual sound driver for Windows 7?
Hi guys,. Is there an available virtual driver sound for win7? I use Satellite A100-847 and impossible to find some drivers. Thanks for your help.
-
Windows Update for Vista (KB2286198) _
Everything from the lates Windows Update has been installeded for Vista (KB2286198) I was not able to use my card to air with the Cradlepoint router. The computer can see the router but only connect with local and non-local and internet access. If
-
Hi all I have to call Matlab of Labview by using ActiveX 'Matlab nodal point Script' (including using activeX) works, but I need for more control via the connection, so I have to use the ActiveX screw directly. Problem: I still get the same error usi
-
LaserJet Pro P1102: p1102 xp ServicePack
I have to buy a new printer for my old pc with Windows XP Service Pack 2. Can you confirm that this printer (P1102) doesn't have Service Pack 3?