'IS NOT NULL' & Index Usage
Hi,
there are many queries my one of my packages, which has the SQL as follows:
Update table XYZ
Set Column A = NULL
Where Colum B IS NOT NULL;
Column B has NUMBER datatype.
Due to 'IS NOT NULL' the index (existing for Column B' is not being used in the above query, leading to Full table scan. Is there any ways of forcing teh index to be picked/used by the query?
Thanks,
Rosalin
thansk again for response. Checked the % of the data
fetched by this query and it ranges from 20% to 50
%(varies due to teh fact the table data content could
have different set of data depending on the days
transactions done). So for sure index usage would
help.
Additionally this sql(used in multiple places) come
up in the v$longsops output.
so definitely needs tuning.
Any suggestions?That's not really true though if you understand the mechanisms employed for a full table scan vs an index scan / table lookup (by rowid since the table must also be visited).
Here's something good for you to read
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4433887271030
A full tablescan reads the table using large sequential reads -- many blocks at a time.
Sequential reads are the fastest type of IO you can do on a disk in general.
An index read will do single block, random IO's. These are generally the slowest you can
do.
I would suggest to you that if you have statistics on the table/indexes that are representative of the data, the Optimizer will be smarter than you (most cases, not all).
Message was edited by:
Tubby
Similar Messages
-
Function-based index, NOT NULL bug?
ALTER SESSION SET OPTIMIZER_MODE = FIRST_ROWS_10;
ALTER SESSION SET QUERY_REWRITE_ENABLED = TRUE;
CREATE TABLE xxx (code CHAR(6) NOT NULL);
create index xxx_idx on xxx (upper(code));
select * from xxx order by upper(code);
-> ORA-03113: end-of-file on communication channel
(Oracle 9.0.1, Windows 2000)I know it's quite a long-time that anyone replied this post, but I just need to report our attempts to workaround that.
Dropping function-based indexes in primary database, just before creation of Logical Dataguard hasn't solved our problem, neither dropping indexes in logical database.
In my opinion and after some docs in metalink, I think there's no way to solve it.
Or you drop them or you migrate to 10g.
Regards. -
Hi, I am trying to properly display a list of tasks for a project however without a join to the project number (which I was aware of) and the employee table, I get over 500 results.
The task can be created without a employee assigned to it so therefore the page does not require the field to be filled in.
Here is the SQL code, any does anyone have any ideas?
select
pd.pk_proj_detail_id "Task Number",
pd.task_title "Task Title",
pd.DETAIL_STATUS "Task Status",
pm.name "Associated Project",
pps.last_name||', '||pps.first_name||', '||pps.middle_initial||'.' "Assigned Employee",
pd.TRACKIT_NUMBER "TrackIt! Number",
pd.CREATEBY_DATE "Date Entered",
pd.DATE_BEGIN "Date Began",
pd.ESTIMATED_DATE "Estimated Completion Date",
pd.DATE_END "Date Completed"
from
PROTRAC_DETAIL pd,
protrac_master pm,
cobr.vw_pps_payroll pps,
resources r
where
pd.fk_proj_master_id = pm.PK_PROJ_MASTER_ID
and r.fk_master_id = pm.PK_PROJ_MASTER_ID
and (r.emp_id = pps.emple_no
or r.emp_id is null)It's 10g r2 with Application Express 3.1.0.00.32
This is the tasks (detail) table
ALTER TABLE PROTRAC_DETAIL
DROP PRIMARY KEY CASCADE;
DROP TABLE PROTRAC_DETAIL CASCADE CONSTRAINTS;
CREATE TABLE PROTRAC_DETAIL
PK_PROJ_DETAIL_ID NUMBER NOT NULL,
FK_PROJ_MASTER_ID NUMBER,
TRACKIT_NUMBER NUMBER,
DETAIL_DESCRIPTION VARCHAR2(4000 CHAR),
DETAIL_STATUS VARCHAR2(19 CHAR),
DETAIL_STATUS_COMMENT VARCHAR2(4000 CHAR),
DATE_BEGIN DATE,
DATE_END DATE,
ESTIMATED_DATE DATE,
CREATEBY_DATE DATE,
CREATEBY_USER VARCHAR2(50 CHAR),
LASTMOD_DATE DATE,
LASTMOD_USER VARCHAR2(50 CHAR),
TASK_TITLE VARCHAR2(100 CHAR)
TABLESPACE DEVPROTRAC_DATA
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
CREATE UNIQUE INDEX PROTRAC_DETAIL_PK ON PROTRAC_DETAIL
(PK_PROJ_DETAIL_ID)
TABLESPACE DEVPROTRAC_DATA
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
CREATE OR REPLACE TRIGGER BUI_PROTRAC_DETAIL
before insert or update
on PROTRAC_DETAIL
referencing new as New old as Old
for each row
begin
if inserting then
select users_seq.nextval, sysdate, apex_application.g_user
into :new.pk_proj_detail_id, :new.createby_date, :new.createby_user
from dual;
elsif updating then
select sysdate, apex_application.g_user
into :new.lastmod_date, :new.lastmod_user
from dual;
end if;
end;
SHOW ERRORS;
ALTER TABLE PROTRAC_DETAIL ADD (
CONSTRAINT PROTRAC_DETAIL_PK
PRIMARY KEY
(PK_PROJ_DETAIL_ID)
USING INDEX
TABLESPACE DEVPROTRAC_DATA
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
ALTER TABLE PROTRAC_DETAIL ADD (
CONSTRAINT PROTRAC_DETAIL_NUM
FOREIGN KEY (FK_PROJ_MASTER_ID)
REFERENCES PROTRAC_MASTER (PK_PROJ_MASTER_ID));
ALTER TABLE DEVPROTRAC.RESOURCES ADD (
FOREIGN KEY (FK_DETAIL_ID)
REFERENCES DEVPROTRAC.PROTRAC_DETAIL (PK_PROJ_DETAIL_ID));
SET DEFINE OFF;
Insert into PROTRAC_DETAIL
(PK_PROJ_DETAIL_ID, FK_PROJ_MASTER_ID, TRACKIT_NUMBER, DETAIL_DESCRIPTION, DETAIL_STATUS,
DETAIL_STATUS_COMMENT, DATE_BEGIN, DATE_END, ESTIMATED_DATE, CREATEBY_DATE,
CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, TASK_TITLE)
Values
(34, 24, NULL, 'test', 'Queued',
NULL, NULL, NULL, NULL, TO_DATE('10/30/2008 13:37:01', 'MM/DD/YYYY HH24:MI:SS'),
'LREDMOND', TO_DATE('11/03/2008 15:19:35', 'MM/DD/YYYY HH24:MI:SS'), NULL, 'bananana');
Insert into PROTRAC_DETAIL
(PK_PROJ_DETAIL_ID, FK_PROJ_MASTER_ID, TRACKIT_NUMBER, DETAIL_DESCRIPTION, DETAIL_STATUS,
DETAIL_STATUS_COMMENT, DATE_BEGIN, DATE_END, ESTIMATED_DATE, CREATEBY_DATE,
CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, TASK_TITLE)
Values
(41, 40, NULL, '2354234', 'Queued',
NULL, NULL, NULL, NULL, TO_DATE('10/31/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'),
'LREDMOND', TO_DATE('11/03/2008 13:52:02', 'MM/DD/YYYY HH24:MI:SS'), 'LREDMOND', 'I can type on the keyboarddf');
Insert into PROTRAC_DETAIL
(PK_PROJ_DETAIL_ID, FK_PROJ_MASTER_ID, TRACKIT_NUMBER, DETAIL_DESCRIPTION, DETAIL_STATUS,
DETAIL_STATUS_COMMENT, DATE_BEGIN, DATE_END, ESTIMATED_DATE, CREATEBY_DATE,
CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, TASK_TITLE)
Values
(49, 32, 78888, 'one day fishsticks will walk on the moon.', 'Queued',
'waiting for fishsticks.', NULL, NULL, NULL, TO_DATE('11/03/2008 11:28:11', 'MM/DD/YYYY HH24:MI:SS'),
'LREDMOND', NULL, NULL, 'Fix the keyboard');
Insert into PROTRAC_DETAIL
(PK_PROJ_DETAIL_ID, FK_PROJ_MASTER_ID, TRACKIT_NUMBER, DETAIL_DESCRIPTION, DETAIL_STATUS,
DETAIL_STATUS_COMMENT, DATE_BEGIN, DATE_END, ESTIMATED_DATE, CREATEBY_DATE,
CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, TASK_TITLE)
Values
(50, 38, NULL, 'dfdfdfdfdfdfdfdfdf', 'Queued',
NULL, NULL, NULL, NULL, TO_DATE('11/03/2008 12:03:06', 'MM/DD/YYYY HH24:MI:SS'),
'LREDMOND', TO_DATE('11/03/2008 15:19:44', 'MM/DD/YYYY HH24:MI:SS'), NULL, 'resreeeeeeeeee');
Insert into PROTRAC_DETAIL
(PK_PROJ_DETAIL_ID, FK_PROJ_MASTER_ID, TRACKIT_NUMBER, DETAIL_DESCRIPTION, DETAIL_STATUS,
DETAIL_STATUS_COMMENT, DATE_BEGIN, DATE_END, ESTIMATED_DATE, CREATEBY_DATE,
CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, TASK_TITLE)
Values
(33, 31, NULL, 'Make sure the bananas are fresh', 'Queued',
NULL, NULL, NULL, NULL, TO_DATE('10/29/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'),
'LREDMOND', TO_DATE('11/03/2008 15:19:52', 'MM/DD/YYYY HH24:MI:SS'), NULL, 'e543563465');
Insert into PROTRAC_DETAIL
(PK_PROJ_DETAIL_ID, FK_PROJ_MASTER_ID, TRACKIT_NUMBER, DETAIL_DESCRIPTION, DETAIL_STATUS,
DETAIL_STATUS_COMMENT, DATE_BEGIN, DATE_END, ESTIMATED_DATE, CREATEBY_DATE,
CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, TASK_TITLE)
Values
(48, 37, NULL, 'guitar heros! yay', 'Queued',
NULL, NULL, NULL, NULL, TO_DATE('11/03/2008 11:26:06', 'MM/DD/YYYY HH24:MI:SS'),
'LREDMOND', TO_DATE('11/03/2008 15:19:57', 'MM/DD/YYYY HH24:MI:SS'), NULL, '34444444444444543etfg');
COMMIT;This is for the resources table:
ALTER TABLE RESOURCES
DROP PRIMARY KEY CASCADE;
DROP TABLE RESOURCES CASCADE CONSTRAINTS;
CREATE TABLE RESOURCES
PK_RESOURCES_ID NUMBER,
FK_DETAIL_ID NUMBER,
EMP_ID NUMBER,
RESOURCE_STATUS VARCHAR2(8 CHAR),
RESOURCE_COMMENT VARCHAR2(4000 CHAR),
CREATEBY_DATE DATE,
CREATEBY_USER VARCHAR2(50 CHAR),
LASTMOD_DATE DATE,
LASTMOD_USER VARCHAR2(50 CHAR),
FK_MASTER_ID NUMBER
TABLESPACE DEVPROTRAC_DATA
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
CREATE UNIQUE INDEX RESOURCES_PK ON RESOURCES
(PK_RESOURCES_ID)
TABLESPACE DEVPROTRAC_DATA
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
CREATE OR REPLACE TRIGGER BUI_RESOURCES
before insert or update
on RESOURCES
referencing new as New old as Old
for each row
begin
if inserting then
select users_seq.nextval, sysdate, apex_application.g_user
into :new.pk_resources_id, :new.createby_date, :new.createby_user
from dual;
elsif updating then
select sysdate, apex_application.g_user
into :new.lastmod_date, :new.lastmod_user
from dual;
end if;
end;
SHOW ERRORS;
ALTER TABLE RESOURCES ADD (
CONSTRAINT RESOURCES_PK
PRIMARY KEY
(PK_RESOURCES_ID)
USING INDEX
TABLESPACE DEVPROTRAC_DATA
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
ALTER TABLE RESOURCES ADD (
FOREIGN KEY (FK_DETAIL_ID)
REFERENCES PROTRAC_DETAIL (PK_PROJ_DETAIL_ID),
FOREIGN KEY (FK_MASTER_ID)
REFERENCES PROTRAC_MASTER (PK_PROJ_MASTER_ID));
SET DEFINE OFF;
Insert into RESOURCES
(PK_RESOURCES_ID, FK_DETAIL_ID, EMP_ID, RESOURCE_STATUS, RESOURCE_COMMENT,
CREATEBY_DATE, CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, FK_MASTER_ID)
Values
(53, 50, 356654, 'Active', NULL,
TO_DATE('11/04/2008 09:32:06', 'MM/DD/YYYY HH24:MI:SS'), 'LREDMOND', NULL, NULL, NULL);
Insert into RESOURCES
(PK_RESOURCES_ID, FK_DETAIL_ID, EMP_ID, RESOURCE_STATUS, RESOURCE_COMMENT,
CREATEBY_DATE, CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, FK_MASTER_ID)
Values
(51, 41, 447250, 'Active', 'No Sure.',
TO_DATE('11/03/2008 14:23:11', 'MM/DD/YYYY HH24:MI:SS'), NULL, TO_DATE('11/04/2008 09:00:04', 'MM/DD/YYYY HH24:MI:SS'), NULL, 40);
Insert into RESOURCES
(PK_RESOURCES_ID, FK_DETAIL_ID, EMP_ID, RESOURCE_STATUS, RESOURCE_COMMENT,
CREATEBY_DATE, CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, FK_MASTER_ID)
Values
(54, 50, 323829, 'Active', NULL,
TO_DATE('11/04/2008 10:26:08', 'MM/DD/YYYY HH24:MI:SS'), 'LREDMOND', NULL, NULL, 38);
Insert into RESOURCES
(PK_RESOURCES_ID, FK_DETAIL_ID, EMP_ID, RESOURCE_STATUS, RESOURCE_COMMENT,
CREATEBY_DATE, CREATEBY_USER, LASTMOD_DATE, LASTMOD_USER, FK_MASTER_ID)
Values
(52, 33, 8915, 'Active', 'get to work',
TO_DATE('11/03/2008 15:20:18', 'MM/DD/YYYY HH24:MI:SS'), 'LREDMOND', TO_DATE('11/03/2008 15:35:10', 'MM/DD/YYYY HH24:MI:SS'), NULL, NULL);
COMMIT;The results I want is everything above regardless of emp_id assigned (if any). Without the r.emp_id = pps.emple_no join, the query will generate 234234239482304234 results.
Hope this helps.
Edited by: leland on Nov 4, 2008 12:56 PM -
I have a performance issue with a query - it would be something like -
select col1,col2, sum(col3), get_val(col_4)
from table1
where
get_val(col_4) is not null
group by col1,col2, get_val(col_4)
I have simplified this but it is something similar. This works great - performance is great. Now I commented out the where clause as I needed to populate null values - and that's it the query does not retrieve the resultset - it keeps running forever. With the where clause it comes back in 60 seconds. There is only one row out of 560 rows that has null value for col_4 which i need to display.
Any help is appreciated.The only difference I notice between the two sqls is HASH(UNIQUE) -
with IS NOT NULL in where clause -
SELECT STATEMENT ALL_ROWS 1598 1 209
HASH(UNIQUE) 1598 1 209
HASH(GROUP BY) 1598 1 209
When is not null is removed from the where clause -
SELECT STATEMENT ALL_ROWS 1598 1 206
HASH(GROUP BY) 1598 1 206
I'm guessing that the index is being used in the first scenario and not in the second. Any idea/suggestion as to how to over come this?
Thanks -
UNUSED EXISTING INDEXES / Index usage
We are using CRM 2007, Netweaver 7.0 with DB2 UDB v9.1 fixpack4 on AIX.
Is there a way to find out UNUSED EXISTING INDEXES for tables ? We have close 12 indexes on the crmd_order_index table and want to find out if some of them can safely deleted. Is there any way to monitor index usage in SAP ? Is there any toold to aid this ?
Pls advise.
thank you
regards
LaxmiLaxmi,
I am not aware of any such tools with DB2 9.1. However, "last_used" columns are being added to various catalog tables in DB2 9.7. Below is an excerpt from a slide presented in the TLU2008A "DB2 LUW V9.7 Cobra u2013 Storage is Charmed" session.
The last reference time of an object will now be maintained in the LASTUSED column of
the corresponding catalog table for the object
u2013 SYSCAT.INDEXES.LASTUSED (prior to V9.7 db2pd u2013tcbstats indexes)
u2013 SYSCAT.TABLES.LASTUSED
u2013 SYSCAT.DATAPARTITIONS.LASTUSED
u2013 SYSCAT.PACKAGE.LASTUSED
The LASTUSED column is of type DATE (default value is 1/1/0001)
Use Cases:
u2013 Detach table partitions that are no longer actively used (esp. when not partitioned by time)
u2013 Determine inactive or infrequently used indexes
u2013 Easily identify tables which are no longer in use
u2013 Get rid of unused packages
The presenter said the code will begin populating these columns in an upcoming fixpack.
Regards,
Rick -
i am having a table in my schema named provider_rate_history
PROVIDER_RATE_HISTORY_ID NOT NULL NUMBER
WORK_ORDER_HISTORY_ID NOT NULL NUMBER
PROVIDER_RATE_TYPE_ID NOT NULL NUMBER
CREATED_BY NOT NULL NUMBER
DATE_CREATED NOT NULL DATE
MODIFIED_BY NUMBER
DATE_MODIFIED DATE
I created an index named provider_rate_type_idx on the provider_rate_type_id column of the table, but when i am using the following query index is used, but if i replace count(*) keyword in the select statement with any of the column name of the table a ful table scan is performed. What could be the reason for this error and how to correct it
select count(*) from provider_rate_history
where rate_type_id=7;
Index is used, if we replace count(*) with any column name of the table index is not used
select work_order_history_id from provider_rate_history
where rate_type_id=7;
Index is not usedHi,
Why count(*) will lead to full table scan?
APC have clearly told reason for not using Index.
Hope this illustration helps to clear the situation.
SQL> create table test111 as select * from all_objects where rownum < 1001;
Table created.
SQL> desc test111
Name Null? Type
OWNER NOT NULL VARCHAR2(30)
OBJECT_NAME NOT NULL VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NOT NULL NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED NOT NULL DATE
LAST_DDL_TIME NOT NULL DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
SQL> create index test111_indx1 on test111 (object_id);
Index created.
SQL>
SQL> set autotrace on
SQL> select count(1) from test111;
COUNT(1)
1000
Execution Plan
Plan hash value: 1326770390
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | INDEX FAST FULL SCAN| TEST111_INDX1 | 1000 | 3 (0)| 00:00:01 |
Note
- dynamic sampling used for this statement
Statistics
5 recursive calls
0 db block gets
23 consistent gets
3 physical reads
0 redo size
206 bytes sent via SQL*Net to client
239 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>
SQL> select count(distinct owner) from test111;
COUNT(DISTINCTOWNER)
3
Execution Plan
Plan hash value: 991123090
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 17 | 5 (0)| 00:00:01 |
| 1 | SORT GROUP BY | | 1 | 17 | | |
| 2 | TABLE ACCESS FULL| TEST111 | 1000 | 17000 | 5 (0)| 00:00:01 |
Note
- dynamic sampling used for this statement
Statistics
27 recursive calls
0 db block gets
33 consistent gets
0 physical reads
0 redo size
233 bytes sent via SQL*Net to client
239 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> -
Index Usage from SQL query in Oracle Forms
Would using LIKE/OR in where clause (of an indexed column) will force the the query to NOT use INDEX. We have these where clause in Oracle Forms Records Group.
Below are two examples...
1. If we have a where clause with LIKE would that NOT use the index?
Example: ColumnName like :block.Column||%
2. How about having an OR clause?
Example: and (ColumnName = :block.column or :block.column is null)
ThanksHi
Answer 1: Where with like clause WOULD use the index.
In this example index on ColumnName
Answer 2: Write better where:
Example: and (:block.column is null or ColumnName = :block.column)
When :block column is null then statement after 'or' is not used. Index will not be used with RBO, i think.
The best way to be sure is to look at explain plan on the original query.
Regards
Kuba -
BOOLEAN DEFAULT FALSE NOT NULL for key-column
Hello,
These statements show an unexpected behavior when a column is added to a table as 'BOOLEAN DEFAULT FALSE NOT NULL' and added afterward to the table's primary key column set:
create table test_1 (a char(1))
insert into test_1 values('A')
alter table test_1 add b boolean default false not null
alter table test_1 add primary key (a,b)
create table test_2 (a char(1), b boolean default false not null)
insert into test_2 (a) values('A')
alter table test_2 add foreign key f_test_1 (a,b) references test_1 (a,b)
-> [350]: Referential integrity violated
update test_1 set b=false
alter table test_2 add foreign key f_test_1 (a,b) references test_1 (a,b)
-> success
delete from test_2
delete from test_1
insert into test_1 (a,b) values('A',false)
insert into test_2 (a) values('A')
-> success
I think the error message '[350] Referential integrity violated' should not happen because the column 'b' really contains 'false'. But there obviously seem to be a difference before and after setting the column 'b' explicitly to 'false'. I can imagine that this depends on the way how the index for the primary key is updated. Probably the index is not properly updated in this context(?)
GabrielHi Gabriel,
you're right, this is a bug and indeed seems to caused by the way the DEFAULT boolean is stored in the page.
(There is no separate index for the primary key in MaxDB as all data is stored in B*trees - basically the table is the primary key).
This is how the record looks like when column b is 'false' only due to the change of the DEFAULT value:
ROOT/LEAF 460 perm entries : 1 [block 0]
bottom : 93 filevers: 14888 convvers: 83
writecnt: 1
1: (pos 00081)
00001 recLen : 12 recKeyLen : 4
00005 recVarcolOff: 0 recVarcolCnt: 0
record
1 2 3 4 5 6 7 8 9 10 11 12
81 82 83 84 85 86 87 88 89 90 91 92
dec: 12 0 4 0 0 0 0 0 32 65 0 0
hex: 0C 00 04 00 00 00 00 00 20 41 00 00
chr: A
And this is how it looks like after the explicit UPDATE:
ROOT/LEAF 460 perm entries : 1 [block 0]
bottom : 93 filevers: 14888 convvers: 84
writecnt: 2
1: (pos 00081)
00001 recLen : 11 recKeyLen : 3
00005 recVarcolOff: 0 recVarcolCnt: 0
record
1 2 3 4 5 6 7 8 9 10 11
81 82 83 84 85 86 87 88 89 90 91
dec: 11 0 3 0 0 0 0 0 32 65 0
hex: 0B 00 03 00 00 00 00 00 20 41 00
chr: A
Little difference but this leads to the problems during the foreign key validation.
I'll inform the developers next week about this.
As a workaround you'll have to explicitly update the columns for which you change the default setting.
regards,
Lars -
Hi,
I have a table
SQL> desc tabula.M$$USERS;
Name Null? Type
USERLOGIN NOT NULL VARCHAR2(20)
PASSWORD NOT NULL VARCHAR2(30)
T$USER NOT NULL NUMBER(38)
USERNAME NOT NULL VARCHAR2(30)
USERID NOT NULL NUMBER(38)
USERGROUP NOT NULL NUMBER(38)
T$LINKID NOT NULL VARCHAR2(50)
password column is not null.
Application get ORA-01400 (can't insert to null into not null colum) and also when I run -
Edited by: user10237262 on Nov 29, 2011 12:54 AMHi welcome to forum
see below example
SQL> create table t(empno number(4) not null, ename varchar2(10))
2 /
Table created.
SQL> insert into t values(100,'abc');
1 row created.
SQL> insert into t values(200,'def');
1 row created.
SQL> insert into t values(null,'def');
insert into t values(null,'def')
ERROR at line 1:
ORA-01400: cannot insert NULL into ("SYSTEM"."T"."EMPNO")
SQL> desc t
Name Null? Type
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
SQL>"Null?" tells the perticular column is null or not...
Usage
The description for tables, views, types and synonyms contains the following information:
each column's name
whether or not null values are allowed (NULL or NOT NULL) for each column
refer:
http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12019.htm
Edited by: newbie on Nov 29, 2011 12:54 AM -
Is their a difference between primary key and unique key with not null valu
What is the difference in having a column as primary key and having unique key with not null for the column.
vinodhSBH wrote:
For quick review, below is the link
http://www.dba-oracle.com/data_warehouse/clustered_index.htm
You appear to have stumbled on a site that is a mine of disinformation about Oracle.
>
It would be helpful, if you explain it too..thnx !!
The site is wrong and makes up its own terminology as it goes along.
If the value for clustering factor approaches the number of blocks in the base table, then the index is said to be clustered. http://www.oracle.com/pls/db112/search?remark=quick_search&word=clustered+index
There is no create clustered index in Oracle.
- Clustering factor affects the efficiency of an index.
- There can be clustered tables that you can create indexes on.
- An Index Organized table is a similar concept to the Microsoft SQL Server clustered index, but it isn't the same thing at all. -
Difference between Primary Key and Unique+Not NUll
Hi Guys,
Is there any difference the column being declared as primary key or unique+NOT NULL.
Please let me know the internal and application point of view.
Thanks in advance!
Ranjan957590 wrote:
Ok,Thanks however I donot think Primary key uses unique indexPK uses whatever index you specify - unique or not (as long as index is on proper column(s)). However, if you do not specify any index, PK creates unique index:
SQL> create table tbl(
2 id number,
3 name varchar2(10)
4 )
5 /
Table created.
SQL> alter table tbl
2 add constraint tbl_pk
3 primary key(
4 id
5 )
6 /
Table altered.
SQL> select index_name,
2 uniqueness
3 from user_indexes
4 where table_name = 'TBL'
5 /
INDEX_NAME UNIQUENES
TBL_PK UNIQUE
SQL> select constraint_name,
2 index_name
3 from user_constraints
4 where table_name = 'TBL'
5 /
CONSTRAINT_NAME INDEX_NAME
TBL_PK TBL_PK
SQL> alter table tbl
2 drop primary key
3 /
Table altered.
SQL> create index tbl_non_unique_pk_index
2 on tbl(
3 id
4 )
5 /
Index created.
SQL> alter table tbl
2 add constraint tbl_pk
3 primary key(
4 id
5 )
6 using index tbl_non_unique_pk_index
7 /
Table altered.
SQL> select index_name,
2 uniqueness
3 from user_indexes
4 where table_name = 'TBL'
5 /
INDEX_NAME UNIQUENES
TBL_NON_UNIQUE_PK_INDEX NONUNIQUE
SQL> select constraint_name,
2 index_name
3 from user_constraints
4 where table_name = 'TBL'
5 /
CONSTRAINT_NAME INDEX_NAME
TBL_PK TBL_NON_UNIQUE_PK_INDEX
SQL> insert
2 into tbl
3 values(
4 1,
5 'A'
6 )
7 /
1 row created.
SQL> insert
2 into tbl
3 values(
4 2,
5 'B'
6 )
7 /
1 row created.
SQL> insert
2 into tbl
3 values(
4 1,
5 'C'
6 )
7 /
insert
ERROR at line 1:
ORA-00001: unique constraint (SCOTT.TBL_PK) violated
SQL> SY. -
Filter(NULL IS NOT NULL) in Explain Plan ??
Hi All,
Can someone please explain what this explain plan statement means? I see a filter(NULL IS NOT NULL) as the first statement - could not figure out why it came up so from googling.
My Query Used:
EXPLAIN PLAN FOR
MERGE INTO summary_bysrccd
USING
(SELECT LAST_DAY(TRUNC(to_timestamp(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))) AS SUMMARY_DATE,
os.acctnum,
ol.sourcecode AS sourcecode,
ol.sourcename AS sourcename,
count(1) cnt_articleview
FROM article_views os , master_sourcecode ol
where os.sourcecode = ol.sourcecode
AND os.acctnum IS NOT NULL
AND ol.sourcecode IS NOT NULL
AND os.requestdatetime IS NOT NULL
AND UPPER(os.success_ind) = 'S'
AND (
('INCR' = 'FULL'
AND (get_date_timestamp(os.requestdatetime) BETWEEN TO_DATE('23-AUG-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('27-AUG-2011 23:59:59','DD-MON-YYYY HH24:MI:SS')
AND os.entry_CreatedDate BETWEEN TO_DATE('22-AUG-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('28-AUG-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
OR ('INCR' = 'FULL'
AND os.entry_createddate BETWEEN TO_DATE('23-AUG-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('27-AUG-2011 23:59:59','DD-MON-YYYY HH24:MI:SS') )
group by LAST_DAY(TRUNC(to_timestamp(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))),
os.acctnum,ol.sourcecode,ol.sourcename) mrg_query
ON (ods_av_summary_bysrccd.acctnum = mrg_query.acctnum AND
ods_av_summary_bysrccd.summary_date=mrg_query.summary_date AND
ods_av_summary_bysrccd.sourcecode=mrg_query.sourcecode)
WHEN NOT MATCHED THEN
INSERT (SUMMARY_date,ACCTNUM,SOURCECODE,SOURCENAME,CNT_ARTICLEVIEW,ENTRY_LASTUPDATEDDATE)
VALUES(mrg_query.summary_date,mrg_query.acctnum,mrg_query.sourcecode,mrg_query.sourcename,
mrg_query.cnt_articleview,sysdate)
WHEN MATCHED THEN
UPDATE SET ods_av_summary_bysrccd.cnt_articleview=
CASE WHEN NVL('INCR','INCR') = 'FULL' THEN mrg_query.cnt_articleview
ELSE ods_av_summary_bysrccd.cnt_articleview+mrg_query.cnt_articleview
END,
ods_av_summary_bysrccd.entry_lastupdateddate=sysdate;My Explain Plan:
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 268591246
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
| 0 | MERGE STATEMENT | | 1 | 456 | | 3 (0)| 00:00:01 | | |
| 1 | MERGE | ODS_AV_SUMMARY_BYSRCCD | | | | | | | |
| 2 | VIEW | | | | | | | | |
| 3 | NESTED LOOPS OUTER | | 1 | 417 | | 3 (0)| 00:00:01 | | |
| 4 | VIEW | | 1 | 360 | | 5 (100)| 00:00:01 | | |
| 5 | SORT GROUP BY | | 1 | 73 | 595M| | | | |
PLAN_TABLE_OUTPUT
|* 6 | FILTER | | | | | | | | |
|* 7 | HASH JOIN | | 6975K| 485M| 3944K| 17594 (1)| 00:03:32 | | |
| 8 | TABLE ACCESS FULL | ODS_MASTER_SOURCECODE | 84021 | 2953K| | 273 (1)| 00:00:04 | | |
|* 9 | TABLE ACCESS BY GLOBAL INDEX ROWID| ODS_ARTICLE_VIEWS | 7007K| 247M| | 826 (0)| 00:00:10 | 33 | 33 |
|* 10 | INDEX FULL SCAN | IDX_AV_ACCTNUM | 25M| | | 26 (0)| 00:00:01 | | |
| 11 | TABLE ACCESS BY GLOBAL INDEX ROWID | ODS_AV_SUMMARY_BYSRCCD | 1 | 57 | | 3 (0)| 00:00:01 | ROWID | ROWID |
|* 12 | INDEX UNIQUE SCAN | ODS_AV_SUMMARY_BYSRCCD_PK | 1 | | | 2 (0)| 00:00:01 | | |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
6 - filter(NULL IS NOT NULL)
7 - access("OS"."SOURCECODE"="OL"."SOURCECODE")
9 - filter("OS"."REQUESTDATETIME" IS NOT NULL AND "OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-08-23 00:00:00', 'syyyy-mm-dd
hh24:mi:ss') AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE(' 2011-08-27 23:59:59', 'syyyy-mm-dd hh24:mi:ss') AND UPPER("OS"."SUCCESS_IND")='S')
10 - filter("OS"."ACCTNUM" IS NOT NULL)
12 - access("ODS_AV_SUMMARY_BYSRCCD"."SUMMARY_DATE"(+)=INTERNAL_FUNCTION("MRG_QUERY"."SUMMARY_DATE") AND
"ODS_AV_SUMMARY_BYSRCCD"."ACCTNUM"(+)="MRG_QUERY"."ACCTNUM" AND "ODS_AV_SUMMARY_BYSRCCD"."SOURCECODE"(+)="MRG_QUERY"."SOURCECODE")
Note
PLAN_TABLE_OUTPUT
- dynamic sampling used for this statementHi Toon,
Thanks for the quick resolution. I went back and verified the table's colunm details and it has a NOT NULL constraint.
Regards,
Chaitanya
P.S: Is it ok if I ask you for some help regarding a production issue I have been encountering since 15 days but haev no clear resolution yet about what/why is the reason (the said issue is neither uniform nor regular - its affecting some modules and happening on some days - i shall give the full details if you are willing to have a look) - i shall start a new post or email you directly - yur convenience. -
Hi,
I am trying toceate an interface which collects data from database make some transformation and populated seeded tables in the same database.
My Approach is :
a) Create a record type variable ( concists of multiple segments)
b) Create a pl/sql table type of the records type in a)
c) Created a cursor of same structure as pl/sql table type ( collects data)
d) BULK CoLLECT data from cursor into pl/sql table
e) Print the data
But during Bulk Collect i get the below error :
Unexpected error in xxc_hr2hr_populate_elements.main at FLOW TRACE-1.120. Error: ORA-06502: PL/SQL: numeric or value error: NULL index table key value
ORA-20003: Unexpected error in xxc_hr2hr_populate_elements.get_data at FLOW TRACE-1.1.100. Error: ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated BindAshish_Apps wrote:
Hi,
I am trying toceate an interface which collects data from database make some transformation and populated seeded tables in the same database.
My Approach is :
a) Create a record type variable ( concists of multiple segments)
b) Create a pl/sql table type of the records type in a)
c) Created a cursor of same structure as pl/sql table type ( collects data)
d) BULK CoLLECT data from cursor into pl/sql table
e) Print the data
But during Bulk Collect i get the below error :
Unexpected error in xxc_hr2hr_populate_elements.main at FLOW TRACE-1.120. Error: ORA-06502: PL/SQL: numeric or value error: NULL index table key value
ORA-20003: Unexpected error in xxc_hr2hr_populate_elements.get_data at FLOW TRACE-1.1.100. Error: ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated BindVerify the rows you are fetching are having the same data types as your Record like Dates should go to date , decimal should not be fetched in type defined as number etc. -
select *
from hrm_career x
WHERE x.begin_date = ( SELECT MAX(begin_date)
FROM hrm_career y
WHERE y.employee_id = x.employee_id AND
begin_date <= SYSDATE AND
primary_job = 'Y') AND
x.primary_job = 'Y'
I have the above query which is not using the index created on the BEGIN_DT column
I tried to force using still not using
but when i apply a value say
select *
from hrm_career x
WHERE x.begin_date ='10-20-2007'
It is using index and resulting in very fast response
Can some throw some ideas on it...
Where should i look into here ..SQL> set autotrace traceonly
SQL> select *
2 from hrm_career x
3 WHERE x.begin_date = ( SELECT MAX(begin_date)
4 FROM hrm_career y
5 WHERE y.employee_id = x.employee_id AND
6 begin_date <= SYSDATE AND
7 primary_job = 'Y') AND
8 x.primary_job = 'Y';
13454 rows selected.
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1417 Card=152 Bytes=
35568)
1 0 FILTER
2 1 SORT (GROUP BY) (Cost=1417 Card=152 Bytes=35568)
3 2 HASH JOIN (Cost=254 Card=47127 Bytes=11027718)
4 3 INDEX (FAST FULL SCAN) OF 'HRM_CAREER_PK' (UNIQUE) (
Cost=12 Card=25026 Bytes=500520)
5 3 TABLE ACCESS (FULL) OF 'HRM_CAREER' (Cost=81 Card=25
335 Bytes=5421690)
Statistics
3671 recursive calls
9 db block gets
1758 consistent gets
2130 physical reads
0 redo size
2217762 bytes sent via SQL*Net to client
10359 bytes received via SQL*Net from client
898 SQL*Net roundtrips to/from client
128 sorts (memory)
1 sorts (disk)
13454 rows processed
TKPROF
TKPROF: Release 9.2.0.6.0 - Production on Wed Dec 12 18:40:56 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Trace file: qnhg_ora_500.trc
Sort options: default
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
ALTER SESSION SET EVENTS '10046 trace name context forever, level 8'
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 1 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Misses in library cache during execute: 1
Optimizer goal: CHOOSE
Parsing user id: 30 (ADMIN)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 34.45 34.45
select condition
from
cdef$ where rowid=:1
call count cpu elapsed disk query current rows
Parse 4 0.00 0.00 0 0 0 0
Execute 4 0.00 0.00 0 0 0 0
Fetch 4 0.00 0.00 0 8 0 4
total 12 0.00 0.00 0 8 0 4
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: SYS (recursive depth: 1)
Rows Row Source Operation
1 TABLE ACCESS BY USER ROWID CDEF$
select *
from hrm_career x
WHERE x.begin_date = ( SELECT MAX(begin_date)
FROM hrm_career y
WHERE y.employee_id = x.employee_id AND
begin_date <= SYSDATE AND
primary_job = 'Y') AND
x.primary_job = 'Y'
call count cpu elapsed disk query current rows
Parse 1 0.00 0.07 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 898 0.00 2.39 2038 946 9 13454
total 900 0.00 2.46 2038 946 9 13454
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 30 (ADMIN)
Rows Row Source Operation
13454 FILTER
25335 SORT GROUP BY
67496 HASH JOIN
25333 INDEX FAST FULL SCAN HRM_CAREER_PK (object id 25292)
25336 TABLE ACCESS FULL HRM_CAREER
Rows Execution Plan
0 SELECT STATEMENT GOAL: CHOOSE
13454 FILTER
25335 SORT (GROUP BY)
67496 HASH JOIN
25333 INDEX GOAL: ANALYZED (FAST FULL SCAN) OF 'HRM_CAREER_PK'
(UNIQUE)
25336 TABLE ACCESS GOAL: ANALYZED (FULL) OF 'HRM_CAREER'
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 898 0.00 0.00
SQL*Net more data to client 877 0.00 0.05
db file sequential read 1 0.01 0.01
db file scattered read 60 0.00 0.14
direct path write 9 0.00 0.00
direct path read 125 0.05 0.13
SQL*Net message from client 898 0.02 1.47
DELETE FROM PLAN_TABLE
WHERE
STATEMENT_ID=:1
call count cpu elapsed disk query current rows
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 6 6 6
Fetch 0 0.00 0.00 0 0 0 0
total 4 0.00 0.00 0 6 6 6
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 30 (ADMIN)
Rows Row Source Operation
0 DELETE
0 TABLE ACCESS FULL PLAN_TABLE
Rows Execution Plan
0 DELETE STATEMENT GOAL: CHOOSE
0 DELETE OF 'PLAN_TABLE'
0 TABLE ACCESS (FULL) OF 'PLAN_TABLE'
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 2 0.00 0.00
SQL*Net message from client 2 14.77 14.79
select o.owner#,o.name,o.namespace,o.remoteowner,o.linkname,o.subname,
o.dataobj#,o.flags
from
obj$ o where o.obj#=:1
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 3 0 1
total 3 0.00 0.00 0 3 0 1
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: SYS (recursive depth: 1)
EXPLAIN PLAN SET STATEMENT_ID='PLUS74964' FOR select *
from hrm_career x
WHERE x.begin_date = ( SELECT MAX(begin_date)
FROM hrm_career y
WHERE y.employee_id = x.employee_id AND
begin_date <= SYSDATE AND
primary_job = 'Y') AND
x.primary_job = 'Y'
call count cpu elapsed disk query current rows
Parse 1 0.00 0.01 0 4 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.00 0.01 0 4 0 0
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 30 (ADMIN)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 0.00 0.00
insert into plan_table (statement_id, timestamp, operation, options,
object_node, object_owner, object_name, object_instance, object_type,
search_columns, id, parent_id, position, other,optimizer, cost, cardinality,
bytes, other_tag, partition_start, partition_stop, partition_id,
distribution, cpu_cost, io_cost, temp_space, access_predicates,
filter_predicates )
values
(:1,SYSDATE,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,:17,:18,:19,
:20,:21,:22,:23,:24,:25,:26,:27)
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 6 0.00 0.00 0 3 6 6
Fetch 0 0.00 0.00 0 0 0 0
total 7 0.00 0.00 0 3 6 6
Misses in library cache during parse: 1
Misses in library cache during execute: 2
Optimizer goal: CHOOSE
Parsing user id: 30 (ADMIN) (recursive depth: 1)
Rows Execution Plan
0 INSERT STATEMENT GOAL: CHOOSE
select o.name, u.name
from
sys.obj$ o, sys.user$ u where obj# = :1 and owner# = user#
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 1 0.00 0.00 0 0 0 0
Misses in library cache during parse: 1
Parsing user id: SYS (recursive depth: 1)
SELECT ID ID_PLUS_EXP,PARENT_ID PARENT_ID_PLUS_EXP,LPAD(' ',2*(LEVEL-1))
||OPERATION||DECODE(OTHER_TAG,NULL,'','*')||DECODE(OPTIONS,NULL,'','
('||OPTIONS||')')||DECODE(OBJECT_NAME,NULL,'',' OF '''||OBJECT_NAME||'''')
||DECODE(OBJECT_TYPE,NULL,'',' ('||OBJECT_TYPE||')')||DECODE(ID,0,
DECODE(OPTIMIZER,NULL,'',' Optimizer='||OPTIMIZER))||DECODE(COST,NULL,'','
(Cost='||COST||DECODE(CARDINALITY,NULL,'',' Card='||CARDINALITY)
||DECODE(BYTES,NULL,'',' Bytes='||BYTES)||')') PLAN_PLUS_EXP,OBJECT_NODE
OBJECT_NODE_PLUS_EXP
FROM
PLAN_TABLE START WITH ID=0 AND STATEMENT_ID=:1 CONNECT BY PRIOR ID=PARENT_ID
AND STATEMENT_ID=:1 ORDER BY ID,POSITION
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 22 0 6
total 4 0.00 0.00 0 22 0 6
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 30 (ADMIN)
Rows Row Source Operation
6 SORT ORDER BY
6 CONNECT BY WITH FILTERING
1 NESTED LOOPS
1 TABLE ACCESS FULL PLAN_TABLE
1 TABLE ACCESS BY USER ROWID PLAN_TABLE
5 NESTED LOOPS
6 BUFFER SORT
6 CONNECT BY PUMP
5 TABLE ACCESS FULL PLAN_TABLE
Rows Execution Plan
0 SELECT STATEMENT GOAL: CHOOSE
6 SORT (ORDER BY)
6 CONNECT BY (WITH FILTERING)
1 NESTED LOOPS
1 TABLE ACCESS (FULL) OF 'PLAN_TABLE'
1 TABLE ACCESS (BY USER ROWID) OF 'PLAN_TABLE'
5 NESTED LOOPS
6 BUFFER (SORT)
6 CONNECT BY PUMP
5 TABLE ACCESS (FULL) OF 'PLAN_TABLE'
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 2 0.00 0.00
SQL*Net message from client 2 0.09 0.09
SELECT ID ID_PLUS_EXP,OTHER_TAG OTHER_TAG_PLUS_EXP,OTHER OTHER_PLUS_EXP
FROM
PLAN_TABLE WHERE STATEMENT_ID=:1 AND OTHER_TAG IS NOT NULL ORDER BY ID
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 3 0 0
total 3 0.00 0.00 0 3 0 0
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 30 (ADMIN)
Rows Row Source Operation
0 SORT ORDER BY
0 TABLE ACCESS FULL PLAN_TABLE
Rows Execution Plan
0 SELECT STATEMENT GOAL: CHOOSE
0 SORT (ORDER BY)
0 TABLE ACCESS (FULL) OF 'PLAN_TABLE'
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 2 0.00 0.00
SQL*Net message from client 2 0.00 0.00
ALTER SESSION SET EVENTS '10046 trace name context off'
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 30 (ADMIN)
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 7 0.00 0.09 0 4 0 0
Execute 8 0.00 0.00 0 6 6 6
Fetch 901 0.00 2.39 2038 971 9 13460
total 916 0.00 2.49 2038 981 15 13466
Misses in library cache during parse: 6
Misses in library cache during execute: 1
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 906 0.00 0.00
SQL*Net message from client 906 34.45 50.82
SQL*Net more data to client 877 0.00 0.05
db file sequential read 1 0.01 0.01
db file scattered read 60 0.00 0.14
direct path write 9 0.00 0.00
direct path read 125 0.05 0.13
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 7 0.00 0.00 0 0 0 0
Execute 11 0.00 0.00 0 3 6 6
Fetch 5 0.00 0.00 0 11 0 5
total 23 0.00 0.00 0 14 6 11
Misses in library cache during parse: 4
Misses in library cache during execute: 2
9 user SQL statements in session.
6 internal SQL statements in session.
15 SQL statements in session.
5 statements EXPLAINed in this session.
Trace file: qnhg_ora_500.trc
Trace file compatibility: 9.02.00
Sort options: default
3 sessions in tracefile.
12 user SQL statements in trace file.
8 internal SQL statements in trace file.
15 SQL statements in trace file.
11 unique SQL statements in trace file.
5 SQL statements EXPLAINed using schema:
ADMIN.prof$plan_table
Default table was used.
Table was created.
Table was dropped.
3945 lines in trace file.
Message was edited by:
Maran Viswarayar -
hi,
I have a procedure which took 15-20 minutes in the past to execute.Suddently it is taking 2 hours.When i examined i came to know that the sql statement is not using one of the index.I dropped the index and created it.The explain plan is generated but still the index is not being used.I forced the index usage by using the index hint
SELECT /*+ INDEX(test_his test_hist_idx )*/ column 1.....
But still it does not use the index.Please suggest me some advice on this?
Thanksuser589320 wrote:
I have a procedure which took 15-20 minutes in the past to execute.Suddently it is taking 2 hours.When i examined i came to know that the sql statement is not using one of the index.I dropped the index and created it.The explain plan is generated but still the index is not being used.I forced the index usage by using the index hint
SELECT /*+ INDEX(test_his test_hist_idx )*/ column 1.....
I think you're going to have to post the entire text of your query if you want an answer, or people will simply be trying to guess what you've done wrong.
Do you also have the full execution plan from before and after the change in performance ?
If you do post the text, and plans, please use the 'code' tags to make the text readable.
p.s. My shot in the dark guess, based on the text you've supplied, is that you've used the table name in the hint, rather than the table alias.
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk
"The temptation to form premature theories upon insufficient data is the bane of our profession."
Sherlock Holmes (Sir Arthur Conan Doyle) in "The Valley of Fear".
To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
Maybe you are looking for
-
Its an Iphone4 dont laugh I tried to update to IOS7 thats all I tried and its all gone wrong It says it cant do it and it now says I ahve to reset to factory settings and that makes me want to cry I have my extensive diary in there and my photos... a
-
How to use same actions for differ pop-up
Hi gurus, I am using 2 popup in a view.same popup's having same buttons 'Yes', 'No'.when i use 1st one i have to create an action for that Yes button where i put my code for that particular Action. But when i used 2nd one the action define for that i
-
Error saving data structure CE11000 (please read log) message number KX 655
while activating the data structure in the operating concern of CO PA sap gives the following errors. 1.Error saving data structure CE11000 (please read log) Message no. KX655 2.Error saving table CE01000 Message no. KX593 3.in Log Reference field CE
-
CS6 Plugin works on windows but not mac
Hi, We have been developing a plugin for InDesign since CS3 and have recently ported it to CS6 (it was ported to all previous versions too, as they came out). I followed the porting guide etc. and on windows it compiles and runs just ok - the plugin
-
Dear all can you tell me what will happen if i am doing gr before customs vendor bill booking (Miro for customs vendor) in Indian scenario import procedure with no taxes in po i mean the tax value is 0 in po