Why is query on Table XMLTYPE ACME_CUST do a full Table Scan?
Our Oracle 11 g Enterprise Edition Release 11.2.0.1.0 database, there is a query against a record in 25 214 table XMLTYPE ACME_CUST.SELECT rownum AS seq,
EID AS eid,
SUBSTR(CUST_ID, 1, INSTR(CUST_ID, '|')-1) AS tgt_acme_customer_id,
SUBSTR(CUST_ID, INSTR(CUST_ID, '|') +1) AS src_acme_customer_id_list
FROM
(SELECT ac.eid EID,
listagg(ac.acme_cust_id, '|') WITHIN GROUP (
ORDER BY ac.acme_cust_id, ac.acme_cust_id) CUST_ID
FROM ACME_CUST ac
GROUP BY ac.eid
HAVING COUNT(ac.acme_cust_id)>1)
Explain the plan indicates:SELECT statement
County
VIEW
FILTER
Filter predicates
Count (*) > 1
GROUP SORT BY
ACME_CUST FOR FULL TABLE
The ACME_CUST Table has a virtual column defined on acme_cust_id as well as a corresponding index. He filed is also defined as the primary key.
Here is the table reflect and associated States:
CREATE
TABLE "N98991"."ACME_CUST" OF XMLTYPE
(
CONSTRAINT "ACME_CUST_ID_PK" PRIMARY KEY ("ACME_CUST_ID") USING INDEX
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536
NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1
FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE
DEFAULT) TABLESPACE "ACME_DEV" ENABLE
)
XMLTYPE STORE AS SECUREFILE BINARY XML
(
TABLESPACE "ACME_DEV" ENABLE STORAGE IN ROW CHUNK 8192 CACHE READS LOGGING
NOCOMPRESS KEEP_DUPLICATES STORAGE(INITIAL 106496 NEXT 1048576 MINEXTENTS 1
MAXEXTENTS 2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT)
)
ALLOW NONSCHEMA ALLOW ANYSCHEMA VIRTUAL COLUMNS
(
"EID" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)
/customerProfile/@eid'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(15))),
*bold* "ACME_CUST_ID" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)
/customerProfile/@id' *bold*
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(50))),
"CRET_DT" AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)
/customerProfile/@create_dt'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
WITH
TIME ZONE)))
)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
(
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
TABLESPACE "ACME_DEV" ;
CREATE
INDEX "N98991"."ACME_CST_CRET_DT_IDX" ON "N98991"."ACME_CUST"
(
"CRET_DT"
)
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
(
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
TABLESPACE "ACME_DEV" ;
CREATE
INDEX "N98991"."ACME_CST_EID_IDX" ON "N98991"."ACME_CUST"
(
"EID"
)
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
(
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
TABLESPACE "ACME_DEV" ;
*bold*CREATE UNIQUE INDEX "N98991"."ACME_CUST_ID_PK" ON "N98991"."ACME_CUST"
(
"ACME_CUST_ID"
)
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE *bold*
(
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
TABLESPACE "ACME_DEV" ;
CREATE
INDEX "N98991"."ACME_CUST_XMLINDEX_IX" ON "N98991"."ACME_CUST"
(
OBJECT_VALUE
)
INDEXTYPE IS "XDB"."XMLINDEX" PARAMETERS
(
'XMLTABLE ACME_CUST_IDX_TAB XMLNamespaces (''http://www.cigna.com/acme/domains/commoncontact/2011/11'' as "cm", default ''http://www.cigna.com/acme/domains/customer/customerprofile/2011/11''),
''/customerProfile''
columns
DOB date PATH ''personInformation/cm:birthDate'',
FIRSTNAME varchar2(40) PATH ''name/cm:givenName'',
LASTNAME varchar2(40) PATH ''name/cm:surName'',
SSN varchar2(30) PATH ''identifiers/ssn'',
MEMBERINFOS XMLType path ''memberInfos/memberInfo'' VIRTUAL
XMLTable acme_cust_lev2_idx_tab XMLNAMESPACES(default ''http://www.cigna.com/acme/domains/customer/customerprofile/2011/11''),
''/memberInfo'' passing MEMBERINFOS
columns
ami varchar2(40) PATH ''ami'',
subscId varchar2(50) PATH ''clientRelationship/subscriberInformation/subscriberId'',
employeeId varchar2(50) PATH ''systemKeys/employeeId'',
clientId varchar2(50) PATH ''clientRelationship/clientId''
'
);
CREATE UNIQUE INDEX "N98991"."SYS_C00384339" ON "N98991"."ACME_CUST"
(
"SYS_NC_OID$"
)
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
(
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
)
TABLESPACE "ACME_DEV" ;
CREATE UNIQUE INDEX "N98991"."SYS_IL0000649948C00003$$" ON "N98991"."ACME_CUST"
(
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576
MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST
GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "ACME_DEV" PARALLEL (DEGREE 0 INSTANCES 0) ;
Why is it not the ACME_CUST_ID_PK a unique index on the column virtual ACME_CUST_ID used in the plan to explain it?Any input would be much appreciated, like really puzzled here.
Kind regards
Rick
Hi Richard,
Event 10053 appears excessive for this situation.
What is the problem?
Set the event, run the query, disconnected the event, check the trace file, that's all.
It is not excessive if it helps you understand what is happening and why an index is of no use in this situation.
Tried the / * + INDEX_FFS (ACME_CUST_ID_PK) * / hint in the query "nested".
Don't know what nested query, you reference, so if I misunderstood what you mean, just ignore the comment.
What you posted earlier, it seems that you talk about this part:
listagg(ac.acme_cust_id,'|') WITHIN GROUP (
ORDER BY ac.acme_cust_id,ac.acme_cust_id) CUST_ID
This isn't a nested query, it's a projection. All major works (recovery of lines) has already been done when it comes to this part.
Maybe just to accept the performance of the queries because it is...
Maybe you can try something else.
See the document: Oracle XML DB: best practices, page 15 exodus 8:
When there are multiple scalar values that must be consolidated or ordered, it is better to write
with XMLTable build projecting all the columns to be ordered or grouped as shown
below.
Close example of your real need:
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
SQL> create table xtab_cols of xmltype
2 xmltype store as securefile binary xml;
Table created.
SQL> insert /*+ append */ into xtab_cols
2 select xmlelement("ROW",
3 xmlforest(
4 TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER,
5 DATA_LENGTH, DATA_PRECISION, DATA_SCALE, NULLABLE, COLUMN_ID,
6 DEFAULT_LENGTH, NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,
7 DENSITY, NUM_NULLS, NUM_BUCKETS, LAST_ANALYZED, SAMPLE_SIZE,
8 CHARACTER_SET_NAME, CHAR_COL_DECL_LENGTH,
9 GLOBAL_STATS, USER_STATS, AVG_COL_LEN, CHAR_LENGTH, CHAR_USED,
10 V80_FMT_IMAGE, DATA_UPGRADED, HISTOGRAM
11 )
12 )
13 from dba_tab_cols
14 where owner = 'SYS'
15 ;
57079 rows created.
SQL> commit;
Commit complete.
SQL> set long 1000
SQL> set pages 100
SQL> select xmlserialize(document object_value) from xtab_cols where rownum = 1;
XMLSERIALIZE(DOCUMENTOBJECT_VALUE)
--------------------------------------------------------------------------------
ACCESS$
D_OBJ#
NUMBER
22
N
1
7454
C2083A
C3031D18
,000134156157767642
0
1
2012-01-28
34794
YES
NO
5
0
NO
YES
NONE
SQL> exec dbms_stats.gather_table_stats(user, 'XTAB_COLS');
PL/SQL procedure successfully completed.
SQL> set autotrace traceonly
SQL> set timing on
SQL> set lines 120
SQL> select x.table_name
2 , listagg(x.column_name, ',') within group (order by column_id)
3 from xtab_cols t
4 , xmltable('/ROW' passing t.object_value
5 columns table_name varchar2(30) path 'TABLE_NAME'
6 , column_name varchar2(30) path 'COLUMN_NAME'
7 , column_id number path 'COLUMN_ID'
8 ) x
9 group by x.table_name
10 ;
4714 rows selected.
Elapsed: 00:00:08.25
Execution Plan
----------------------------------------------------------
Plan hash value: 602782846
---------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 466M| 101G| 1580K (3)| 05:16:04 |
| 1 | SORT GROUP BY | | 466M| 101G| 1580K (3)| 05:16:04 |
| 2 | NESTED LOOPS | | 466M| 101G| 1552K (1)| 05:10:32 |
| 3 | TABLE ACCESS FULL| XTAB_COLS | 57079 | 12M| 408 (1)| 00:00:05 |
| 4 | XPATH EVALUATION | | | | | |
---------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
9 recursive calls
1 db block gets
1713 consistent gets
0 physical reads
96 redo size
773516 bytes sent via SQL*Net to client
3873 bytes received via SQL*Net from client
316 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
4714 rows processed
And of course, even better after adding an XML index structured (4714 lines read in 1 s):
SQL> CREATE INDEX xtab_cols_sxi ON xtab_cols (OBJECT_VALUE) INDEXTYPE IS XDB.XMLIndex
2 PARAMETERS (
3 q'#XMLTable my_xtab
4 '/ROW'
5 columns table_name varchar2(30) path 'TABLE_NAME'
6 , column_name varchar2(30) path 'COLUMN_NAME'
7 , column_id number path 'COLUMN_ID' #');
Index created.
Elapsed: 00:00:13.42
SQL> select x.table_name
2 , listagg(x.column_name, ',') within group (order by column_id)
3 from xtab_cols t
4 , xmltable('/ROW' passing t.object_value
5 columns table_name varchar2(30) path 'TABLE_NAME'
6 , column_name varchar2(30) path 'COLUMN_NAME'
7 , column_id number path 'COLUMN_ID'
8 ) x
9 group by x.table_name
10 ;
4714 rows selected.
Elapsed: 00:00:01.00
Execution Plan
----------------------------------------------------------
Plan hash value: 3303494605
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 57520 | 3201K| 174 (3)| 00:00:03 |
| 1 | SORT GROUP BY | | 57520 | 3201K| 174 (3)| 00:00:03 |
| 2 | TABLE ACCESS FULL| MY_XTAB | 57520 | 3201K| 171 (1)| 00:00:03 |
------------------------------------------------------------------------------
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
297 recursive calls
1 db block gets
989 consistent gets
0 physical reads
176 redo size
773516 bytes sent via SQL*Net to client
3873 bytes received via SQL*Net from client
316 SQL*Net roundtrips to/from client
21 sorts (memory)
0 sorts (disk)
4714 rows processed
Tags: Database
Similar Questions
-
I CAN QUERY A TABLE EVEN AFTER THE DELETION OF THE DATA FILE
Hello
Can someone explain to me the reason why I am able to interview some tables even after the deletion of the data that are associated with file?
SQL > select table_name, tablespace_name from dba_tables where owner = 'SCOTT ';
TABLE_NAME, TABLESPACE_NAME
------------------------------ ------------------------------
TEST2 USERS
TEST USERS
SALGRADE USERS
USERS OF BONUS
USERS OF THE EMP
USERS OF DEPT
6 selected lines.
SQL > exit
Disconnected from the database to Oracle 11 g Enterprise Edition Release 11.2.0.1.0 - Production
With partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost orcl] $ rm /app/oracle/oradata/orcl/users01.dbf
[oracle@localhost orcl] $ sqlplus scott/scott
SQL * more: Production version 11.2.0.1.0 on Mon Mar 30 21:35:54 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With partitioning, OLAP, Data Mining and Real Application Testing options
SQL > select count (*) from test2;
Select count (*) from test2
*
ERROR on line 1:
ORA-01116: error opening the database file 4
ORA-01110: data file 4: ' / app/oracle/oradata/orcl/users01.dbf'
ORA-27041: could not open the file
Linux error: 2: no such file or directory
Additional information: 3
SQL > select count (*) of the test;
COUNT (*)
----------
5000
SQL >
The first output is as expected. But why am I still able to query the table of test, even if the data file has been deleted.
Hello
The process of database have a file handle for the data file - this remains even when the file is deleted (it disappears from the normal file system navigation)
You can see if you have lsof installed
just try
lsof | grep datafile_name
Once the database is restarted and the released file handle so you will not be able to do this any more - and in fact you will get errors when it can't find the file.
See you soon,.
Rich
-
The query makes a full table scan?
I have a simple select query that filters on the last 10 or 11 days of data in a table. In the first case, it runs in 1 second. In the second case it takes 15 minutes and still not done.
I can say that the second query (11 days) makes a full table scan.
-Why is this happening? ... I guess some kind of threshold?
-Are there a way to avoid this? ... or encourage Oracle to play nice.
I find confusing from the point of view before end/query to get very different performances.
Jason
Oracle 10g
Toad quest 10.6
CREATE TABLE delme10 AS SELECT * FROM ed_visits WHERE first_contact_dt >= TRUNC(SYSDATE-10,'D'); Plan hash value: 915912709 -------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------------------------- | 0 | CREATE TABLE STATEMENT | | 4799 | 5534K| 4951 (1)| 00:01:00 | | 1 | LOAD AS SELECT | DELME10 | | | | | | 2 | TABLE ACCESS BY INDEX ROWID| ED_VISITS | 4799 | 5534K| 4796 (1)| 00:00:58 | |* 3 | INDEX RANGE SCAN | NDX_ED_VISITS_020 | 4799 | | 15 (0)| 00:00:01 | -------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 3 - access("FIRST_CONTACT_DT">=TRUNC(SYSDATE@!-10,'fmd')) CREATE TABLE delme11 AS SELECT * FROM ed_visits WHERE first_contact_dt >= TRUNC(SYSDATE-11,'D'); Plan hash value: 1113251513 ----------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | TQ |IN-OUT| PQ Distrib | ----------------------------------------------------------------------------------------------------------------- | 0 | CREATE TABLE STATEMENT | | 25157 | 28M| 14580 (1)| 00:02:55 | | | | | 1 | LOAD AS SELECT | DELME11 | | | | | | | | | 2 | PX COORDINATOR | | | | | | | | | | 3 | PX SEND QC (RANDOM) | :TQ10000 | 25157 | 28M| 14530 (1)| 00:02:55 | Q1,00 | P->S | QC (RAND) | | 4 | PX BLOCK ITERATOR | | 25157 | 28M| 14530 (1)| 00:02:55 | Q1,00 | PCWC | | |* 5 | TABLE ACCESS FULL | ED_VISITS | 25157 | 28M| 14530 (1)| 00:02:55 | Q1,00 | PCWP | | ----------------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 5 - filter("FIRST_CONTACT_DT">=TRUNC(SYSDATE@!-11,'fmd'))
This seems to change the plan to explain it...
alter session set optimizer_index_cost_adj=10;
-
FULL TABLE SCAN even with the index, but why?
Could someone please explain why I'd get FULL TABLE SCAN explain plan results when joining 2 tables on columns that already have clues about them? For example,.
consider this fictional scenario:
employee table with columns:
employee # (primary key column)
name
address table with columns:
employee # (foreign key to employee.employee #)
subscription_type
address
Select Employee.Name since it is, address.address_type, address.address
where employee.employee # = address.employee #.
This query shows a full table scan in terms of the explain command.Full scan of the table is not necessarily slow and index access is not necessarily fast.
You will recover, no doubt, most if not all the ranks on both sides. The fastest way to retrieve each row in a table is to do a table scan. Using an index, and a single block of reading for each row in a table is much less effective than to do a table scan.
Justin
-
CBO: full instead of bitmap index use, why table scan?
I have a query in which it is clearly benefitial to use the bitmap index, rather oracle goes for the full table scan. Could you please shed some light on this? Because even a hint does not help, I guess that something prevents oracle (11.1.0.7.0) to use it in a sort of range index scan pass.
installation program:
several select statements:create table test_distance ( x_display number, y_display number, x_rough number(5,2) as (trunc(x_display,2)), y_rough number(5,2) as (trunc(y_display,2))); insert into test_distance (x_display,y_display) (select dbms_random.value(-180,180), dbms_random.value(-90,90) from dual connect by level < 200000); create bitmap index test_bm_xrough on test_distance(x_rough); create bitmap index test_bm_yrough on test_distance(y_rough); create or replace function western_bbox_longitude(x binary_double, y binary_double, radius binary_double) return number is begin --simplified return x - 0.0001*radius; end; / exec dbms_stats.gather_table_stats(user,'TEST_DISTANCE',cascade=>true,estimate_percent=>100);
--remember x and y values and use them in the subsequent queries. select * from test_distance where rownum = 1; alter session set statistics_level = all; --no bind variable, no function call -> proper plan select * from test_distance where x_rough = 16.14 and y_rough = -35.53; select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST')); --with bind variable, no function call -> still proper plan select * from test_distance where x_rough = :xin and y_rough = :yin; select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST')); --using between, bind variable, no function call -> proper plan select * from test_distance where x_rough between :xin-0.01 and :xin and y_rough between :yin-0.01 and :yin; select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST')); --full table scan, why? select td.*, trunc(western_bbox_longitude(:xin,:yin,:radius),2) from test_distance td where x_rough = trunc( western_bbox_longitude(:xin,:yin,:radius),2); select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST')); --forcing oracle to use the index results in bitmap index full instead of range scan, why? select /*+ index( td test_bm_xrough) */ td.*, trunc(western_bbox_longitude(:xin,:yin,:radius),2) from test_distance td where x_rough = trunc( western_bbox_longitude(:xin,:yin,:radius),2); select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST')); --guessing it might be related to the selectivity of the function doesn't change the plan either associate statistics with functions western_bbox_longitude default selectivity 0.001;
Ah sorry, I somehow read the wrong line in your initial statement where it between the function has been used.
Yes it is possible that the selectivity of the function plays a role here. More likely may be the order of execution for the undeterministic functions is then different for literals. However, you can try to work around this problem by using a few different approaches.
encapsulate the function inside a double subseelct
select /*+ index( td test_bm_xrough) */ td.*, (select trunc(western_bbox_longitude(:xin,:yin,:radius),2)) from test_distance td where x_rough = (select trunc(western_bbox_longitude(:xin,:yin,:radius),2) from dual);
This should allow to cache the result of the function to a certain extent. Otherwise, the result of the function may be recalculated for each row in the test_distance table.
The same can be achieved with a WITH clause
not testedwith wboxlong as (select trunc(western_bbox_longitude(:xin,:yin,:radius),2) xrough from dual) select /*+ index( td test_bm_xrough) */ td.*, x.xrough from test_distance td join wboxlong x on td.x_rough = x.xrough
Also note that your tip worked. Oracle uses the bitmap indexes to access the data. Index indicator indicates to the CBO to use this index if possible, but is not on the path. If you want a different plan, you can try to apply also the path combined with a suspicion as NO_INDEX_FFS (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements006.htm#SQLRF50413).
Published by: Sven w. on January 3, 2011 18:57
-
I have a table with 831 k lines and index:
When I run of EXPLAIN PLAN for the sql:CREATE TABLE "ROGADM"."ROG_LOG" ( "LOG_ID" NUMBER(10,0), "LOG_OBK_TYP" VARCHAR2(30 BYTE), "LOG_OBK_ID" VARCHAR2(200 BYTE), "LOG_TYP" VARCHAR2(30 BYTE), "LOG_RODZAJ" VARCHAR2(30 BYTE), "LOG_R_OBK_ID" VARCHAR2(200 BYTE), "LOG_DATA_ZDARZENIA" DATE, "LOG_OPIS_ZDARZENIA" VARCHAR2(4000 BYTE), "LOG_UTWORZYL" VARCHAR2(30 BYTE), "LOG_KIEDY_UTWORZYL" DATE, CONSTRAINT "LOG_PK" PRIMARY KEY ("LOG_ID") ); CREATE INDEX "ROGADM"."LOG_I" ON "ROGADM"."ROG_LOG" ( "LOG_OBK_ID", "LOG_OBK_TYP", "LOG_TYP", "LOG_RODZAJ" ); CREATE INDEX "ROGADM"."LOG_I2" ON "ROGADM"."ROG_LOG" ( "LOG_R_OBK_ID", "LOG_RODZAJ" ); CREATE UNIQUE INDEX "ROGADM"."LOG_PK" ON "ROGADM"."ROG_LOG" ( "LOG_ID" );
the output isSELECT log_obk_id FROM rog_log;
Why?PLAN_TABLE_OUTPUT Plan hash value: 3822058985 ----------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 831K| 8122K| 2240 (2)| 00:00:27 | | 1 | TABLE ACCESS FULL| ROG_LOG | 831K| 8122K| 2240 (2)| 00:00:27 | -----------------------------------------------------------------------------
You have an index on the LOG_OBK_ID column. But when you select this column see you FULL TABLE SCAN and no index is used.
This is because you have not set your column as NOT NULL value column. Oracle stores a NULL value in the index. And that is why when you query the table for LOG_OBK_ID he goes to the table and does not use the index.
See the example below
SQL> create table my_test ( object_id number not null, object_type varchar2(100), object_name varchar2(100)); Table created. SQL> create index my_test_idx on my_test(object_id, object_type); Index created. SQL> insert into my_test 2 select object_id, object_type, object_name 3 from all_objects 4 where rownum <= 100000 5 / 50058 rows created. SQL> commit 2 / Commit complete. SQL> exec dbms_stats.gather_table_stats('KARTHICK_PATTABIRAMAN','MY_TEST',cascade=>true) PL/SQL procedure successfully completed. SQL> explain plan for select object_id from my_test 2 / Explained. SQL> select * from table(dbms_xplan.display) 2 / PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Plan hash value: 720752151 ------------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------ PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 50058 | 244K| 36 (0)| 00:00:01 | | 1 | INDEX FAST FULL SCAN| MY_TEST_IDX | 50058 | 244K| 36 (0)| 00:00:01 | ------------------------------------------------------------------------------------ 8 rows selected.
See the index is used. Oracle considers the index as a Skinny table version and do a FULL scan on the INDEX and not on the TABLE.
Now, let us remove the NOT NULL constraint and see what happens.
SQL> alter table my_test modify object_id null 2 / Table altered. SQL> desc my_test Name Null? Type ----------------------------------------- -------- ---------------------------- OBJECT_ID NUMBER OBJECT_TYPE VARCHAR2(100) OBJECT_NAME VARCHAR2(100) SQL> exec dbms_stats.gather_table_stats('KARTHICK_PATTABIRAMAN','MY_TEST',cascade=>true) PL/SQL procedure successfully completed. SQL> explain plan for select object_id from my_test 2 / Explained. SQL> select * from table(dbms_xplan.display) 2 / PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Plan hash value: 1615681525 ----------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 50058 | 244K| 67 (0)| 00:00:01 | | 1 | TABLE ACCESS FULL| MY_TEST | 50058 | 244K| 67 (0)| 00:00:01 | ----------------------------------------------------------------------------- 8 rows selected. SQL>
See oracle now goes for FULL TABLE SCAN.
-
Why this query can remove duplicates?
Why this query can remove duplicates? Can someone give me detailed explanation?
Thank you
select salary from employees union select salary from employees;
Hello
See the docs.
' Example of the UNION
The following statement combines the results of two queries with the UNION operator which eliminates duplicates of selected lines.
"This statement shows that you must match the data type (using the function TO_CHAR) when the columns do not exist in one or the other table"http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/queries004.htm#i2054381
Edit
Here's another interpretation of your question:
http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:1224636375004
Published by: hoek on October 22, 2009 17:40
-
Hello
I use ATG version 10.2 and you have configured CRS application by IMC. All data import and deployments have been successful.
Applications of short (MDEX 6.4.1, CASE 3.2.1 6.4.1.2, tools and Framework 3.1.2 platform services) are running: port 8006, 8500, race 8888.
Now MY PROBLEM IS in TWO PARTS:
PART 1) Ran the store on jboss, has worked well, core application started without any error. When trying to load the homepage, get following error message:
16:42:25, 926 full repository INFO [SEORepository] SQL boot
16:43:32, 653 ERROR [DynamoServlet]
CAUGHT AT:
Container: ATG.servlet.jsp.ContainerJspException: Cannot find the named component: / atg/registry/Slots/HomeTheme; Source: javax.servlet.ServletException: Cannot find the named component: / atg/registry/Slots/HomeTheme
at atg.taglib.dspjsp.ParamTag.doStartTag(ParamTag.java:419)
at org.apache.jsp.navigation.gadgets.homePagePromotions_jsp._jspx_meth_dsp_005fparam_005f0(homePagePromotions_jsp.java:1021)
at org.apache.jsp.navigation.gadgets.homePagePromotions_jsp._jspService(homePagePromotions_jsp.java:219)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:543)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:480)
at atg.servlet.WrappingRequestDispatcher.include(WrappingRequestDispatcher.java:123)
at atg.taglib.dspjsp.IncludeTag.doEndTag(IncludeTag.java:883)
at org.apache.jsp.index_jsp._jspx_meth_dsp_005finclude_005f1(index_jsp.java:633)
to org.apache.jsp.index_jsp.access$ 1 (index_jsp.java:622)
to org.apache.jsp.index_jsp$ Helper.invoke1 (index_jsp.java:685)
to org.apache.jsp.index_jsp$ Helper.invoke (index_jsp.java:711)
at org.apache.jsp.tag.web.store.pageContainer_tag._jspx_meth_c_005fwhen_005f1(pageContainer_tag.java:2757)
at org.apache.jsp.tag.web.store.pageContainer_tag.doTag(pageContainer_tag.java:812)
at org.apache.jsp.index_jsp._jspx_meth_crs_005fpageContainer_005f0(index_jsp.java:598)
at org.apache.jsp.index_jsp._jspx_meth_dsp_005fpage_005f1(index_jsp.java:565)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:127)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
...........................
...........................
...........................
...........................
At this point, the CRS page opens but no short content. Don't load no registration, no image on the home page does display, NO SEARCH BOX displayed in the header.
PART 2) On top of that when I try to run the server pubishing on JBOSS, start does'nt server and responds to error. If the das_id_generator table exists in DB for all 4 patterns.
16:09:41, 082 INFO [ScreenLog] with logging of external for debug messages and trace kernel to avoid hidden kernel logging information. Set the property /atg/dynamo/service/logging/ScreenLog.useInfoForDebug to false nucleus to use external instead trace and debug logging.
16:09:41, 199 INFO [Version] HV000001: Hibernate Validator 4.3.1.Final
16:09:41, 748 Truncating WARN [ClusterBroadcaster] serviceProperties "commandLineModules" key value
16:09:42, size INFO [STDOUT] 345 (ERR_QUERY_TABLE, das_id_generator
16:09:42, 351 ERROR [IdGenerator]
CAUGHT AT:
Container: ATG.service.IdGen.IdGeneratorException; Source: Container: ATG.service.IdGen.IdGeneratorException: Cannot query the table 'das_id_generator '. Please make sure that the table exists and is accessible before you start this service. ; Source: Java.Sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
at atg.service.idgen.PersistentIdGenerator.initialize(PersistentIdGenerator.java:389)
at atg.service.idgen.AbstractSequentialIdGenerator.doStartService(AbstractSequentialIdGenerator.java:643)
at atg.nucleus.GenericService.startService(GenericService.java:561)
at atg.nucleus.NucleusNameResolver.startService(NucleusNameResolver.java:1726)
at atg.nucleus.NucleusNameResolver.configureAndStartService(NucleusNameResolver.java:1397)
at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:928)
at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:667)
at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:648)
at atg.nucleus.NucleusNameResolver.resolveName(NucleusNameResolver.java:493)
at atg.nucleus.ConfigurationRef.getValue(ConfigurationRef.java:119)
at atg.nucleus.SimpleComponentState.setBeanProperty(SimpleComponentState.java:403)
at atg.nucleus.SimpleConfigurationState.saveToBean(SimpleConfigurationState.java:240)
at atg.nucleus.SimpleConfigurationState.configureBean(SimpleConfigurationState.java:263)
at atg.nucleus.BeanConfigurator.configureBean(BeanConfigurator.java:297)
at atg.nucleus.PropertyConfiguration.configureService(PropertyConfiguration.java:984)
at atg.nucleus.SingleNucleusConfigurator.configureService(SingleNucleusConfigurator.java:84)
at atg.nucleus.NucleusNameResolver.configureService(NucleusNameResolver.java:1643)
at atg.nucleus.NucleusNameResolver.configureAndStartService(NucleusNameResolver.java:1368)
........................
........................
........................
An early response would be really useful because we have demo in 10 days.
Kind regards
Ben Milot
Thank you for this comment.
I had created a fresh scheme for publication but the jboss was still pointing to the old.
I've updated this pointers in file @ /server/
atg atg - ds - ds.xml. Worked like a charm! If 2nd EDITION solved.
The QUESTION 1 depended on question 2. Once I ran publishing and completed the full deployment on ICC, 1st edition got resolved.
Thanks to shaik and Grando
Kind regards
Ben Milot
-
I use the af: query with table to create a query, but the funny page, is in charge of the query page, the data contained in af:table are not fulfilled automatically. any idea, what the problem is?
Rgds!Hello
Do you use ViewCriteria to build your af:query with table, if yes, go to your ViewObject, then select your viewCriteria and click edit, and then open the data of the user interface tab, then check the query automatically . -
Hello
on 10 g 2, I can not query a table, but it exists:
Thanks for the help.SQL> show user USER is "SYS" SQL> select count(*) from PROP_USER1.Mytable; select count(*) from PROP_USER1.Mytable * ERROR at line 1: ORA-00942: table or view does not exist SQL> select object_name , owner, object_type from dba_objects where object_name like '%Mytable%'; OBJECT_NAME OWNER OBJECT_TYPE ------------------------- ------------------------------ ------------------- Mytable PROP_USER1 TABLE SQL> select count(*) from PROP_USER1.Mytable; select count(*) from PROP_USER1.Mytable * ERROR at line 1: ORA-00942: table or view does not exist
Sign in as PROP_USER1 and check if you are able to query this table?
-
Why this query produces no output?
Why this query produces no output?
select * from ( SELECT 40 as startvalue, (24 * 60)*(To_Date('00:40', 'HH24:MI') - To_Date('00:00', 'HH24:MI')) as c FROM dual di ) q where q.c = q.startvalue
And just to show that it works if round you...
SQL> ed Wrote file afiedt.buf 1 select * from 2 ( 3 SELECT 40 as startvalue, round((24 * 60)*(To_Date('00:40', 'HH24:MI') - To_Date('00:00', 'HH24:MI')),0) as c 4 FROM dual di 5 ) q 6* where q.c = q.startvalue SQL> / STARTVALUE C ---------- ---------- 40 40
I certainly wouldn't say using TRIM as PS has suggested. TRIM is a string function, not a digital function.
-
Refresh table-form query on table only for pages in .jsff
I have a group being generated as a presentation of table form. I would like for the page of the table to always refresh, and submit the form to refresh page after.
I saw a thread about how to do this on a .jspx page: Refresh table-form query on table only
Unfortunately, this does not work for me because I use the .jsff pages and they do not have access to the facesContext. Does anyone know how to do this for a .jsff page?
Thank you
MichelleMichelle,
The taskflow 11 ADF in the equivalent of the region of this expression would be
#{jhsPageChanged and controllerContext.currentViewPort.viewId=='/MyGroupTaskFlow/MyGroupTable'}
Unfortunately, this currently does not work because there is an error in the JhsNavigationHandlerImpl class we're going to fix in the next release.
You can apply a work around by creating a subclass of JhsNavigationHandler and replace as follows:' public Sub handleNavigation (FacesContext facesContext, string action,
The string result)
{
String oldPageFragmentId = ControllerContext.getInstance () .getCurrentViewPort () .getViewId ();
super.handleNavigation (facesContext, action, result);
String newPageFragmentId = ControllerContext.getInstance () .getCurrentViewPort () .getViewId ();
If (! oldPageFragmentId.equals (newPageFragmentId))
{
JsfUtils.storeOnRequest (JHS_PAGE_CHANGED, Boolean.TRUE);
}
}To use your subclass, create a custom template for the facesConfig.vm and modify the navigation Manager to use your subclass.
Steven Davelaar,
JHeadstart team. -
Hello
I hope this is the right forum.
I'm doing some coding in Java to monitor a lock. I have a built tool that takes SQL and apply logic to a multi tool so so I never write code more to do what I want to do in our systems - just follow the successive executions of this app and intercept the error codes.
in any case, I'm watching the locks in the database under certain conditions, but I'm not able to get Ibatis query on tables of v$.
If I put ' select * lock in $ v' in Ibatis, it will come out ' select * of vlock' causing an ORA-000942: there is no error table or view.
Real diary of my application:
+ DEBUG [hand] (Log4jImpl.java:26) - declaration of preparation {conn-100000}: select nvl ((sélectionnez '1' de vlock vlock2 où 1 = 1 et vlock1.block=1 et vlock1.id1=vlock2.id1 et vlock1.id2=vlock2.id2 et 0 < vlock2.request et rownum = 1), ' 0') as resulting double +.
+ DEBUG [main] (Log4jImpl.java:26) - {pstm-100001} executing statement: select nvl ((sélectionnez '1' de vlock vlock2 où 1 = 1 et vlock1.block=1 et vlock1.id1=vlock2.id1 et vlock1.id2=vlock2.id2 et 0 < vlock2.request et rownum = 1), ' 0') as resulting double +.
+ DEBUG [hand] (Log4jImpl.java:26) - {pstm-100001} parameters: [] +.
+ DEBUG [main] (Log4jImpl.java:26) - {pstm-100001} Types: [] +.
+ [Hand] DEBUG (Log4jImpl.java:26) - return to connection pool 1156596976. +
+ ERROR [main] (Main.java:101) - com.ibatis.common.jdbc.exception.NestedSQLException: +.
-The error occurred in jdasql.xml.
-The error occurred when applying a parameter map.
-Check the - existf_AsdLockCheck2-InlineParameterMap.
-Check the instruction (failed query).
-Cause: java.sql.SQLException: ORA-00942: table or view does not exist
It's strange. The sqlmap did this:
Select nvl)
Select '1'
v $ lock vlock1
+ v$ lock vlock2 +.
where 1 = 1
and vlock1.block = 1
and vlock1.id1 = vlock2.id1
and vlock1.id2 = vlock2.id2
and 0 & lt; vlock2. Request
(and rownum = 1), '0') as a result of the doubleIn ibatis, you must double pound (#) and the dollar ($) symbols escape them:
select nvl(( select '1' from v$$lock vlock2 where 1=1 and vlock1.block=1 and vlock1.id1=vlock2.id1 and vlock1.id2=vlock2.id2 and 0 < vlock2.request and rownum=1), '0') as results from dual
Max
[My Italian blog Oracle | http://oracleitalia.wordpress.com/2010/01/17/supporto-di-xml-schema-in-oracle-xmldb/] -
Why cannot create the table partitioned successfully?
Why cannot create the table partitioned successfully?SQL> create table hr.gps_log_his (id number, name varchar2(10), time date) tablespace ts_log_his PARTITION BY RANGE (TIME) (PARTITION udp_part09110707 VALUES LESS THAN (TO_DATE('09110708','yymmddhh24')), PARTITION udp_part09110708 VALUES LESS THAN (TO_DATE('09110709','yymmddhh24')), PARTITION udp_part09110709 VALUES LESS THAN (TO_DATE('09110710','yymmddhh24')), PARTITION udp_part09110710 VALUES LESS THAN (maxvalue) ); (PARTITION udp_part09110707 VALUES LESS THAN (TO_DATE('09110708','yymmddhh24')), Error on line 7: ORA-14120: DATE columns did not specify the complete partitioning limits.
The detailed error message is as follows:
ORA-14120: incompletely specified partition bound for a DATE column Cause: An attempt was made to use a date expression whose format does not fully (i.e. day, month, and year (including century)) specify a date as a partition bound for a DATE column. The format may have been specified explicitly (using TO_DATE() function) or implicitly (NLS_DATE_FORMAT). Action: Ensure that date format used in a partition bound for a DATE column supports complete specification of a date (i.e. day, month, and year (including century)). If NLS_DATE_FORMAT does not support complete (i.e. including the century) specification of the year, use TO_DATE() (e.g. TO_DATE('01-01-1999', 'MM-DD-YYYY') to fully express the desired date.
Action: Change to_date('09110708','yymmddhh24') to
to_date('2009110708','yyyymmddhh24') -
Why full when I index the table scan
Can someone quickly tell me why this statement will generate a full table scan if RECEIPT_NO for both tables have a unique index.
Select * from agency_ledger where a.RECEIPT_NO in (select receipt_no from temp)
concerningHello
Two reason I can think
(1) statistics are not collected or are at a standstill.
(2) oracle considers the hash join full table scan more appropriate than the nested loop + scan small index.Post your explain plain and let us know stats is collected or not.
In addition, let us know what is the percentage of rows are expected in output compared to the total number of lines.Concerning
Anurag Tibrewal.
Maybe you are looking for
-
Satellite Pro A100-622: Impossible to activate the card PCI-E BT
Hello so, I have this laptop and it doesn't have the internal Bluetooth module or no connections to install one.So I bought a combo wifi/Bluetooth Broadcom pci-e card and WiFi part works fine but the Bluetooth part is not recognized, When you install
-
HP warranty repair question?
HelloI currently have a HP laptop with a hard drive defective, unfortunately I am not available a lot in the week and I was wondering if you do collection on Saturday or Sunday? Thank youJames
-
0x8024400a error code, impossible to install service pack 3
Original title: Toshiba laptop under XP Home Edition with service pack 2. When I try to update and install SP3, it will fail with a 0x8024400a error code. I tried to reset update download "Fix it." Laptop is 6 years old, XP Home Edition (2005) came
-
Since the update I can not find the sets on the Lenovo theme... where can I find them?
-
ElitePad 1000: ElitePad 1000 G2 - WWAN
bought a refurbished G2 Elitpad 1000. Everything works fine, but can't understand is it a WWAN or not. has a micro sim slot.