How oracle decide whetehr to use the index or full analysis (statistics)
Hi guys,.Let's say I have an index on a column.
Tables and index statistics were collected. (without the histograms).
Let's say I have run a select * from table where a = 5;
Oracle will perform a complete analysis.
But what statistics, it will be able to know indeed the greater part of the column = 5? (histograms do not used)
After analysis, we get the following:
Statistical table:
(NUM_ROWS)
(BLOCKS)
(EMPTY_BLOCKS)
(AVG_SPACE)
(CHAIN_COUNT)
(AVG_ROW_LEN)
Index statistics:
(BLEVEL)
(LEAF_BLOCKS)
(DISTINCT_KEYS)
(AVG_LEAF_BLOCKS_PER_KEY)
(AVG_DATA_BLOCKS_PER_KEY)
(CLUSTERING_FACTOR)
Thank you
Index of column (A)
======
1
1
2
2
5
5
5
5
5
5
I have prepared a few explanations and did not notice that the topic has been marked as answer.
My sentence is not quite true.
A column "without histograms' means that the column has only a bucket.
More correct: even without the histogram there are data in dba_tab_histograms which can be considered a bucket for the whole column. In fact, these data are extracted from hist_head$, not from $ histgrm as usual buckets.
Technically there are no buckets without combined histograms.
Let's create a table with the asymmetric data distribution.
SQL> create table t as
2 select least(rownum,3) as val, '*' as pad
3 from dual
4 connect by level <= 1000000;
Table created
SQL> create index idx on t(val);
Index created
SQL> select val, count(*)
2 from t
3 group by val;
VAL COUNT(*)
---------- ----------
1 1
2 1
3 999998
So, we have table with the very uneven distribution of the data.
We collect statistics without histograms.
SQL> exec dbms_stats.gather_table_stats( user, 'T', estimate_percent => 100, method_opt => 'for all columns size 1', cascade => true);
PL/SQL procedure successfully completed
SQL> select blocks, num_rows from dba_tab_statistics
2 where table_name = 'T';
BLOCKS NUM_ROWS
---------- ----------
3106 1000000
SQL> select blevel, leaf_blocks, clustering_factor
2 from dba_ind_statistics t
3 where table_name = 'T'
4 and index_name = 'IDX';
BLEVEL LEAF_BLOCKS CLUSTERING_FACTOR
---------- ----------- -----------------
2 4017 3107
SQL> select column_name,
2 num_distinct,
3 density,
4 num_nulls,
5 low_value,
6 high_value
7 from dba_tab_col_statistics
8 where table_name = 'T'
9 and column_name = 'VAL';
COLUMN_NAME NUM_DISTINCT DENSITY NUM_NULLS LOW_VALUE HIGH_VALUE
------------ ------------ ---------- ---------- -------------- ---------------
VAL 3 0,33333333 0 C102 C104
Therefore, Oracle suggests that the values between 1 and 3 (raw C102 C104) are distributed uniform and the density of the distribution is 0.33.
We will try to explain the plan
SQL> explain plan for
2 select --+ no_cpu_costing
3 *
4 from t
5 where val = 1
6 ;
Explained
SQL> @plan
--------------------------------------------------
| Id | Operation | Name | Rows | Cost |
--------------------------------------------------
| 0 | SELECT STATEMENT | | 333K| 300 |
|* 1 | TABLE ACCESS FULL| T | 333K| 300 |
--------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("VAL"=1)
Note
-----
- cpu costing is off (consider enabling it)
An excerpt from trace 10053
BASE STATISTICAL INFORMATION
***********************
Table Stats::
Table: T Alias: T
#Rows: 1000000 #Blks: 3106 AvgRowLen: 5.00
Index Stats::
Index: IDX Col#: 1
LVLS: 2 #LB: 4017 #DK: 3 LB/K: 1339.00 DB/K: 1035.00 CLUF: 3107.00
***************************************
SINGLE TABLE ACCESS PATH
-----------------------------------------
BEGIN Single Table Cardinality Estimation
-----------------------------------------
Column (#1): VAL(NUMBER)
AvgLen: 3.00 NDV: 3 Nulls: 0 Density: 0.33333 Min: 1 Max: 3
Table: T Alias: T
Card: Original: 1000000 Rounded: 333333 Computed: 333333.33 Non Adjusted: 333333.33
-----------------------------------------
END Single Table Cardinality Estimation
-----------------------------------------
Access Path: TableScan
Cost: 300.00 Resp: 300.00 Degree: 0
Cost_io: 300.00 Cost_cpu: 0
Resp_io: 300.00 Resp_cpu: 0
Access Path: index (AllEqRange)
Index: IDX
resc_io: 2377.00 resc_cpu: 0
ix_sel: 0.33333 ix_sel_with_filters: 0.33333
Cost: 2377.00 Resp: 2377.00 Degree: 1
Best:: AccessPath: TableScan
Cost: 300.00 Degree: 1 Resp: 300.00 Card: 333333.33 Bytes: 0
FTS here costs 300 and Index Range Scan here costs 2377.
I disabled cpu cost, so the selectivity does not affect the cost of FTS.
cost of the Index Range Scan is calculated as
blevel + (leaf_blocks * selectivity + clustering_factor * selecivity) = 2 + (4017 * 0.33333 + 3107 * 0.33333) = 2377.
Oracle believes that he must read 2 blocks root/branch index, 1339 the index leaf blocks and 1036 blocks in the table.
Pay attention that the selectivity is the main component of the cost of the Index Range Scan.
We will try to collect histograms:
SQL> exec dbms_stats.gather_table_stats( user, 'T', estimate_percent => 100, method_opt => 'for columns val size 3', cascade => true);
PL/SQL procedure successfully completed
If you look at dba_tab_histograms you can see more
SQL> select endpoint_value,
2 endpoint_number
3 from dba_tab_histograms
4 where table_name = 'T'
5 and column_name = 'VAL'
6 ;
ENDPOINT_VALUE ENDPOINT_NUMBER
-------------- ---------------
1 1
2 2
3 1000000
ENDPOINT_VALUE is the value of the column (in number for any type of data) and ENDPOINT_NUMBER is the cumulative number of lines.
Number of lines for any ENDPOINT_VALUE = ENDPOINT_NUMBER for this ENDPOINT_VALUE - ENDPOINT_NUMBER to the previous ENDPOINT_VALUE.
explain the plan and track 10053 the same query:
------------------------------------------------------------
| Id | Operation | Name | Rows | Cost |
------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 4 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 1 | 4 |
|* 2 | INDEX RANGE SCAN | IDX | 1 | 3 |
------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("VAL"=1)
Note
-----
- cpu costing is off (consider enabling it)
***************************************
BASE STATISTICAL INFORMATION
***********************
Table Stats::
Table: T Alias: T
#Rows: 1000000 #Blks: 3106 AvgRowLen: 5.00
Index Stats::
Index: IDX Col#: 1
LVLS: 2 #LB: 4017 #DK: 3 LB/K: 1339.00 DB/K: 1035.00 CLUF: 3107.00
***************************************
SINGLE TABLE ACCESS PATH
-----------------------------------------
BEGIN Single Table Cardinality Estimation
-----------------------------------------
Column (#1): VAL(NUMBER)
AvgLen: 3.00 NDV: 3 Nulls: 0 Density: 5.0000e-07 Min: 1 Max: 3
Histogram: Freq #Bkts: 3 UncompBkts: 1000000 EndPtVals: 3
Table: T Alias: T
Card: Original: 1000000 Rounded: 1 Computed: 1.00 Non Adjusted: 1.00
-----------------------------------------
END Single Table Cardinality Estimation
-----------------------------------------
Access Path: TableScan
Cost: 300.00 Resp: 300.00 Degree: 0
Cost_io: 300.00 Cost_cpu: 0
Resp_io: 300.00 Resp_cpu: 0
Access Path: index (AllEqRange)
Index: IDX
resc_io: 4.00 resc_cpu: 0
ix_sel: 1.0000e-06 ix_sel_with_filters: 1.0000e-06
Cost: 4.00 Resp: 4.00 Degree: 1
Best:: AccessPath: IndexRange Index: IDX
Cost: 4.00 Degree: 1 Resp: 4.00 Card: 1.00 Bytes: 0
Be careful on selectivity, ix_sel: 1.0000e - 06
Cost of the FTS is always the same = 300,
but the cost of the Index Range Scan is now 4: 2 blocks from root/branch + block 1 sheet + 1 table blocks.
So, conclusion: histograms to calculate more accurate selectivity. The goal is to have more efficient execution plans.
Alexander Anokhin
http://alexanderanokhin.WordPress.com/
Tags: Database
Similar Questions
-
How to monitor the SQL perticuler using the INDEX or not?
I'm running on a long-term quary and the output is coming very late. So, I want to know that the quary sql uses the index or not? How do I know that?Hello
You have not provided your db version?
You can check v $ object_usage in a simple way. Try to check the explanation of your query if you current sql is by using your existing index or not.
Check with dbms_xplan.displayRequest to go through the links of Ask tom and jonathan lewis
http://jonathanlewis.WordPress.com/2007/02/15/index-not-used-10G/
http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:736825544526HTH
-Pounet N
-
I have problem with a query as follows. It does not index when I keep a function on the left side of the comparison in which the condition.
But when I remove the function is using the index.
With BLC AS Name Null? Type ----------------------------------------- -------- ---------------------------- ID NOT NULL NUMBER MASTER_VALUE NOT NULL NUMBER(8) DESC_TEXT_ID NUMBER GVM VARCHAR2(50) MASTER_LOOKUP_ID NOT NULL NUMBER WORK_SECTION_ID NUMBER AUDIT_TRAIL_NO NUMBER SQL> SELECT COUNT(*) FROM BLC; COUNT(*) ---------- 7769 SQL> SELECT COUNT(DISTINCT(GVM)) "distinct" FROM BLC; distinct ---------- 1350 SQL> SELECT COUNT(*) "nulls" FROM BLC WHERE GVM IS NULL; nulls ---------- 6419 SQL> SELECT COLUMN_NAME,INDEX_NAME FROM DBA_IND_COLUMNS WHERE TABLE_NAME='BLC'; COLUMN_NAME INDEX_NAME ---------------------------------------- ------------------------------ MASTER_LOOKUP_ID LKPCDE_MSTLKP_FK_I WORK_SECTION_ID LKPCDE_WRKSEC_FK_I GVM LKPCDE_UK MASTER_VALUE LKPCDE_MASTERID_VALUE_UK MASTER_LOOKUP_ID LKPCDE_MASTERID_VALUE_UK ID LKPCDE_PK SQL> EXPLAIN PLAN FOR SELECT ID FROM BLC WHERE UPPER ( GVM) = 'MAIN_ORG'; Explained. SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY); PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Plan hash value: 3196655606 -------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time| -------------------------------------------------------------------------------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 78 | 624 | 18 (0)| 00:00:01 | |* 1 | TABLE ACCESS FULL| BLC | 78 | 624 | 18 (0)| 00:00:01 | -------------------------------------------------------------------------------------- Predicate Information (identified by operation id): PLAN_TABLE_OUTPUT ----------------------------------------------------------------------------------------------------------------------------------- 1 - filter(UPPER("GVM")='MAIN_ORG') 13 rows selected. SQL> EXPLAIN PLAN FOR SELECT ID FROM BLC WHERE GVM = 'MAIN_ORG'; Explained. SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY); PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Plan hash value: 1620245961 -------------------------------------------------------------------------------- ---------------- | Id | Operation | Name | Rows | Bytes | Cost (% CPU)| Time | -------------------------------------------------------------------------------- ---------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 8 | 2 (0)| 00:00:01 | | 1 | TABLE ACCESS BY INDEX ROWID| BLC | 1 | 8 | 2 (0)| 00:00:01 | |* 2 | INDEX UNIQUE SCAN | LKPCDE_UK | 1 | | 1 (0)| 00:00:01 | -------------------------------------------------------------------------------- ---------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("GVM"='MAIN_ORG') 14 rows selected. SQL> EXPLAIN PLAN FOR SELECT /* INDEX(LKPCDE_UK) */ ID FROM BLC WHE RE UPPER ( GVM ) = 'MAIN_ORG'; Explained. SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY); PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Plan hash value: 3196655606 -------------------------------------------------------------------------------- ------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------- ------ PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 78 | 624 | 18 (0)| 00:0 0:01 | |* 1 | TABLE ACCESS FULL| BLC | 78 | 624 | 18 (0)| 00:0 0:01 | -------------------------------------------------------------------------------- ------ Predicate Information (identified by operation id): PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- --------------------------------------------------- 1 - filter(UPPER("GVM")='MAIN_ORG') 13 rows selected.
Please let me know how I can force it to use an index as it is causing the CPU usage.
I can't change the query in the application it is used in several places.
Thank you
And/or read: ORACLE-BASE - Oracle function index
-
SDO_NN cannot be assessed without using the index when put inside subquery
Hi all
I met a problem when you use the function sdo_nn to find the nearest neighbor. Here is my scenario:
_ I have 2 customer and store tables.
Customer table _ a client_ID and a 2D sdo_geom point
_ Store table has store_ID and a 2D polygon sdo_geom.
In the beginning, I have this query to find the nearest store to each customer as below:
Select s.STORE_ID, c.CLIENT_ID
store customer, s c
where sdo_nn (s.MYPOLYGON, c.MYPOINT, 'sdo_num_res = 1', 1) = "TRUE";
_It works as expected when it returns a table showing the nearest store each customer.
_Now I want to count the number of customers who have the same nearest store:
Select / * + INDEX (store store_spatial_idx, client_spatial_idx client) * / count (nearest_store. CLIENT_ID)
from (select s.STORE_ID, c.CLIENT_ID
store customer, s c
where sdo_nn (s.MYPOLYGON, c.MYPOINT, 'sdo_num_res = 1', 1) = "TRUE") nearest_store
Group of nearest_store. STORE_ID;
This query generates the following error:
Error report-
SQL error: ORA-13249: SDO_NN cannot be assessed without using the index
ORA-06512: at the 'MDSYS. MD", line 1723
ORA-06512: at the 'MDSYS. MDERR", line 17
ORA-06512: at the 'MDSYS. PRVT_IDX', line 9
13249 00000 - '%s '.
I'm pretty new to spatial databases and hope get help to go further. Thank you in advance!
Hello Pinball,
Oracle space tends to be a quite complex with many variables and moving parts. We chatted about the group to a sort of FAQ or guidelines to help people like you submit questions that actually answers. First of all, you really have to tell us the version of Oracle you are using. Particularly the problems involving the optimizer, version down to the exact defined patch number is a good idea. Secondly, you took the time to submit the question so I guess you want a response. If you really want to see the answer and then providing an example is one of the most important things that you can do. I'm going to do here for you, but in general people on this forum come and go and are often pushed into lurkitude, so if you want the coax to provide you with an example of work is the key.
DROP TABLE store1 PURGE; CREATE TABLE store1( store_id INTEGER NOT NULL ,shape MDSYS.SDO_GEOMETRY ,PRIMARY KEY(store_id) ); DROP TABLE client2 PURGE; CREATE TABLE client2( client_id INTEGER NOT NULL ,shape MDSYS.SDO_GEOMETRY ,PRIMARY KEY(client_id) ); CREATE OR REPLACE PROCEDURE seeder( p_client_count IN NUMBER ,p_store_count IN NUMBER ) AS sdo_foo MDSYS.SDO_GEOMETRY; int_counter NUMBER; FUNCTION random_point RETURN MDSYS.SDO_GEOMETRY AS num_x1 NUMBER; num_y1 NUMBER; BEGIN num_x1 := dbms_random.value(-179,179); num_y1 := dbms_random.value(-89,89); RETURN MDSYS.SDO_GEOMETRY( 2001 ,8265 ,MDSYS.SDO_POINT_TYPE( num_x1 ,num_y1 ,NULL ) ,NULL ,NULL ); END random_point; BEGIN int_counter := 1; FOR i IN 1 .. p_client_count LOOP -- Create a client point sdo_foo := random_point(); INSERT INTO client2 VALUES ( int_counter ,sdo_foo ); int_counter := int_counter + 1; END LOOP; int_counter := 1; FOR i IN 1 .. p_store_count LOOP -- Create a store polygon of some kind sdo_foo := MDSYS.SDO_GEOM.SDO_ARC_DENSIFY( MDSYS.SDO_GEOM.SDO_BUFFER( random_point() ,5000 ,0.05 ) ,0.05 ,'arc_tolerance=0.05' ); INSERT INTO store1 VALUES ( int_counter ,sdo_foo ); int_counter := int_counter + 1; END LOOP; COMMIT; END seeder; / BEGIN seeder(10000,200); END; / BEGIN INSERT INTO user_sdo_geom_metadata( table_name ,column_name ,diminfo ,srid ) VALUES ( 'STORE1' ,'SHAPE' ,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,.05),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,.05)) ,8265 ); COMMIT; EXCEPTION WHEN OTHERS THEN NULL; END; / BEGIN INSERT INTO user_sdo_geom_metadata( table_name ,column_name ,diminfo ,srid ) VALUES ( 'CLIENT2' ,'SHAPE' ,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,.05),MDSYS.SDO_DIM_ELEMENT('Y',-90,90,.05)) ,8265 ); COMMIT; EXCEPTION WHEN OTHERS THEN NULL; END; / CREATE INDEX store1_spx ON store1 (shape) INDEXTYPE IS MDSYS.SPATIAL_INDEX NOPARALLEL; CREATE INDEX client2_spx ON client2 (shape) INDEXTYPE IS MDSYS.SPATIAL_INDEX NOPARALLEL; /* Works as expected */ SELECT s.store_id ,c.client_id ,MDSYS.SDO_NN_DISTANCE(1) FROM store1 s ,client2 c WHERE MDSYS.SDO_NN( s.shape ,c.shape ,'sdo_num_res=1' ,1 ) = 'TRUE'; /* No worky? Works for me */ SELECT ns.store_id ,COUNT(ns.client_id) FROM ( SELECT s.store_id ,c.client_id FROM store1 s ,client2 c WHERE MDSYS.SDO_NN( s.shape ,c.shape ,'sdo_num_res=1' ,1 ) = 'TRUE' ) ns GROUP BY ns.store_id ORDER BY ns.store_id;
So I wrote this about 12 c (12.1.0.2.0) and everything works fine for me. Then I moved back from 11 GR 2 (11.2.0.4.0) and of course, there are questions. So I guess that you don't use flavor of 11g. So at this point we can look at the docs and see for 11g, have you often need to specify which table is the head and that is the one that has the spatial index to use.
http://docs.Oracle.com/CD/E11882_01/AppDev.112/e11830/sdo_operat.htm#SPATL1032Its rather interesting that the optimizer of 12 c knows what you want, when I had to squint myself at your request and to play a little with the refining. Note that SDO_NN is sensitive, because the geometry of the main table should come second in the operator. I did not know that on the top of my head.
SELECT /*+ LEADING(c) INDEX(s store1_spx) */ s.store_id ,c.client_id ,MDSYS.SDO_NN_DISTANCE(1) FROM store1 s ,client2 c WHERE MDSYS.SDO_NN( s.shape ,c.shape ,'sdo_num_res=1' ,1 ) = 'TRUE'; SELECT ns.store_id ,COUNT(ns.client_id) FROM ( SELECT /*+ LEADING(c) INDEX(s store1_spx) */ s.store_id ,c.client_id ,MDSYS.SDO_NN_DISTANCE(1) FROM store1 s ,client2 c WHERE MDSYS.SDO_NN( s.shape ,c.shape ,'sdo_num_res=1' ,1 ) = 'TRUE' ) ns GROUP BY ns.store_id ORDER BY ns.store_id;
So I think that is your answer. Give it a shot and see if this fits the Bill. Of course, moving to 12 c would be useful for such things. It would be interesting to collect more examples of this kind of space thing where 12 c is the answer. Also, would be nice if we could mark somehow this discussion as applying only to 11g and earlier versions.
See you soon,.
Paul
-
What is the right time to use the index with force?
I have an EMPLOYEE table. I join with the ROLE, and it has only about 200 distinct values on column EMPLOYEE. EMPLOYEE_TYPE_ID.
Select / * + INDEX (an i_employee_type_id) * / b.SID as EMP_NAME, b.role_cd in the ROLE
Of
EMPLOYEE,
B ROLE
where
a.EMPLOYEE_TYPE_ID = b.EMPLOYEE_TYPE_ID
AND a.EFFECTIVE_END_TS > = systimestamp;
Is it a good idea to use the index? .. Or let the full table scan.
SQL > select distinct EMPLOYEE_TYPE_ID of the EMPLOYEE;
238 selected lines.
If you don't know it will help not to use.
Personally, I found several SQLs with index finger tips (written by programmers thinking index access is ALWAYS GOOD) end up harming performance. Oracle made a reading diluvium full table scan, single index reads as follows, according to the % of the returned array it is actually faster to do a full table scan. The optimizer did a great job to determine this.
If you think there are cardinality estimation problems, and the optimizer expects a large number of lines when there are actually few being returned, in THIS case a suspicion was justified. Even so, in this case, I prefer that oracle manages the flag itself.
You can do this by running the SQL tuning advisor. In fact, it will trigger the optimizer checks that the estimates are turned off and it will create a profile for you. (A profile is actually a stored set of advice that set the execution plan for you). If at the point where the underlying data changes significantly and profile ends up hurting performance, you do not need to touch the code like you would with manually added notes, you can just disable or delete the profile and let the optimizer re - analyze the statement.
Concerning
EDIT: In case of small tables, it is preferable to just cache the whole table in the POOL to KEEP and let oracle scan if necessary.
Edit2: With the notable exception of index fast full scans, which are diluvium index readings. But they are only relevant when the request is quite satisfied by the index and has no need to visit the table.
-
SDO_NN giving ORA-13249: SDO_NN cannot be assessed without using the index
Hi people,
I do not understand why the SDO_NN gives ORA-13249 in circumstances.
SQL > SELECT SlavaTest WHERE SDO_NN s s.title (s.geometry, SDO_GEOMETRY (2001, 4326, SDO_POINT (14.0, 49.0, NULL), null, null)) = 'TRUE' and title like '%' and rownum < 10;
TITLE
--------------------------------------------------------------------------------
MultiPoint_305199
LineString_691779
MultiPolygon_180478
MultiPolygon_358113
MultiPolygon_53008
MultiPolygon_249905
MultiPolygon_204076
MultiPolygon_636994
MultiPoint_464514
9 selected lines.
SQL > SELECT SlavaTest WHERE SDO_NN s s.title (s.geometry, SDO_GEOMETRY (2001, 4326, SDO_POINT (14.0, 49.0, NULL), null, null)) = 'TRUE' and timestamp > = to_timestamp (January 6, 2011 ', ' dd/mm/yyyy') and rownum < 10;
SELECT SlavaTest WHERE SDO_NN s s.title (s.geometry, SDO_GEOMETRY (2001, 4326, SDO_POINT (14.0, 49.0, NULL), null, null)) = 'TRUE' and timestamp > = to_timestamp (January 6, 2011 ', ' dd/mm/yyyy') and rownum < 10
*
ERROR on line 1:
ORA-13249: SDO_NN cannot be assessed without using the index
ORA-06512: at the 'MDSYS. MD", line 1723
ORA-06512: at the 'MDSYS. MDERR", line 17
ORA-06512: at the 'MDSYS. PRVT_IDX', line 49
The spatial index is created with:
CREATE the INDEX SlavaTest_geometry_idx_spatial ON SlavaTest (geometry) INDEXTYPE IS mdsys.spatial_index;
'Title' and 'timestamp' columns have an index.
Note the query comes from Hibernate and I can't change it's arbitrary.Slava2 wrote:
What this means - there is a bug in Oracle?Well, it could probably be considered a, but [url http://docs.oracle.com/cd/E11882_01/appdev.112/e11830/sdo_operat.htm#i78067] documentation on SDO_NN warns you:
Documentation says:
However, if the column in the WHERE clause predicate specifies a non-space column in the table for geometry1 with an associated index, make sure that this index is not used by specifying the NO_INDEX indicator for this index.See you soon,.
Stefan -
SELECT on a table in the INSERT statement uses the INDEX
Hello world
I have a strange problem with EA Oracle 10 g (64-bit) running on a Linux system. The situation is, I developed a Java program to migrate one client system to another. One of the steps in the migration fills a new table with the data from the old system. Given that the data on the old system structure is fundamentally different from that new, I have to check each time I read a line from the old system, if I have already created an entity on the new table, and if so, update certain attributes. The WHERE clause of this audit uses a key of the company indexed on the new table. The problem is now, that Oracle does not use the index on the key attribute of the company, but it makes table scans complete to select the line. As you can imagine, the lines first thousand or so go fast, but the amount increases, the program becomes slower and slower.
If I do a "scan" when executing the migration program, Oracle change the execution plan and use the index on the attribute key and everything works fast and smooth. However, if I do the analysis on the empty table first, nothing changes (which I understand it perfectly, since there is nothing to analyze, at this point). By integrating a hint of 'INDEX' (table) in the statement SELECT does not change the full implementation plan (also table scans).
Is it possible to change this behavior, in order to SELECT it uses the index of key business from the beginning?
Greetings from Cologne,
Thorsten.
Published by: thkitz on 13.03.2012 18:27thkitz wrote:
SELECT STATEMENT ALL_ROWSCost: 2 Bytes: 76 Cardinality: 2 7 TABLE ACCESS BY INDEX ROWID TABLE AIDATINT.PRVVSSCHADENKORRESPONDENZ Cost: 2 Bytes: 76 Cardinality: 2 6 BITMAP CONVERSION TO ROWIDS 5 BITMAP OR 2 BITMAP CONVERSION FROM ROWIDS 1 INDEX RANGE SCAN INDEX AIDATINT.I_PRVVSSCHADENKORRESPONDENZ_1 Cost: 1 4 BITMAP CONVERSION FROM ROWIDS 3 INDEX RANGE SCAN INDEX AIDATINT.I_PRVVSSCHADENKORRESPONDENZ_2 Cost: 1
I would have thought that as a plan as possible. It is not a concatenation, is a btree/bitmap conversion.
Allude to this plan you need / * + index_combine (table_alias index1 index2) * /.
For 10g and later the index can be specified by name or by descriptionI'm a bit puzzled why the plan changes after truncate - but maybe my comment about not cleared statistics is no longer true. It is easy enough to check if I'm right or wrong on your version of Oracle.
Concerning
Jonathan Lewis
http://jonathanlewis.WordPress.com
Author: core Oracle -
How do you download InDesign using the Adobe Download Manager?
How do you download InDesign using the Adobe Download Manager?
With Adobe Download Wizard installed, you should be able to start the download at http://www.adobe.com/cfusion/tdrc/index.cfm?product=indesign. If this doesn't work for you then please try another browser.
-
Using the index of multiple values
Hi guys,.
Trying to assess the benefits of the addition of index of multiple values, a quick question on the index of multiple values:
Here's my content from the cache:
Key (EmpID), value [employee (age int, double salary, Department of String)]
(1, new employee (25, 35000.0, "Admin"));
(2, new employee (22, 30000.0, "Admin"));
(3, new employee (34, 40000.0, 'Communications'));
(4, new employee (36, 41000.0, "Admin"));
(5, new employee (36, 42000.0, "HR"));
(6, new employee (29, 30000.0, "HR"));
(7, new employee (51, 50000.0, "BackOffice"));
(8, new employee (36, 35000.0, "HR"));
(9, new employee (46, 45000.0, "Admin"));
(10, new employee (48, 47000.0, "HR"));
If I still want to find all employees in the 'Human resources' Department and whose salary is more than 35000.
Eventually, I would like to do the following:
ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
ValueExtractor depExtractor = new PofExtractor (String.class, 3);
cache.addIndex (salExtractor, false, null);
cache.addIndex (depExtractor, false, null);
EqualsFilter departmentFilter = new EqualsFilter (depExtractor, 'HR');
GreaterFilter salFilter = new GreaterFilter (salExtractor, 35000);
Filter allFilter = new AllFilter (new filter [] {departmentFilter, salFilter});
Employees value = cache.entrySet (allFilter));
For my usecase above how can I use the indexing of multiple values to the same query?
ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
ValueExtractor depExtractor = new PofExtractor (String.class, 3);
MultiExtractor mExtractor is new MultiExtractor (new ValueExtractor [] {salExtractor, depExtractor});.
cache.addIndex (mExtractor, false, null);
But how can I use the extractor to create multivalued filter queries for employees in the Department of human resources with greater than 35000 salary? Any ideas are much appreciated.
Thank youD wrote:
Hi guys,.Trying to assess the benefits of the addition of index of multiple values, a quick question on the index of multiple values:
Here's my content from the cache:
Key (EmpID), value [employee (age int, double salary, Department of String)]
(1, new employee (25, 35000.0, "Admin"));
(2, new employee (22, 30000.0, "Admin"));
(3, new employee (34, 40000.0, 'Communications'));
(4, new employee (36, 41000.0, "Admin"));
(5, new employee (36, 42000.0, "HR"));
(6, new employee (29, 30000.0, "HR"));
(7, new employee (51, 50000.0, "BackOffice"));
(8, new employee (36, 35000.0, "HR"));
(9, new employee (46, 45000.0, "Admin"));
(10, new employee (48, 47000.0, "HR"));If I still want to find all employees in the 'Human resources' Department and whose salary is more than 35000.
Eventually, I would like to do the following:
ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
ValueExtractor depExtractor = new PofExtractor (String.class, 3);
cache.addIndex (salExtractor, false, null);
cache.addIndex (depExtractor, false, null);EqualsFilter departmentFilter = new EqualsFilter (depExtractor, 'HR');
GreaterFilter salFilter = new GreaterFilter (salExtractor, 35000);
Filter allFilter = new AllFilter (new filter [] {departmentFilter, salFilter});
Employees value = cache.entrySet (allFilter));For my usecase above how can I use the indexing of multiple values to the same query?
ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
ValueExtractor depExtractor = new PofExtractor (String.class, 3);
MultiExtractor mExtractor is new MultiExtractor (new ValueExtractor [] {salExtractor, depExtractor});.
cache.addIndex (mExtractor, false, null);But how can I use the extractor to create multivalued filter queries for employees in the Department of human resources with greater than 35000 salary? Any ideas are much appreciated.
Thank you
I remember, values multiple index refers to a different concept: a multivalued index means that you can retrieve a collection of values of similar role of an attribute on which you can do Contains, ContainsAll filtering, and ContainsAny.
In this case to fully the lever consistency of querying capabilities, you would
- either add a sorted index with a custom comparator that compares the tables containing a salary and a Department on a first salary so the base of the Department and add a filter custom which is able to take advantage of the index for the request for the salary and also able to filter on the element of the array of index service
-Add two independent indices (a sorted index of wages and a unsorted for the Department), in which case you can leverage all existing (GreaterThanFilter, EqualsFilter and AndFilter) codeBest regards
Robert
-
Urgent: How to navigate through records using the ReadOnly ADF form
Hi guru,.
I'm new to ADF.
I have a requirement where I need to display the records 'ADF read only form' where my query retrieve multiple records, now I want to browse all the record as we do in the table of the ADF. How can I achieve this using the Readonly ADF form.
Please suggest me emergency.
Thank you
SPCYou can also drag and drop on Next, Previous, first, last from the data control panel like buttons (it comes under the node for the data collection operations),
A lot of this is covered in the book that I wrote to help people to start learning oracle ADF and Jdeveloperhttp://www.mhprofessional.com/product.php?ISBN=0071744282
-
SDO_NN cannot be assessed without using the index
Hello
I'll try to find more close neighbours of a point using two tables (grafo_ped_links & haltestellen) and I fail miserably quiet.
Select h.desc_i, grafo_ped_links h.numpal g, haltestellen h where (g.geometry, h.geometry) sdo_nn = 'true' and g.start_node_id = 355 and rownum < = 5
*
ERROR on line 1:
ORA-13249: SDO_NN cannot be assessed without using the index
ORA-06512: at the 'MDSYS. MD", line 1723
ORA-06512: at the 'MDSYS. MDERR", line 17
ORA-06512: at the 'MDSYS. PRVT_IDX', line 49
But I am able to find the nearest neighbor on individual tables (singularly) without any problem. I'm even able to find a WITHIN_DISTANCE using two tables (below the sql statement).
Select h.numpal from grafo_ped_links g, haltestellen h where SDO_WITHIN_DISTANCE (h.geometry, g.geometry, 'DISTANCE = 0.5 UNIT = KM') = 'TRUE' and g.start_node_id = 355;
NUMPAL
----------
5122
5103
5102
5120
5100
5301
5302
5303
I even dropped the indexes of the two tables and recreated them again. I read somewhere that the problem could be due to a lack of advice, so I tried the following and I still get the same error.
Select / * + LEADING (g) INDEX (h haltestellen_ridx) * / h.desc_i, h.numpal
of grafo_ped_links g, h haltestellen
where (g.geometry, h.geometry) sdo_nn = 'true' and g.start_node_id = 355 and rownum < = 5
Select / * + INDEX (h haltestellen_ridx) NO_INDEX (g grafo_ped_links_ridx) * / h.desc_i, h.numpal
of grafo_ped_links g, h haltestellen
where (g.geometry, h.geometry) sdo_nn = 'true' and g.start_node_id = 355 and rownum < = 5
Select / * + USE_NL (h, g) VALUE * / h.desc_i, h.numpal
of grafo_ped_links g, h haltestellen
where sdo_nn (g.geometry, h.geometry, 'sdo_num_res = 5', 1) = 'true' and g.start_node_id = 355 and rownum < = 5
Anyone can please, show me the way, or give a hint. I use oracle spatial 11g.
Thank you!
Cook
Published by: user611283 on December 30, 2009 06:11It should be 'TRUE '.
Select h.desc_i, grafo_ped_links h.numpal g, haltestellen h where (h.geometry, g.geometry) sdo_nn = 'TRUE' and g.start_node_id = 355 and rownum<=>=>
-
Hi all
Version of DB: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
Here is the description of the problem:
(The statistics are up to date for all tables).
The query below does not use the index on ACCOUNTS_LIVE (ID). (Unique index)
Line 23 of the query uses accounts_live.id.SQL> explain plan for 2 select txn.account_number,to_number(txn.amount_lcy) txn_amt,to_date(booking_date,'YYYYMMDD') TXN_DATE, 3 sal.latest_sal,sal.sal_date,customer_name,employer_name, 4 decode(COMMUNICATION_TYPE_1,'MOBILE',COMMUNICATION_NO_1, 5 decode(COMMUNICATION_TYPE_2,'MOBILE',COMMUNICATION_NO_2)) mob, 6 txn.CURRENCY, CHEQUE_NUMBER,trans_dets,trans_reference,target,teller_id,acc.category,acc.inactive_marker, 7 acc.posting_restrict,cus.sector,cus.industry 8 from coreadmin.Gtxn_dtl_v1 txn, 9 (select account_number,round(to_number(nvl(amount_lcy,0)),2) latest_sal,TXN_DATE sal_date,rr 10 from 11 (select to_date(booking_date,'YYYYMMDD') TXN_DATE,batch_id,account_number,amount_lcy 12 ,row_number() over (partition by account_number 13 order by to_date(booking_date,'YYYYMMDD') desc NULLS LAST, 14 batch_id desc nulls last) rr, 15 CURRENCY, CHEQUE_NUMBER,trans_dets,trans_reference 16 from coreadmin.Gtxn_dtl_v1 17 where transaction_code in ('204','938') 18 and to_number(amount_lcy) > 0) 19 where rr = 1 20 ) sal,accounts_live acc,customers_live cus 21 where to_date(booking_date,'YYYYMMDD') between to_date('030109','DDMMRR') and to_date('020209','DDMMRR') 22 and txn.account_number = sal.account_number 23 and txn.account_number = acc.id 24 and txn.CUSTOMER_ID = cus.CUSTOMER_number 25 and target in ('30','31','32') 26 / Explained. SQL> select * from table(dbms_xplan.display); PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------ Plan hash value: 920245766 ----------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | ----------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 363M| 121G| | 223K (4)| 00:44:47 | |* 1 | HASH JOIN | | 363M| 121G| 6232K| 223K (4)| 00:44:47 | |* 2 | VIEW | | 34453 | 5820K| | 147K (1)| 00:29:36 | |* 3 | WINDOW SORT PUSHED RANK | | 34453 | 1480K| 4072K| 147K (1)| 00:29:36 | |* 4 | FILTER | | | | | | | | 5 | INLIST ITERATOR | | | | | | | |* 6 | TABLE ACCESS BY INDEX ROWID| GTXN_DTL_V1 | 34453 | 1480K| | 147K (1)| 00:29:31 | |* 7 | INDEX RANGE SCAN | IDX_TXN5 | 707K| | | 1815 (2)| 00:00:22 | |* 8 | HASH JOIN | | 598K| 106M| 20M| 63724 (1)| 00:12:45 | |* 9 | MAT_VIEW ACCESS FULL | CUSTOMERS_LIVE | 227K| 17M| | 2239 (4)| 00:00:27 | |* 10 | HASH JOIN | | 598K| 59M| 9504K| 57157 (1)| 00:11:26 | | 11 | MAT_VIEW ACCESS FULL | ACCOUNTS_LIVE | 249K| 6577K| | 1832 (2)| 00:00:22 | |* 12 | TABLE ACCESS BY INDEX ROWID | GTXN_DTL_V1 | 597K| 43M| | 52319 (1)| 00:10:28 | |* 13 | INDEX RANGE SCAN | IDX_TXN11_V1 | 1204K| | | 3931 (2)| 00:00:48 | ----------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - access("TXN"."ACCOUNT_NUMBER"="ACCOUNT_NUMBER") 2 - filter("RR"=1) 3 - filter(ROW_NUMBER() OVER ( PARTITION BY "ACCOUNT_NUMBER" ORDER BY TO_DATE("BOOKING_DATE",'YYYYMMDD') DESC NULLS LAST,INTERNAL_FUNCTION("BATCH_ID") DESC NULLS LAST)<=1) 4 - filter(TO_DATE('030109','DDMMRR')<=TO_DATE('020209','DDMMRR')) 6 - filter(TO_NUMBER("AMOUNT_LCY")>0) 7 - access("TRANSACTION_CODE"='204' OR "TRANSACTION_CODE"='938') 8 - access("TXN"."CUSTOMER_ID"="CUS"."CUSTOMER_NUMBER") 9 - filter("TARGET"='30' OR "TARGET"='31' OR "TARGET"='32') 10 - access("TXN"."ACCOUNT_NUMBER"="ACC"."ID") 12 - filter("TXN"."CUSTOMER_ID" IS NOT NULL) 13 - access(TO_DATE("BOOKING_DATE",'YYYYMMDD')>=TO_DATE('030109','DDMMRR') AND TO_DATE("BOOKING_DATE",'YYYYMMDD')<=TO_DATE('020209','DDMMRR')) 38 rows selected. SQL> select index_name 2 from dba_ind_columns 3 where table_name = 'ACCOUNTS_LIVE' 4 and column_name = 'ID'; INDEX_NAME ------------------------------ IDX_ACCLIVE
11 the order ID explain plan shows that the index does not use.
Please suggest.
Thanks in advance,
JacWhat happens when you force the index by using hint and use the hash between txn and acc join?
See you soon
Sarma. -
My two front USB slots don't work. How to decide what could be the problem? The machine is a HP Pavilion p6516f-b. Thank you
try to uninstall the drivers (usb root hub) from Device Manager, restart the pc if you see little red or yellow circles can mean the mistake with the equipment. see if the keyboard works in ports
-
How can I reset passwords using the hidden administrator account?
Original title: hidden admin account
How can you reset pass using the hidden account dmin. ? That can make the admin account hidden?
I have windows vista and I am the only administrator and user of my laptop.
Hello
You cannot use the hidden administrator account to reset the password. If you forget your only means of password to reset using the password reset disk. See the article below for further assistance.
What to do if you forget your Windows password
http://Windows.Microsoft.com/en-us/Windows-Vista/what-to-do-if-you-forget-your-Windows-passwordActivate hidden administrator account gives you access to the files or the privileges if you are denied access in some cases.
Hope this information helps.
Thank you, and in what concerns:
Shekhar S - Microsoft technical support.Visit our Microsoft answers feedback Forum and let us know what you think.
If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly. -
How to create IT strategy using the BES administrator API
Hi all
Can tell me, how to create IT strategy using the BES administrator API.
Please provide me with the code example.
Thanks in advance.
Kind regards
Sampath
Hi Sebastian,.
The Administration of BlackBerry API does not support the creation of it political. This feature is currently with the development of control and review for a future version of the BlackBerry Web Services for the Administration of the company.
Kind regards
Maybe you are looking for
-
Placement of video on a photographic background
I have imovie 10.1.1 installed on my mac. I have a simple task that is confusing to me. I want to place a video on a background of photo so that I can crop the video to fit the photo using the photo as a frame. I tried to do, but keep. I'm unable to
-
Need Gmail application for dashboard
The Gmail application that has been installed for Sony Dash does not work. I had to constantly re-enable/turn on pop and IMAP and it works for 5 minutes. I tried to use the viewer of standard e-mail with Gmail and it does not work either.
-
My computer has a slow start and is slow running.
Hi I'm not a wiz kid so any help would be helpful thanks
-
How update for adobe flash player for your myspace _
I've been trying to finish that peace _ long since someone can help
-
Hello I have a HP Compaq 6735 s, I'm looking for a recovery disc for Windows XP. Can someone help me please.