How to create index on Global Temporary Table?
Hi,
Can i create index with storage parameters on global temporary table? If possible, how?
Thanks
Yes. You can create an index on a global temporary table (GTT) with the regular 'CREATE INDEX' statement.
Not sure though if you are allowed to locate it in a specific tablespace. Why would you want to do that anyway?
My guess is, like the GTT, indexes on GTT's also default to the temporary tablespace.
Similar Messages
-
Problem creating index on global temporary table
Running Oracle DB Oracle9i Release 9.2.0.7.0.
I'm trying to create 3 indexes on a temporary table, the first index creates fine but the other remaining 2 result in the following error:
ERROR at line 1: ORA-00600: internal error code, arguments: [kftts2bz_many_files], [0], [20], [], [], [], [], []
Have tried searching with not much success, any pointers, tips, hints would be appreciated, below is the table and the indexes:-
create global temporary TABLE contacts (
ID VARCHAR2(20) NOT NULL,
DOB VARCHAR2(8),
HH_LASTNAME VARCHAR2(90),
PERSON VARCHAR2(10) NOT NULL,
CONT_JOB VARCHAR2(90) NOT NULL,
SOURCE VARCHAR2(8) NOT NULL,
ADS VARCHAR2(8) NOT NULL,
CONT VARCHAR2(8) NOT NULL,
SRCPERSONID VARCHAR2(15),
FIRSTNAME VARCHAR2(90),
MIDDLENAME VARCHAR2(90),
LASTNAME VARCHAR2(90),
FULLNAME VARCHAR2(90),
TITLE VARCHAR2(50),
SALUTATION VARCHAR2(90),
) on commit delete rows;
create index i_contact_1 on contacts(dob, soundex(hh_lastname ));
create index i_contact_pk on contacts(id, person, cont_job, source, ads, cont);
create index i_contact_2 on contacts(srcpersonid, source);Bug 3238525 - Upgrade from 9.0 can leave corruptdata for global temporary table indices
ORA-600 [kftts2bz_many_files]
Doc ID: 285592.1 -
Create view for Global Temporary Table
if view is create for global temporary table so exactly how it works which helps regarding application performance.
Regaards,
Sambit RayA view is just a stored query. It can be on global temporary tables or regular one, makes no difference.
-
How to create index on specific partition table?
Hi Experts,
we created 4 partitions on table .
Table Name : test
partitions : Test_prt1
Test_prt2
Test_prt3
Test_prt4
Our requiremnt create the index on specific partition (ex : Test_prt2) only.Creating Partitioned Tables and Indexes
http://technet.microsoft.com/en-us/library/ms187526(v=sql.105).aspx
you can create a aligned index, the index will be spread over the filegroups
Create NonClustered Index IX_orders_aligned
On dbo.orders(order_id)
On test_monthlyDateRange_ps(orderDate);
OR
Unaligned parition, you can create index on any filegroups
Create NonClustered Index IX_orders_unpartitioned
On dbo.orders(order_id)
On [Test_prt2_FileGroup];
For more information refer the below link
http://sqlfool.com/2008/12/indexing-for-partitioned-tables/
Or
You can try Creating a filtered index (I've not tried it though)
http://www.mssqltips.com/sqlservertip/1785/sql-server-filtered-indexes-what-they-are-how-to-use-and-performance-advantages/
--Prashanth -
How to create index for Telecom large table
Hi ,
I'm working on DB 10G on REHL 5 for telecom company with more than 1 million recorded per day , we need to speed the query result ,
we know there are many types of the INDEX and I'm need a professional advice to create a suitable one ,
many of our queries depend on the MSID ( the MAC address of the Modem ) column ,
Name Null Type
STREAMNUMBER NUMBER(9)
MSID VARCHAR2(20)
USERNAME VARCHAR2(20)
DOMAIN VARCHAR2(20)
USERIP VARCHAR2(16)
CORRELATION_ID VARCHAR2(64)
ACCOUNTREASON NUMBER(3)
STARTTIME VARCHAR2(14)
PRIORTIME VARCHAR2(14)
CURTIME VARCHAR2(14)
SESSIONTIME NUMBER(9)
SESSIONVOLUME NUMBER(9)
.please any help ,really i have 3 queries for the subscriber activity like (usage details , the date of bundle start the the total of the download , he's working out of bundle or not )
and any of the subscribers can check those queries at any time thorw web ,
select nvl(min(substr(a.starttime,1,8)),0) Service_Start_Time, nvl(sum(a.sessionvolume),0) Total_Traffic_KB
FROM aaa_bill a
where msid='84A8E46E929D'
and starttime >=(select max(fee) FROM aaa_bill
where msid='84A8E46E929D' and accountreason=5);and the expected result is
service_start_date totoal_traffic_KB
20120225 440554the MSIDs examples
(84A8E46E7F43,
84A8E46E7A82,
84A8E46E7C84,
84A8E46E7CBF,
also i have this query ,
select
substr(nvl(
(select nvl(starttime,'0') as starttime
from (
select nvl(starttime,0) starttime,sum(sessionvolume) over(partition by msid order by starttime) sum1
from aaa_bill
where msid='84A8E46E90BC' and starttime >=(select max(fee) FROM aaa_bill
where msid='84A8E46E90BC' and accountreason=5))
where sum1>=44987000
and rownum<2)
,0),1,8) Reached_45GB
from dual;and this one ,
select min(to_char(to_date(starttime,'yyyymmddhh24miss'),'yyyy-mm-dd hh24:mi:ss')) "Accounting Start Time",
max(to_char(to_date(curtime,'yyyymmddhh24miss'),'yyyy-mm-dd hh24:mi:ss')) "Accounting Stop Time",sum(sessiontime) Duration1,
TO_CHAR (TRUNC (SYSDATE) + NUMTODSINTERVAL (sum(sessiontime), 'second'),'hh24:mi:ss') hr,
sum(sessionvolume) Traffic
from aaa_bill
where msid='84A8E46E78EF'
and starttime >=(select max(fee) FROM aaa_bill
where msid='84A8E46E78EF' and accountreason=5)
group by correlation_id
order by min(starttime); -
Transaction with Global Temporary Table
Problem:
Transaction starts with few DML statements and in the middle we are calling a JAVA method which creates the dynamic global temporary table and proceeding with few DML statements, if one of the statement fails, in the exception clause we are trying to rollback and transactions after the DDL (create global temp table) are rolled back and transactions before the DDL (create global temp table) are committed.
We cannot pre-create the global temporary table, since we do not know the number of temp table to be pre-created.
How we can resolve this issue? The same concept works for SQL server.
Example of our issue:
--drop table table1 purge;
--drop table t_id purge;
Create table table1 (col1 number, col2 varchar2(20));
Insert into table1 values (1, 'Test1');
Create global temporary table t_id (id number);
Insert into table1 values (2, 'Test2');
Rollback;
After the rollback you can see only the 'Test1' record.> We cannot pre-create the global temporary table, since we do not know the number of temp table to be pre-created.
I don't see how one procedure could need to create an unknown number of temporary tables. Do they all have different (and unknown) column lists? Couldn't you combine them into a single table with a key to distinguish betweeen the different sets of rows? -
Will Partitioning improve performance on Global Temporary Table
Dear Guru,
In one of complicated module I am using Global Temporary Table (GTT) for intermediate processing i.e. It will store required data in it but the rows of the data goes into 10,00,000 - 20,00,000.
Can Partitioning or Indexing on Global Temporary Table improve the performance?
Thanking in Advance
SanjeevSounds like an odd use of a GTT to me, but I'm sure there are valid reasons...
Presumably you are going to be processing all of these rows in some way? In which case I can't see how partitioning, even if it's possible (And I don't think it is) would help you.
Indexes - sure, that might help, but again, if you are reading all/most of these rows anyway they might not help or even get used.
Can you give a bit more detail about exactly what you are doing?
Edited by: Carlovski on Nov 24, 2010 12:51 PM -
Create and insert into temporary table
Dear all,
I want to create an temporary table and insert data from select statement and order data by field in that table, at the end i want to drop temporary table.
CURSOR rob_twin
IS
SELECT t.tarj, s.b24, date, status, fii, acnt, mbr, pviv, type
FROM
p6.tarj t
p6.stb24 s
p6.cuet c
WHERE .......
--now I want to create table and insert above data (from cursor rob_twin)
--after that I need to order data by t.tary from new table
--finally I want to drop this table
Thank you for your help.
Regards,
RobertThe point is in Oracle you do not create the temporary table at run-time, use it, and drop it again.
But you can create a GTT (Global Temporary Table) once and then it stays in the data dictionary, just like a normal table. The "temporary" part is simply that the data is temporary, can only be seen in this one session, and will go away either on commit or when the session ends.
So first you create a global temporary table with the columns you wish. Using either ON COMMIT DELETE ROWS or ON COMMIT PRESERVE ROWS you decide whether data in this GTT should survive across transactions or not.
Your logic could then be to populate this GTT with data from your remote database using INSERT INTO gtt_table SELECT ... FROM ...@dblink
Then work with that data in the GTT as you would with any normal local table
And finally either you simply commit your transaction and the data in the GTT goes away (if you did ON COMMIT DELETE ROWS), or you just DELETE gtt_table.
You do not continually create and drop a GTT. The table definition is permanent - it is only the data that is temporary.
Edit:
PS: As Karthick stated above - for almost any usual purposes it is likely to be possible to solve the problem without having to use GTT's. Usually even with db_links it can be done with suitable SQL and joins without having to use a GTT. But if that turns out to be one of those rare occasions where that is hard - then the above is the way to go ;-)
Edited by: Kim Berg Hansen on Sep 19, 2011 1:38 PM -
Datas deletion from Global Temporary table when clear command is given
Dear All,
How to Delete datas from global temporary Table when clear command is given in forms
Suggest me syntax..
Pls help..
Regards,
Gokul.Bhttp://psoug.org/reference/gtt.html
Francois -
How can i create a Global Temporary Table inside a Stored Procedure....
Hi...
I need to create a Global Temporary Table inside a Stored
Procedure....
I have no idea how to do that....
Please....if u can send me a sample, send to me....
Thanks a lotTo create a global temporary table inside a stored procedure,
the minimal syntax would be:
CREATE OR REPLACE PROCEDURE procedure_name
AS
BEGIN
EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE table_name'
|| '(column_name NUMBER)';
END procedure_name;
As Todd stated, it would probably be better to create the global
temporary table outside of the procedure:
SQL> CREATE GLOBAL TEMPORARY TABLE table_name
2 (column_name NUMBER);
Table created.
You can also specify things like ON COMMIT PRESERVE ROWS or ON
COMMIT DELETE ROWS.
It may be that there is something else, like a PL/SQL table of
records or a cursor, that would suit your needs better. It is
difficult to guess without knowing what you want to do with it. -
How Create a Global Temporary Table inside a Stored Procedure?
Hi...
I need to create a Global Temporary Table inside a Stored
Procedure....
I have no idea how to do that....
Please....if u can send me a sample, send to me....
Thanks a lotthere are many ways to do this..
one u can use dbms_utility package to run ddl statements like
for ex:
declare
t varchar2(200):='order_no';
v number;
begin
--dbms_utility.exec_ddl_statement('select '||t||' into '||v||'
from
--ordermaster where rownum=1');
dbms_utility.exec_ddl_statement('create table cvt(t number)');
dbms_output.put_line(v);
end;
but the actual method(recommended) involves a bit coding using
dbms_sql package you will find examples on technet or metalink
to use this package..
I hope this helps
Narendra -
ORA-00955 reports when I try to "create global temporary table" in windows
Hi,
When I try to run the sql in my oracle 9i server which is installed in a windows2000 machine,
Create global temporary table test ...;
For the first time, I can create table successfully.
But I cannot access this table any more:
drop table test;
desc test;
select * from test;
In addition, if I try to create the table again, I got the error:
ORA-00955: name is already used by an existing object
While the same table can be created and dropped in another oracle9i server which is installed in Solaris 9 machine.
So I suspect that this sould be a bug of window oracle server.
Is there anyone who can confirm this?
Or who can tell me how to report this bug to oracle?
Thanks in advance.
Please also refer the message at:
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:1046974576560
If you search the text: "create global temporary table sess_event", you can see for the first time, the table is created successfully.
But the ORA-00955 reports when the author try to create table for the second time.
This problem is exactly the same as my problem.
I have also made a search both in Google and in Oracle website and I cannot find any solution of it.Read Metalink Note:68098.1 Subject: Overview of Temporary Tables
How did you difine the temporary tables? on commit delete rows are reserv rows?
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg03sch.htm#7794
Jaffar
Message was edited by:
The Human Fly -
How we cn avoid the sequence in remote tables through global temporary tabl
Hi,
We have table xx_interface_qualifiers in the remote db and we are inserting the data like this and its on a loop
INSERT INTO xx_interface_qua
(interface_id,
list_line_interface_id, excluder_flag,
qualifier_context, qualifier_attribute,
qualifier_attr_value, qualifier_precedence,
comparison_operator_code, start_date_active,
end_date_active, list_header_name, list_line_no,
creation_date, created_by, last_update_date,
last_updated_by, interface_attribute1
VALUES (xx_interface_qua_s.NEXTVAL,
ttt, 'Y',
xxx, xxx2,
xxx3, xxx4,
'=', SYSDATE,
NULL, xxx4, -1,
SYSDATE, '-1', SYSDATE,
'-1', 44 );
We are trying to avoid the hitting of the database every time for a sequence and try to implement the global temporary tables,i mean to say 1st we need to insert the data to TEMP table and then from temp table we cn inseert all the data to xx_interface_qual in a single shot to improve the performance.
But how we cn avoid the sequence in this case as we do not know the sequence in remote side.
Please suggest any other way to improve the performance.
Regards
Das797846 wrote:
We have table xx_interface_qualifiers in the remote db and we are inserting the data like this and its on a loop
We are trying to avoid the hitting of the database every time for a sequence and try to implement the global temporary tables,i mean to say 1st we need to insert the data to TEMP table and then from temp table we cn inseert all the data to xx_interface_qual in a single shot to improve the performance.
But how we cn avoid the sequence in this case as we do not know the sequence in remote side.Does not make sense. I/O is the slowest database operation.
You have an unknown performance problem (that you claim is due to a sequence, but failed to provide any evidence for). Now you want to create more I/O, by writing the data twice. Once into a temp table and then again into the destination table. And do that in order to increase performance?
I do not see how this can solve the underlying, and unknown, performance issue that you claim exists.
Any problem solution needs to start with correctly and comprehensively identifying the problem.
You cannot solve a problem without first knowing WHAT the problem is. -
How to create index on XMLTYPE ordered collection table?
I am using Oracle 11.2.0.2.
Essentially, my XML documents have a 3-level hierarchy:
event
+---action [1:n]
+---- param [1:n]
I am trying to create indexes on ordered collection tables, but can not get the syntax right...
I have created a table with an object-relational XMLType column:
CREATE TABLE T_C_RMP_MNTRNG_XML_FULL_IL4 (
MESSAGE_ID NUMBER(22,0) NOT NULL ENABLE,
XML_EVAL_ID NUMBER(22,0),
VIN7 VARCHAR2(7 BYTE),
FLEET_ID VARCHAR2(50 BYTE),
CSC_SW_VERSION VARCHAR2(100 BYTE),
RECEIVED DATE,
XML_CONTENT SYS.XMLTYPE ,
DWH_LM_TS_UTC DATE NOT NULL ENABLE,
CONSTRAINT PK_C_RMP_MNTRNG_XML_FULL_IL4 PRIMARY KEY (MESSAGE_ID)
) NOLOGGING TABLESPACE CATALOG
VARRAY "XML_CONTENT"."XMLDATA"."action" STORE AS TABLE "T_OR_MON_ACTION" (
NOLOGGING TABLESPACE "CATALOG"
VARRAY "param" STORE AS TABLE "T_OR_MON_ACTION_PARAM" (
NOLOGGING TABLESPACE "CATALOG"
) RETURN AS LOCATOR
) RETURN AS LOCATOR
XMLTYPE XML_CONTENT STORE AS OBJECT RELATIONAL XMLSCHEMA "http://mydomain.com/cs.xsd" ELEMENT "monitoring";
I am running the following SELECT:
SELECT EVENT_ID, ACTION_SUB_ID, MESSAGE_ID, ACTION_TYPE, UNIXTS_TO_DATE(ACTION_TIMESTAMP) ACTION_TIMESTAMP
FROM T_C_RMP_MNTRNG_XML_FULL_IL4,
XMLTABLE(
'for $i1 in /monitoring ,
$i2 in $i1/action
return element r {
$i1/eventId,
$i2
PASSING XML_CONTENT COLUMNS
EVENT_ID VARCHAR(40) PATH 'eventId',
ACTION_SUB_ID INTEGER PATH 'action/actionSubId',
ACTION_TYPE VARCHAR2(100) PATH 'action/type',
ACTION_TIMESTAMP NUMBER(13,0) PATH 'action/time'
) T2
WHERE (
EVENT_ID IS NOT NULL AND ACTION_SUB_ID IS NOT NULL
The explain plan looks like this (sorry, don't know how to get this formatted any "eye-friendlier"):
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1609K| 6316M| | 6110K (1)| 20:22:11 |
|* 1 | HASH JOIN | | 1609K| 6316M| 111M| 6110K (1)| 20:22:11 |
| 2 | TABLE ACCESS FULL| T_C_RMP_MNTRNG_XML_FULL_IL4 | 582K| 104M| | 5241 (1)| 00:01:03 |
|* 3 | TABLE ACCESS FULL| T_OR_MON_ACTION | 32M| 117G| | 105K (2)| 00:21:08 |
Predicate Information (identified by operation id):
1 - access("NESTED_TABLE_ID"="T_C_RMP_MNTRNG_XML_FULL_IL4"."SYS_NC0001300014$")
filter(CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(SYS_XQEXTRACT(XMLCONCAT(SYS_XMLGEN("T_C_RMP_MNTRN
G_XML_FULL_IL4"."SYS_NC00017$",NULL,SYS_XMLCONV("T_C_RMP_MNTRNG_XML_FULL_IL4"."SYS_NC00012$",0,32,
'EC1EEF23FD023A27E04032A06D930A8D',3,3783,1)),SYS_MAKEXML('EC1EEF23FD023A27E04032A06D930A8D',3780,
"T_C_RMP_MNTRNG_XML_FULL_IL4"."SYS_NC00008$","SYS_ALIAS_0"."SYS_NC_ROWINFO$")),'/eventId',NULL),0,
0,20971520,0),50,1,2) AS VARCHAR(40) ) IS NOT NULL)
3 - filter(CAST(TO_NUMBER(TO_CHAR("SYS_ALIAS_0"."actionSubId")) AS INTEGER ) IS NOT NULL)
Note
- dynamic sampling used for this statement (level=2)
- Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)
The XML schema looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns:oraxdb="http://xmlns.oracle.com/xdb" oraxdb:storeVarrayAsTable="true" oraxdb:flags="2105639" oraxdb:schemaURL="http://mydomain.com/cs.xsd" oraxdb:schemaOwner="MYUSER" oraxdb:numProps="23">
<xs:element name="monitoring" oraxdb:propNumber="3785" oraxdb:global="true" oraxdb:SQLName="monitoring" oraxdb:SQLType="monitoring755_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:defaultTable="monitoring757_TAB" oraxdb:defaultTableSchema="MYUSER">
<xs:complexType oraxdb:SQLType="monitoring755_T" oraxdb:SQLSchema="MYUSER">
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="action" oraxdb:propNumber="3780" oraxdb:global="false" oraxdb:SQLName="action" oraxdb:SQLType="action752_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false" oraxdb:SQLCollType="action756_COLL" oraxdb:SQLCollSchema="MYUSER"/>
<xs:element ref="reservationType" oraxdb:propNumber="3781" oraxdb:global="false" oraxdb:SQLName="reservationType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
<xs:element ref="softwareVersion" oraxdb:propNumber="3782" oraxdb:global="false" oraxdb:SQLName="softwareVersion" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
<xs:element ref="eventId" oraxdb:propNumber="3783" oraxdb:global="false" oraxdb:SQLName="eventId" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
<xs:element ref="vin" oraxdb:propNumber="3784" oraxdb:global="false" oraxdb:SQLName="vin" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="action" oraxdb:propNumber="3790" oraxdb:global="true" oraxdb:SQLName="action" oraxdb:SQLType="action752_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:defaultTable="action754_TAB" oraxdb:defaultTableSchema="MYUSER">
<xs:complexType oraxdb:SQLType="action752_T" oraxdb:SQLSchema="MYUSER">
<xs:sequence>
<xs:element ref="type" oraxdb:propNumber="3786" oraxdb:global="false" oraxdb:SQLName="type" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
<xs:element maxOccurs="unbounded" ref="param" oraxdb:propNumber="3787" oraxdb:global="false" oraxdb:SQLName="param" oraxdb:SQLType="param749_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false" oraxdb:SQLCollType="param753_COLL" oraxdb:SQLCollSchema="MYUSER"/>
<xs:element ref="actionSubId" oraxdb:propNumber="3788" oraxdb:global="false" oraxdb:SQLName="actionSubId" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
<xs:element ref="time" oraxdb:propNumber="3789" oraxdb:global="false" oraxdb:SQLName="time" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="type" type="xs:string" oraxdb:propNumber="3791" oraxdb:global="true" oraxdb:SQLName="type" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="type751_TAB" oraxdb:defaultTableSchema="MYUSER"/>
<xs:element name="param" oraxdb:propNumber="3794" oraxdb:global="true" oraxdb:SQLName="param" oraxdb:SQLType="param749_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:defaultTable="param750_TAB" oraxdb:defaultTableSchema="MYUSER">
<xs:complexType oraxdb:SQLType="param749_T" oraxdb:SQLSchema="MYUSER">
<xs:sequence>
<xs:element minOccurs="0" ref="value" oraxdb:propNumber="3792" oraxdb:global="false" oraxdb:SQLName="value" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
<xs:element ref="key" oraxdb:propNumber="3793" oraxdb:global="false" oraxdb:SQLName="key" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="value" type="xs:string" oraxdb:propNumber="3795" oraxdb:global="true" oraxdb:SQLName="value" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="value748_TAB" oraxdb:defaultTableSchema="MYUSER"/>
<xs:element name="key" type="xs:string" oraxdb:propNumber="3796" oraxdb:global="true" oraxdb:SQLName="key" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="key747_TAB" oraxdb:defaultTableSchema="MYUSER"/>
<xs:element name="actionSubId" type="xs:integer" oraxdb:propNumber="3797" oraxdb:global="true" oraxdb:SQLName="actionSubId" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:defaultTable="actionSubId746_TAB" oraxdb:defaultTableSchema="MYUSER"/>
<xs:element name="time" type="xs:integer" oraxdb:propNumber="3798" oraxdb:global="true" oraxdb:SQLName="time" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:defaultTable="time745_TAB" oraxdb:defaultTableSchema="MYUSER"/>
<xs:element name="reservationType" type="xs:string" oraxdb:propNumber="3799" oraxdb:global="true" oraxdb:SQLName="reservationType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="reservationType744_TAB" oraxdb:defaultTableSchema="MYUSER"/>
<xs:element name="softwareVersion" type="xs:string" oraxdb:propNumber="3800" oraxdb:global="true" oraxdb:SQLName="softwareVersion" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="softwareVersion743_TAB" oraxdb:defaultTableSchema="MYUSER"/>
<xs:element name="eventId" type="xs:string" oraxdb:propNumber="3801" oraxdb:global="true" oraxdb:SQLName="eventId" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="eventId742_TAB" oraxdb:defaultTableSchema="MYUSER"/>
<xs:element name="vin" type="xs:string" oraxdb:propNumber="3802" oraxdb:global="true" oraxdb:SQLName="vin" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="vin741_TAB" oraxdb:defaultTableSchema="MYUSER"/>
</xs:schema>
How can I create an index on these ordered collection tables in order to improve performance?
I found the example at http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb_rewrite.htm#ADXDB5859 but am not able to apply it to this particular case...
Thank you in advance...If the schema is not annotated then xs:integer and xs:string are mapped to NUMBER and VARCHAR2(4000) datatypes, so you have to use those in your query in order to avoid unnecessary typecasting operations.
You should also use chained XMLTABLEs when accessing a parent/child relationship instead of a FLWOR expression, otherwise the CBO may not rewrite the XQuery correctly (maybe it's fixed in the latest release).
If you make those changes, the plan should show cleaner predicates :
SQL> SELECT EVENT_ID, ACTION_SUB_ID, MESSAGE_ID, ACTION_TYPE, ACTION_TIMESTAMP
2 FROM test_table,
3 XMLTABLE('/monitoring'
4 PASSING XML_CONTENT COLUMNS
5 EVENT_ID VARCHAR2(4000) PATH 'eventId',
6 actions XMLTYPE PATH 'action'
7 ) T1,
8 XMLTABLE('/action'
9 PASSING actions COLUMNS
10 ACTION_SUB_ID NUMBER PATH 'actionSubId',
11 ACTION_TYPE VARCHAR2(4000) PATH 'type',
12 ACTION_TIMESTAMP NUMBER PATH 'time'
13 ) T2
14 WHERE EVENT_ID IS NOT NULL
15 AND ACTION_SUB_ID IS NOT NULL
16 ;
Execution Plan
Plan hash value: 1763884463
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 109 | 220K| 6 (17)| 00:00:01 |
| 1 | MERGE JOIN | | 109 | 220K| 6 (17)| 00:00:01 |
|* 2 | TABLE ACCESS BY INDEX ROWID| TEST_TABLE | 11 | 352 | 2 (0)| 00:00:01 |
| 3 | INDEX FULL SCAN | SYS_C007567 | 11 | | 1 (0)| 00:00:01 |
|* 4 | SORT JOIN | | 109 | 216K| 4 (25)| 00:00:01 |
|* 5 | TABLE ACCESS FULL | T_OR_MON_ACTION | 109 | 216K| 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter("TEST_TABLE"."SYS_NC00012$" IS NOT NULL)
4 - access("SYS_ALIAS_0"."NESTED_TABLE_ID"="TEST_TABLE"."SYS_NC0000800009$")
filter("SYS_ALIAS_0"."NESTED_TABLE_ID"="TEST_TABLE"."SYS_NC0000800009$")
5 - filter("SYS_ALIAS_0"."actionSubId" IS NOT NULL)
Note
- dynamic sampling used for this statement (level=2)
Now, if still necessary, it all boils down to choosing a technique to index NULL values :
- composite index with a not null or constant column
- FBI
- bitmap
Pick one that best fits your data, selectivity and activity on the tables. -
How can i write the trigger for Global Temporary Table
Hi Grus,
How can i write the trigger for Global Temporary Table.
I was created the GTT with trigger using the below script .
CREATE GLOBAL TEMPORARY TABLE GLOBAL_TEMP
EMP_C_NAME VARCHAR2(20 BYTE)
ON COMMIT PRESERVE ROWS;
CREATE OR REPLACE TRIGGER TRI_GLOBAL_TEMP
BEFORE DELETE OR UPDATE OR INSERT
ON GLOBAL_TEMP
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
INSERT INTO EMPNAME VALUES (:OLD.EMP_C_NAME);
END;
trigger was create successfully, but the wouldn't insert into to EMPNAME Table..
Please guide whether am correct or not? if not kindly give a correct syntax with example
Thanks in Advance,
Arun M MBEGIN
INSERT INTO EMPNAME VALUES (:OLD.EMP_C_NAME);
END;
you are referencing old value in insert stmt.
BEGIN
INSERT INTO EMPNAME VALUES (:new.EMP_C_NAME);
END;then run ur application it works fine...
CREATE GLOBAL TEMPORARY TABLE GLOBAL_TEMP
EMP_C_NAME VARCHAR2(20 BYTE)
ON COMMIT PRESERVE ROWS;
CREATE OR REPLACE TRIGGER TRI_GLOBAL_TEMP
BEFORE DELETE OR UPDATE OR INSERT
ON GLOBAL_TEMP
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
dbms_output.put_line(:OLD.EMP_C_NAME||'yahoo');
INSERT INTO EMPNAME VALUES (:new.EMP_C_NAME);
dbms_output.put_line(:OLD.EMP_C_NAME);
END;
create table EMPNAME as select * from GLOBAL_TEMP where 1=2
insert into GLOBAL_TEMP values('fgfdgd');
commit;
select * from GLOBAL_TEMP;
select * from EMPNAME;
output:
1 rows inserted
commit succeeded.
EMP_C_NAME
fgfdgd
1 rows selected
EMP_C_NAME
fgfdgd
1 rows selectedgot it Arun
Edited by: OraclePLSQL on Dec 28, 2010 6:07 PM
Maybe you are looking for
-
"Can't read or write to disk" error message
hi... got my husband a 16g nano and i'm trying to sync his songs. i have the newest version of itunes installed. it put almost half of the songs on the nano and all of a sudden itunes has an error that says something about "can't write to nano. disk
-
Bad Apple experience/turn off grifical extra;s leopard
So I give up! It started with my iBook a few weeks ago. A burned adapter. My Girl burn her fingers and a big flame came out of it (were lucky becouse we were home).. iBook dead, no service! Now my iMac has trouble. Greenblocks (ghost pixels) broken A
-
Recurring Vendor Invoice- Number range problem
I am trying to setup recurring invoice entry through FBD1 for my company code abcd. I entered KR as document type. I have already set up number range which is 03 for KR. after entering all field data on the first screen when I click on "first entry d
-
Will the iPhone 3G Universal Dock Adapter work with...
My 3Gen FW iPod dock? Anyone know? tia, e
-
Why can't I find Photoshop Elements 11 Photomerge under "File/New"
When I used Photoshop VERSION 10, I would do a Photomerge by selecting "File/New". Now that I have Photoshop VERSION 11, this option does not exist. What happened to it? How can I do a photomerge with this latest version of the product? Thanks,