USE loop index - how?
Can I follow the UUT in WatchExpression loop index in the execution of my order?
In short, I want to see how much DUT I already have.
Thank you
Fomin
Hello
did you try this expression 'RunState.Root.Locals.UUT.UUTLoopIndex '?
A2
Tags: NI Software
Similar Questions
-
How to monitor the SQL perticuler using the INDEX or not?
I'm running on a long-term quary and the output is coming very late. So, I want to know that the quary sql uses the index or not? How do I know that?Hello
You have not provided your db version?
You can check v $ object_usage in a simple way. Try to check the explanation of your query if you current sql is by using your existing index or not.
Check with dbms_xplan.displayRequest to go through the links of Ask tom and jonathan lewis
http://jonathanlewis.WordPress.com/2007/02/15/index-not-used-10G/
http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:736825544526HTH
-Pounet N
-
How to use an index with the clause 'in '.
Hi all
I have a sql statement with "" * in the clause * "."
for example:
select emp_id from emp where ename in ("vikas", "krishna", "John", "scott");
When I check the plan explain he uses the index here even if the statistics was entered. He always goes for the full table scan.
There is an index created for the ename column.
Please tell me a technique on how to make use of the index here.
Thank you and best regards,
Vikas KrishnaVikas,
What version of Oracle you are running.
CLAUSE IN will use the index as appropriate.
In your example Optimizer may decide to use FTS (Full Tablle Scan) for various reasons. May be that the table is very small.
SE for example below where he uses an index on the CLAUSE IN...
The essential point being that I made "wide enough" table (in this case including a column of type CHAR) makes use of INDEX more effective than a FTS.select * from v$version where rownum < 2; Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi create table bigt (c int, s char(100)); insert into bigt select level, 'X' from dual connect by level < 501; create index bigt_in1 on bigt (c ); exec dbms_stats.GATHER_TABLE_STATS('SUDHAKAR', 'BIGT'); explain plan for select c,s from bigt where c in (1,2,3,43,5); select * from table(dbms_xplan.display); PLAN_TABLE_OUTPUT Plan hash value: 238667275 ----------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 5 | 520 | 3 (0)| 00:00:01 | | 1 | INLIST ITERATOR | | | | | | | 2 | TABLE ACCESS BY INDEX ROWID| BIGT | 5 | 520 | 3 (0)| 00:00:01 | |* 3 | INDEX RANGE SCAN | BIGT_IN1 | 5 | | 2 (0)| 00:00:01 | ----------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 3 - access("C"=1 OR "C"=2 OR "C"=3 OR "C"=5 OR "C"=43)
VR,
Sudhakar B. -
How it warns Oracle to use an index for the join of two tables...
How to prevent the Oracle to use an index for the join of two tables to get a view online that is used in an update statement?
O.K. I think I should explain what I mean:
When you join two tables that have many entries sometimes there're better is not to use an index on the column that is used as a criterion to join.
I have two tables: table A and table B.
Table A has 4,000,000 entries and table B has 700,000 entries.
I have a join of two tables with a numeric column as join criteria.
There is an index on this column in A table.
So I instead of
I want to usewhere (A.col = B.col)
in order to avoid Oracle using the index.where (A.col+0 = B.col)
When I use the join in a select query, it works.
But when I use the join as inline in an update statement I get the error ORA-01779.
When I remove the '+ 0' the update statement works. (The column is unique in table B).
Any ideas why this happens?
Thank you very much in advance for any help.
Hartmut cordiallyYou plan to use a NO_INDEX hint as shown here: http://www.psoug.org/reference/hints.html
-
Using Windows 7, how can I access shortcut files by using relative indexing
I'm trying to back up a folder containing subfolders containing shortcuts to different files in subfolders. The main file must be saved on the removable device and indexing to the shortcuts will not be valid. By using relative indexing in the main folder for shortcuts, the shortcuts will be valid no mater where the main folder is moved to. This option is available in earlier versions of Windows using the "... /.." in the path to access the higher folders. This option is not available when you set the path of shortcuts. Any help in this matter would be very welcomed.
Hi Joët,Thanks for posting your question on Microsoft Community!I suggest you to ask your question on the TechNet Forums.I hope this helps! -
How to find the person using an index
Hello
I'm working on a
Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
With partitioning, Real Application Clusters, Automatic Storage Management, OLAP,.
Options of Data Mining and Real Application Testing
I need to know who (who) using an index.
Is it possible to do?
Thanks in advance,
Samuel
I'm not sure of what you're trying to achieve... but well, you could start here:
Select *.
v $ sql_plan
where object_name = '
. ' HTH,
Thierry
-
Help for Oracle to use an index
Unfortunately, I'm stuck with Oracle 8i. I have a fairly complex view which, at the time of the call, will have values specified for the columns in the view.
The full view will look something like this - even if real life tables are slightly different and a little more complex. (view has been developed [another post | http://forums.oracle.com/forums/thread.jspa?threadID=1043162 & messageID = 4163818 #4163818]):
When this view is called, there will certainly skuid and skuid is indexed. The problem I'm having becomes Oracle to bring the skuid specified in the Interior selects.select a.skuid, sum(a.qty) qty, a.lot, b.status status from ( select skuid, lot, 1 qty, row_number() over(partition by skuid order by lot) rn from lot, ( select rownum rnum from all_objects where rownum <= (select sum(qty) from lot) ) where rnum <= qty ) a, ( select skuid, status, sum(qty) over(order by qty desc) - qty + 1 start_rn, sum(qty) over(order by qty desc) end_rn from status ) b where b.skuid = a.skuid and a.rn between b.start_rn and end_rn group by a.skuid, b.status, a.lot order by a.skuid, b.status, a.lot
For now, concentrate on the online portion "a":
If I put this part of the display within a select statement as follows:select skuid, lot, 1 qty, row_number() over(partition by skuid order by lot) rn from lot, ( select rownum rnum from row_gen ) where rnum <= qty
Can I get a good result of query performance. Similar to this execution plan:select skuid, lot, sum(qty) from ( select skuid, lot, 1 qty, row_number() over(partition by skuid order by lot) rn from lot, ( select rownum rnum from row_gen where rownum <= (select max(qty) from lot) ) where rnum <= qty AND SKUID = 'SKUA' -- <--- Note indexed column here ) group by skuid, lot
However, when I move the indexed column outside the Interior view (where it will be in real life), like this:Execution Plan ---------------------------------------------------------- 0 SELECT STATEMENT Optimizer=RULE 1 0 SORT (GROUP BY) 2 1 VIEW 3 2 WINDOW (SORT) 4 3 COUNT 5 4 NESTED LOOPS 6 5 VIEW 7 6 COUNT (STOPKEY) 8 7 TABLE ACCESS (FULL) OF 'ROW_GEN' 9 5 TABLE ACCESS (BY INDEX ROWID) OF 'LOT' 10 9 INDEX (RANGE SCAN) OF 'LOT_SKU' (UNIQUE)
So in this case, the performance is very poor, with a similar to this execution plan:select skuid, lot, sum(qty) from ( select skuid, lot, 1 qty, row_number() over(partition by skuid order by lot) rn from lot, ( select rownum rnum from row_gen where rownum <= (select max(qty) from lot) ) where rnum <= qty ) WHERE SKUID = 'SKUA' -- <--- Note indexed column here, -- since inner view will be an Oracle view, not inline view group by skuid, lot
In the example of real life, the unique key is actually 5 columns, but the principle, I think, it's the same.Execution Plan ---------------------------------------------------------- 0 SELECT STATEMENT Optimizer=RULE 1 0 SORT (GROUP BY) 2 1 VIEW 3 2 WINDOW (SORT) 4 3 COUNT 5 4 NESTED LOOPS 6 5 VIEW 7 6 COUNT (STOPKEY) 8 7 TABLE ACCESS (FULL) OF 'ROW_GEN' 9 5 TABLE ACCESS (FULL) OF 'LOT'
So, is it possible to write this request (which will be a view) such as Oracle (8i) realizes he can carry the values specified in the Interior selects and use the index for them?
Published by: kent b on March 16, 2010 08:29
Adding a / * + INDEX() * / index in the Interior, select help a little, but is still nowhere near as fast when the skuid is specified in the internal selection.Hello
Here is another solution to this problem that uses any CONNECT BY and does not assume that this amount represents an integer.
In your previous thread
Re: Very challenging FINDS to write (call for help)
Solomon has shown how we can avoid "explode" status in units, using a total cumulative.
The solution below does the same thing for many, as well.SELECT l.skuid , LEAST (l.max_qty, s.max_qty) - GREATEST (l.min_qty, s.min_qty) AS qty , l.lot , s.status FROM ( -- Begin in-line view l to get data from lot SELECT skuid , lot , SUM (qty) OVER ( PARTITION BY skuid ORDER BY SUBSTR (lot, 1, 1) , TO_NUMBER (SUBSTR (lot, 2)) ) - qty AS min_qty , SUM (qty) OVER ( PARTITION BY skuid ORDER BY SUBSTR (lot, 1, 1) , TO_NUMBER (SUBSTR (lot, 2)) ) AS max_qty FROM lot ) l -- End in-line view l to get data from lot , ( -- Begin in-line view s to get data from status SELECT skuid , status , SUM (qty) OVER ( PARTITION BY skuid ORDER BY CASE WHEN status = 'AVAIL' THEN 1 WHEN status = 'RES' THEN 2 WHEN status = 'HOLD' THEN 3 END ) - qty AS min_qty , SUM (qty) OVER ( PARTITION BY skuid ORDER BY CASE WHEN status = 'AVAIL' THEN 1 WHEN status = 'RES' THEN 2 WHEN status = 'HOLD' THEN 3 END ) AS max_qty FROM status ) s -- End in-line view s to get data from status WHERE l.skuid = s.skuid AND l.min_qty < s.max_qty AND s.min_qty < l.max_qty ORDER BY l.skuid , l.max_qty , s.max_qty ;
Published by: Frank Kulash, March 16, 2010 13:23
It might be easier to manage if we pull the min_qty of the max_qty, like this:
SELECT l.skuid , LEAST (l.max_qty, s.max_qty) - GREATEST (l.min_qty, s.min_qty) AS qty , l.lot , s.status FROM ( -- Begin in-line view l to get data from lot SELECT skuid, lot , max_qty , max_qty - qty AS min_qty FROM ( -- Begin in-line view to get max_qty SELECT skuid, lot, qty , SUM (qty) OVER ( PARTITION BY skuid ORDER BY SUBSTR (lot, 1, 1) , TO_NUMBER (SUBSTR (lot, 2)) ) AS max_qty FROM lot ) -- End in-line view to get max_qty ) l -- End in-line view l to get data from lot , ( -- Begin in-line view s to get data from status SELECT skuid, status , max_qty , max_qty - qty AS min_qty FROM ( -- Begin in-line view to get max_qty SELECT skuid, status, qty , SUM (qty) OVER ( PARTITION BY skuid ORDER BY CASE WHEN status = 'AVAIL' THEN 1 WHEN status = 'RES' THEN 2 WHEN status = 'HOLD' THEN 3 END ) AS max_qty FROM status ) -- End in-line view to get max_qty ) s -- End in-line view s to get data from status WHERE l.skuid = s.skuid AND l.min_qty < s.max_qty AND s.min_qty < l.max_qty ORDER BY l.skuid , l.max_qty , s.max_qty ;
-
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
-
ORA-00904 PLS-00364: loop index variable
Hi all
create the table xxc_cust_id (cust_id number);
insert into xxc_cust_id values (1)
create table xxc_child (id number, part varchar2 (20), amount number);
insert into xxc_child values (1, "Replaced processor", 1500)
insert into xxc_child values (1, 'Replaced mouse', 200)
insert into xxc_child values (' 6, ' mouse replaced ', 200)
create table xxc_parent (ID, cust_id varchar2 (10));
insert into xxc_parent values (1,1)
insert into xxc_parent values (6.1)
Select * from xxc_parent
ID CUST_ID
--------- ----------
1 1
6 1
Select * from xxc_child
AMOUNT OF PART ID
-------- -------------------- ----------
1 processor replaced 1500
1 mouse replaced 200
6 mouse replaced 200
Select * from xxc_cust_id
CUST_ID
--------
1
I need
CUST_ID PLATE
-------- ----------
1 1900
to insert data into the table xxc_details
CREATE OR REPLACE PROCEDURE XXC_SUM_DETAILS
IS
CURSOR c_1
IS
SELECT Cust_id
OF xxc_cust_id
ORDER BY cust_id.
CURSOR c1
IS
SELECT a.cust_id, SUM (sum) total_sum
Xxc_parent a, xxc_child b
WHERE a.id = b.id
AND cust_id = c_cust_id.cust_id
GROUP BY a.cust_id;
BEGIN
FOR c_cust_id IN c_1
LOOP
dbms_output.put_line ('Enter');
C_rec IN C1
LOOP
BEGIN
INSERT INTO xxc_details (part_id, total_amount)
VALUES (c_rec.cust_id, c_rec.total_sum);
COMMIT;
END;
END LOOP;
END LOOP;
END;
LINE/COL ERROR
-------- -----------------------------------------------------------------
10/9 PL/SQL: statement ignored
12/42 PL/SQL: ORA-00904: "C_CUST_ID." "" Cust_id ": invalid identifier
21/13 PL/SQL: statement ignored
22/41 PLS-00364: 'C_REC' use the loop index variable is not valid
22/47 PL/SQL: ORA-00984: column not allowed here
In this case you cannot include the sequence directly in the GROUP BY in the query part, that you can group on sequences or the aggregated.
He must ignore the sequence to a higher level, the group so that it is assigned to each row that will be inserted in the sub-sub-group by query to...
INSERT INTO xxc_details (details_id, cust_id, total_amount, CONTRACT_NUMBER)
Select DETAILS_ID_SEQ. NEXTVAL
cust_id
total_sum
quantity
from (select a.cust_id,
Total_sum SUM (b.amount),
d.amount
Xxc_parent a.,
b xxc_child,
xxc_cust_id c,
xxc_sum_acc d
where a.id = b.id
and c.cust_id = a.cust_id
and c.cust_id = d.cust_id
AND contract_type = 'AML.
and not exists (select 1
of e xxc_details
where c.cust_id = e.cust_id
)
GROUP BY a.cust_id, d.amount
);
-
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
-
query not using the index for some user
Hello
I have a query that is running in less than a second for sys, system, or schema owner. However, another user (test_user) take 30 seconds to run the same query.
I certainly dba and privileges identical to test_user as schmea_user, but the result is the same.
I checked
Select * from V$ SYS_OPTIMIZER_ENV;
Both are the same for both users.
I have check the plan to explain to both users. I noticed that for sys/system/schema_owner, the query uses an index, but not the test_user.
All have experience the issue where a user uses an index, but not the other?
Thank you for any assistance.Thank you for the display of formatting output, this output is much easier to read.
One of the first things you notice about the execution plans that is for the owner non-schema "SQL_ID, 0wcs85uywn72m, number of children 1" appears in the output of DBMS_XPLAN, while "SQL_ID 0wcs85uywn72m, child number 0" (the same SQL_ID but a different number of child) appears for the schema owner. "" Whereas the SQL_ID is the same, which indicates that the client requires exactly the same SQL statement, so it's a good start.
Then, note that in the predicate for the nonschema owner information section the following appears (sometimes with the order of the two conditions switched in position) as a condition placed on each table that is available in the schema:
filter(("SEAL_FLAG" IS NULL OR "SEAL_FLAG"'Y'))
The above suggests the presence of the virtual private database (or a superset of private database virtual) generated the predicates. You should be able to confirm that this is the case by querying V$ VPD_POLICY using the SQL_ID which was displayed in the DBMS_XPLAN output:
SELECT * FROM V$VPD_POLICY WHERE SQL_ID='0wcs85uywn72m';
As a test, I made a few minor adjustments to the example on this page:
http://Antognini.ch/2011/09/optimizer_secure_view_merging-and-VPD/
I changed the name of T to T12 and TESTUSER table specified for the schema names. I then created the function S of this page as follows:CREATE OR REPLACE FUNCTION s (schema IN VARCHAR2, tab IN VARCHAR2) RETURN VARCHAR2 AS BEGIN RETURN 'ID < 10'; END; /
I then added a couple of lines in the T12 test table:
INSERT INTO T12 VALUES (1,1,NULL); INSERT INTO T12 VALUES (4,1,NULL); INSERT INTO T12 VALUES (10,1,NULL); INSERT INTO T12 VALUES (12,1,NULL); COMMIT;
With an active 10053 trace, I executed the following SQL statement:
SELECT id, pad FROM t12 WHERE spy(id, pad) = 1
The SQL_ID (in my case, found in the 10053 trace file) was 6hqw5p9d8g8wf, so I checked V$ VPD_POLICY to this SQL_ID:
SELECT * FROM V$VPD_POLICY WHERE SQL_ID='6hqw5p9d8g8wf'; ADDRESS PARADDR SQL_HASH SQL_ID CHILD_NUMBER OBJECT_OWNER OBJECT_NAME POLICY_GROUP POLICY POLICY_FUNCTION_OWNER PREDICATE ---------------- ---------------- ---------- ------------- ------------ ------------ ------------------------------ ------------------------------ ---------------------- ------------------------------ ------------------------------------------------------------------------------------ 000007FFB7701608 000007FFB7743350 1518838670 6hqw5p9d8g8wf 0 TESTUSER T12 SYS_DEFAULT T_SEC TESTUSER ID < 10
As noted above, the VPD test function named S added the predicate "ID".< 10"="" to="" the="" sql="">
There are not many clues in the 10053 trace file in my test VPD generated additional predicates. Trace the following was found shortly after the beginning of the file (this is the SQL statement initially presented):
----- Current SQL Statement for this session (sql_id=6hqw5p9d8g8wf) ----- SELECT id, pad FROM t12 WHERE spy(id, pad) = 1
I searched then down in the trace for final after changes query file (to be noted that this sentence could be slightly different in different versions of database Oracle). That's what I found:
Final query after transformations: ******* UNPARSED QUERY IS ******* SELECT "T12"."ID" "ID","T12"."PAD" "PAD" FROM "TESTUSER"."T12" "T12" WHERE "TESTUSER"."SPY"("T12"."ID","T12"."PAD")=1 AND "T12"."ID"<10 kkoqbc: optimizing query block SEL$F5BB74E1 (#0)
Note that the final query after transformation shows how the final version of the query that has been rewritten by the query optimizer before the SQL statement has been executed and this version of the query includes AND "T12". "" IDENTITY CARD ".<10. if="" i="" was="" attempting="" to="" determine="" how="" that="">10.><10 predicate="" was="" added="" to="" the="" sql="" statement,="" i="" would="" start="" at="" the="" "current="" sql="" statement="" for"="" line="" in="" the="" trace="" file="" and="" search="" down="" the="" trace="" file="" for="">10><10* -="" in="" this="" case,="" the="" following="" is="" what="" i="" found="" as="" the="" first="" search="" result,="" very="" close="" to="" the="" "current="" sql="" statement="" for"="" line="" in="" the="" trace="">10*>
************************** Predicate Move-Around (PM) ************************** PM: PM bypassed: Outer query contains no views. PM: PM bypassed: Outer query contains no views. query block SEL$F5BB74E1 (#0) unchanged FPD: Considering simple filter push in query block SEL$F5BB74E1 (#0) "TESTUSER"."SPY"("T12"."ID","T12"."PAD")=1 AND "T12"."ID"<10 try to generate transitive predicate from check constraints for query block SEL$F5BB74E1 (#0) finally: "TESTUSER"."SPY"("T12"."ID","T12"."PAD")=1 AND "T12"."ID"<10
As can be seen from the above (because the predicate again appeared before and after the line containing the word "Finally: '), the AND"T12 ". "" IDENTITY CARD ".<10 predicate="" was="" already="" added="" to="" the="" original="" sql="" statement="" by="" the="" time="" the="" predicate="" move-around="" section="" of="" the="" trace="" file="" was="" written,="" and="" that="" is="" the="" first="" mention="" of="">10><10 in="" the="" trace="" file.="" in="" your="" case,="" you="" would="" search="" the="" 10053="" trace="" file="">10>
"SEAL_FLAG" IS NULL
If V$ VPD_POLICY revealed that there are virtual private database (VPD) generated predicates applied to the SQL statement, take a look at the following article in the Oracle documentation library:
http://docs.Oracle.com/CD/B28359_01/network.111/B28531/VPD.htmThis article lists the different points of view, who can be interviewed to learn more about the VPD rules which are in force in the schema. For example, with my SPV test:
SELECT * FROM ALL_POLICIES; OBJECT_OWNER OBJECT_NAME POLICY_GROUP POLICY_NAME PF_OWNER PACKAGE FUNCTION SEL INS UPD DEL IDX CHK ENA STA POLICY_TYPE LON ------------------------------ ------------------------------ ----------------------------- ------------------------------ ------------------------------ ----------------------------- ------------------------------ --- --- --- --- --- --- --- --- ------------------------ --- TESTUSER T12 SYS_DEFAULT T_SEC TESTUSER S YES YES YES YES NO NO YES NO DYNAMIC NO
He knows performance issues related to the use of VPD, some of which are Oracle Database version-dependent, and some have been fixed in recent versions. Take a look at the following articles if you have access to My Oracle Support:
MetaLink (MOS) Doc ID 728292.1 ' known performance problems when you use transparent encryption data and indexes on the encrypted columns.
MetaLink (MOS) Doc ID 967042.1 "How to investigate Query Performance regressions Caused by VPD (FGAC) predicates?"You might find working through the second of the above that the problem is caused by a bug in database Oracle.
On a side note. Execution plans you have published include the 0 value in the column starts many of the operations in the execution plan. 0 indicates that the operation never actually executed. A 0 is included in the column starts on the line that includes the FULL ACCESS of TABLE of PEOPLE_TRANSACTIONS at least to the OPC. Value 123, a full table of PEOPLE_TRANSACTIONS table scan PROPERTY_CONTAINER_ID was not actually performed.
Charles Hooper
http://hoopercharles.WordPress.com/
IT Manager/Oracle DBA
K & M-making Machine, Inc. -
Why doesn't Oracle use my index?
Hi guys, imagine I have a table with columns A, B, C, D
It has a (non-unique) index on column D
When I run the query:
"SELECT A, B and C WHERE D > = ' 1.1.2010.
the index is never used, and it takes 20 minutes. The table has about 7 million lines. It doesn't matter what size of my result set is (even for a few lines), the plan of execution always shows me a full table scan. Only when I create an index on all 4 columns, the index is used. But this isn't a solution, because in my real application, I have about 20 columns in my SELECT clause. I also rebuilt the indexes and statistics.
Can someone help me?
Thank you!890408 wrote:
Well, then this is the result of 3 queries:Well, Oracle did what I thought it would be then. Don't you see how your density changed (and now matches the 1/NUM_DISTINCT)? Before this etait.33333 and now it's de.0024. So the estimated cardinalities went from 2 624 862 to 19 492 making it much more attractive index the optimizer.
As I mentioned in my previous post, you should be aware of your inclination of data. A large part of your data in this column is in the period of 01/01/1970. If someone asks for this Oracle is likely to try to use an index to chase these data that is not optimal.
-
Using the index of multiple values
Hi guys,.
Trying to assess the benefits of the addition of index of multiple values, a quick question on the index of multiple values:
Here's my content from the cache:
Key (EmpID), value [employee (age int, double salary, Department of String)]
(1, new employee (25, 35000.0, "Admin"));
(2, new employee (22, 30000.0, "Admin"));
(3, new employee (34, 40000.0, 'Communications'));
(4, new employee (36, 41000.0, "Admin"));
(5, new employee (36, 42000.0, "HR"));
(6, new employee (29, 30000.0, "HR"));
(7, new employee (51, 50000.0, "BackOffice"));
(8, new employee (36, 35000.0, "HR"));
(9, new employee (46, 45000.0, "Admin"));
(10, new employee (48, 47000.0, "HR"));
If I still want to find all employees in the 'Human resources' Department and whose salary is more than 35000.
Eventually, I would like to do the following:
ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
ValueExtractor depExtractor = new PofExtractor (String.class, 3);
cache.addIndex (salExtractor, false, null);
cache.addIndex (depExtractor, false, null);
EqualsFilter departmentFilter = new EqualsFilter (depExtractor, 'HR');
GreaterFilter salFilter = new GreaterFilter (salExtractor, 35000);
Filter allFilter = new AllFilter (new filter [] {departmentFilter, salFilter});
Employees value = cache.entrySet (allFilter));
For my usecase above how can I use the indexing of multiple values to the same query?
ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
ValueExtractor depExtractor = new PofExtractor (String.class, 3);
MultiExtractor mExtractor is new MultiExtractor (new ValueExtractor [] {salExtractor, depExtractor});.
cache.addIndex (mExtractor, false, null);
But how can I use the extractor to create multivalued filter queries for employees in the Department of human resources with greater than 35000 salary? Any ideas are much appreciated.
Thank youD wrote:
Hi guys,.Trying to assess the benefits of the addition of index of multiple values, a quick question on the index of multiple values:
Here's my content from the cache:
Key (EmpID), value [employee (age int, double salary, Department of String)]
(1, new employee (25, 35000.0, "Admin"));
(2, new employee (22, 30000.0, "Admin"));
(3, new employee (34, 40000.0, 'Communications'));
(4, new employee (36, 41000.0, "Admin"));
(5, new employee (36, 42000.0, "HR"));
(6, new employee (29, 30000.0, "HR"));
(7, new employee (51, 50000.0, "BackOffice"));
(8, new employee (36, 35000.0, "HR"));
(9, new employee (46, 45000.0, "Admin"));
(10, new employee (48, 47000.0, "HR"));If I still want to find all employees in the 'Human resources' Department and whose salary is more than 35000.
Eventually, I would like to do the following:
ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
ValueExtractor depExtractor = new PofExtractor (String.class, 3);
cache.addIndex (salExtractor, false, null);
cache.addIndex (depExtractor, false, null);EqualsFilter departmentFilter = new EqualsFilter (depExtractor, 'HR');
GreaterFilter salFilter = new GreaterFilter (salExtractor, 35000);
Filter allFilter = new AllFilter (new filter [] {departmentFilter, salFilter});
Employees value = cache.entrySet (allFilter));For my usecase above how can I use the indexing of multiple values to the same query?
ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
ValueExtractor depExtractor = new PofExtractor (String.class, 3);
MultiExtractor mExtractor is new MultiExtractor (new ValueExtractor [] {salExtractor, depExtractor});.
cache.addIndex (mExtractor, false, null);But how can I use the extractor to create multivalued filter queries for employees in the Department of human resources with greater than 35000 salary? Any ideas are much appreciated.
Thank you
I remember, values multiple index refers to a different concept: a multivalued index means that you can retrieve a collection of values of similar role of an attribute on which you can do Contains, ContainsAll filtering, and ContainsAny.
In this case to fully the lever consistency of querying capabilities, you would
- either add a sorted index with a custom comparator that compares the tables containing a salary and a Department on a first salary so the base of the Department and add a filter custom which is able to take advantage of the index for the request for the salary and also able to filter on the element of the array of index service
-Add two independent indices (a sorted index of wages and a unsorted for the Department), in which case you can leverage all existing (GreaterThanFilter, EqualsFilter and AndFilter) codeBest regards
Robert
-
Using an index that is located on a column in OBIEE expression
Hi all
We have an ORDERS table that has a column on it is called ORDER_TIMESTAMP. On the table at the physical level, there is a hint of TRUNC (ORDER_TIMESTAMP). However, when I select on this ORDER_TIMESTAMP by using a filter, its does not use the index.
How can I use the index on this table? I tried to use the 'Advanced' and 'convert filter SQL.
Can someone advise?
Thank youIn your BMM layer, map the timestamp field command in the source of the logical table to TRUNC (ORDER_TIMESTAMP) against the source table.
Only try.
Rgrds
Alastair -
2 running, 1 inside and 1 sql external, dynamic queries using loops and ref Cursor
Hi all
I'm under Oracle 10.2.0.2. I'm currently building dynamic sql using external and internal queries ref Cursor. Queries make use of user selected lists of ID, which is stored in a table in memory at run time. My example is as follows. From a list of book_publication_id on a web page, the user selects several books. The same user selects then several maps from a list of map_publication_id on the same web page. A book contains several maps and some of these cards will appear in more than one book (aka many many relationships).
This should then ask the following output to a new web page:
In the example above, the outer loop displays the details of the book for book_publication_id 230 and the inner loop displays all the users selected the maps in book_publication_id 230. Then, it moves on the details of the book for book_publication_id 240 and done the same thing again. Similar in some ways to how break would work in SQL * Plus, even if the table is built like an HTML, the book details must be on a separate line for the card details. However I don't know how I would want it to work.Outer loop: Display book details for book_publication_id 230 Inner loop: Display 1st map details for map_publication_id 340 Inner loop: Display 2nd map details for map_publication_id 346 Inner loop: Display 3rd map details for map_publication_id 350 Outer loop: Display book details for book_publication_id 240 Inner loop: Display 1st map details for map_publication_id 346 Inner loop: Display 2nd map details for map_publication_id 375 Outer loop: Display book details for id 255 and so on.
So far, using loops, I could not show all the details of card for each different book_publication_id, after the details of the book for only 1 book_publication_id are displayed each time. If a loop in a loop. I hope that makes sense. I think this is my internal request that it be built differently. My code for this part of the program, which is currently wrong, is as follows:
If anyone has any ideas or suggestions, I would be grateful. It is an extension of my previous code, I posted a question recently. As I am working and learning a step at a time, I left this idea in my previous question, that I had to make sure I knew that first.--Global variable section contains: var_user_chosen_map_list_ids VARCHAR2(32767); var_details VARCHAR2(32767); ...... PROCEDURE PROCMAPSEARCH (par_user_chosen_map_list_ids PKG_ARR_MAPS.ARR_MAP_LIST) IS BEGIN FOR rec_user_chosen_map_list_ids IN 1 .. par_user_chosen_map_list_ids.count LOOP var_user_chosen_map_list_ids := var_user_chosen_map_list_ids || '''' || par_user_chosen_map_list_ids(rec_user_chosen_map_list_ids) || ''',' ; END LOOP; var_user_chosen_map_list_ids := substr(var_user_chosen_map_list_ids, 1, length(var_user_chosen_map_list_ids)-1); var_details := FUNCMAPDATAFIND (var_user_chosen_map_list_ids); htp.print(var_details); END PROCMAPSEARCH; FUNCTION FUNCMAPDETAILS (par_user_chosen_map_list_ids IN VARCHAR2(32767) RETURN VARCHAR2 AS TYPE cur_type_map IS REF CURSOR; cur_book_search cur_type_map; var_book_date NUMBER(4); var_book_title VARCHAR2(32767); cur_map_search cur_type_map; var_map_date NUMBER(4); var_map_title VARCHAR2(32767); begin: OPEN cur_book_search FOR 'SELECT BI.book_date, BT.book_title FROM BOOK_INFO BI, BOOK_TITLE BT, TABLE (sys.dbms_debug_vc2coll(' || par_user_chosen_book_list_ids || ')) BL_1 WHERE BI.book_title_id = BT.book_title_id AND BI.book_publication_id = BL_1.column_value'; OPEN cur_map_search FOR 'SELECT MI.map_date, MT.map_title FROM map_info MI, map_title MT, TABLE (sys.dbms_debug_vc2coll(' || par_user_chosen_book_list_ids || ')) BL_2 TABLE (sys.dbms_debug_vc2coll(' || par_user_chosen_map_list_ids || ')) ML WHERE MI.map_title_id = MT.map_title_id AND BI.book_publication_id = BL_2.column_value AND BI.book_publication_id = MI.pub_publication_id AND MI.map_publication_id = ML.column_value'; LOOP LOOP FETCH cur_map_compare INTO var_book_date, var_book_title; var_details var_details := var_details || 'Book date: '|| var_book_date || 'Book title: ' || var_book_title; FETCH cur_map_compare INTO var_map_date, var_map_title; var_details := var_details || 'Map date: '|| var_map_date || 'Map title: ' || var_map_title EXIT WHEN cur_book_compare%NOTFOUND; END LOOP; EXIT WHEN cur_map_compare%NOTFOUND; END LOOP; RETURN var_details; END FUNCMAPDETAILS;
Kind regards
TimUsing dynamic SQL
declare dd sys_refcursor; ee sys_refcursor; d dept%rowtype ; e emp%rowtype ; begin open dd for 'select * from dept' ; loop fetch dd into d ; exit when dd%notfound ; dbms_output.put_line('Department:'||d.dname); open ee for 'select * from emp where deptno='||d.deptno ; loop fetch ee into e ; exit when ee%notfound ; dbms_output.put_line('..Employee:'||e.empno||':'||e.ename); end loop; end loop ; end ; / Department:ACCOUNTING ..Employee:7782:CLARK ..Employee:7839:KING ..Employee:7934:MILLER Department:RESEARCH ..Employee:7369:SMITH ..Employee:7566:JONES ..Employee:7788:SCOTT ..Employee:7876:ADAMS ..Employee:7902:FORD Department:SALES ..Employee:7499:ALLEN ..Employee:7521:WARD ..Employee:7654:MARTIN ..Employee:7698:BLAKE ..Employee:7844:TURNER ..Employee:7900:JAMES Department:OPERATIONS PL/SQL procedure successfully completed.
HTH
SS
Maybe you are looking for
-
Hey! I have a laptop HP 635 with AMD E - 350 1.6 GHz processor in general I am very happy with my laptop, but when it comes on playing the games my CPU is on the way. So! My question is: can I change everything that is on my computer? If I do, I lose
-
Want to e-mail addresses of the computer to my mobile phone
Original title: Email Contacts How can I get e-mail addresses from my computer copied on my mobile phone
-
Download again the photos in the photo library of sd card
I downloaded pictures from my sd card to 3 times without erasing my card, and each time he copied all the images instead of just to add new to the picture library. I removed them all from the library thinking I could then just download it again and o
-
Windows 7 Live Mail Exchange... file extension?
Is there a setting for Windows 7 to prevent it from changing a file extention (attachments), for example, the file name "boxes... xls '... Windows XP and Vista will leave the only extension and allow you to open with Excel. When sent to Windows 7 Li
-
problems of network with Vmware workstation 6.5.0
version of Workstation 6.5.0 - 118166I have two virtual machines W2003R2 and W2008r2 in a physical host with Windows XP Edition family.The network configuration is in Bridge mode the two.No dynamic IP for both.Physical PC1W2003R2: W2008R2IP: 172.17.0