Function index and user_tab_cols
Why an entry is created in user_tab_cols when we create a function based on a column in a table?
create table t1(a varchar2(100), b number);
select * from user_tab_cols where table_name = 'T1'; -- Two rows coming
create index idx1 on t1(upper(a));
select * from user_tab_cols where table_name = 'T1'; -- Three rows coming
What is the reason to put an entry in user_tab_cols?
Martin Preiss wrote:
If I remember correctly there is also a VIRTUAL_COLUMN attribute in % _TAB_COLS (at least since 11.1).
Yes, there is, but how it would be useful to determine if the column is the index of based function related? All not stored in the disk column is a virtual column:
SQL > create table (tbl)
Number 2,
3 the number n
4 )
5.
Table created.
SQL > create index tbl_idx1 on tbl (abs (n));
The index is created.
SQL > alter table tbl
2. Add n_ceil number generated always as (ceil (n));
Modified table.
SQL > alter table tbl change invisible n_ceil;
Modified table.
SQL > create index tbl_idx2 on tbl (n_ceil);
The index is created.
SQL > select column_id,.
2 column_name
virtual_column 3,.
4 hidden_column
5 to user_tab_cols
6 where table_name = "TBL";
COLUMN_ID COLUMN_NAME HIDDEN VIR
---------- ------------------------------ --- ---
1 ID NO NO
2 N NO NO
SYS_NC00003$ YES YES
N_CEIL YES YES
SQL >
As you can see, the two SYS_NC00003$ and N_CEIL are hidden, virtual columns. This part is the same regardless of the version. And in 12 c with the invisible support of solumn, you can't count on the id of null column. That's why (or at least one of the reasons) Oracle introduced another column in the view _TAB_COLS in 12 c - USER_GENERATED:
SQL > select column_id,.
2 column_name
virtual_column 3,.
hidden_column 4,.
5 user_generated
user_tab_cols 6
7 where table_name = "TBL";
COLUMN_ID COLUMN_NAME VIR HID USE
---------- ------------------------------ --- --- ---
1 NOT ONLY ID YES
2 N NO NO YES
SYS_NC00003$ YES YES NO
N_CEIL YES YES YES
SQL >
Now, we can say column SYS_NC00003$ is related FBI.
SY.
Tags: Database
Similar Questions
-
Function Index and Query Rewrite
Hi members,
I just stumbled on something that I've never thought of before.
It has to do with the function according to index and (possibly re - write query)
Here is my configuration:
So, I created a small table with a FBI.SQL> create table tab1 ( 2 x varchar2 (1) default 'N' not null check (x in ('Y', 'N')), 3 y varchar2 (100) not null 4 ); Table created. SQL> create index tab1ix on tab1 (NULLIF(x,'N')); Index created. SQL> insert into tab1 (y) 2 (select rpad (level,100,'x') from dual connect by level <= 1000); 1000 rows created. SQL> insert into tab1 (x,y) values ('Y', 'Hello there'); 1 row created. SQL> commit 2 / Commit complete. SQL> exec dbms_stats.gather_table_stats(user, 'tab1', cascade => true) PL/SQL procedure successfully completed.
Now, let's use it.
The first is a query that obviously do not use it.
Second, one is a query that corresponds to the FBI.
No worries, right?SQL> explain plan 2 set statement_id = 'st1' 3 into plan_table 4 for 5 select * from tab1 where x = 'Y'; Explained. SQL> SQL> select plan_table_output 2 from table(dbms_xplan.display('PLAN_TABLE', 'st1','TYPICAL')); PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- ---------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | ---------------------------------------------------------- | 0 | SELECT STATEMENT | | 501 | 51603 | 5 | | 1 | TABLE ACCESS FULL| TAB1 | 501 | 51603 | 5 | ---------------------------------------------------------- SQL> explain plan 2 set statement_id = 'st2' 3 into plan_table 4 for 5 select * from tab1 where NULLIF(x,'N') = 'Y'; Explained. SQL> SQL> select plan_table_output 2 from table(dbms_xplan.display('PLAN_TABLE', 'st2','TYPICAL')); PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- ---------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | ---------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 103 | 1 | | 1 | TABLE ACCESS BY INDEX ROWID| TAB1 | 1 | 103 | 1 | | 2 | INDEX RANGE SCAN | TAB1IX | 1 | | 1 | ---------------------------------------------------------------------- SQL>
Everything works as expected, when my predicate corresponds to the FBI, the index is used.
But here's what surprises me. It seems that the index expression is rewritten then it is created:
Questions are now, is this safe? -Does still work?SQL> select column_expression from user_ind_expressions 2 where index_name = 'TAB1IX'; COLUMN_EXPRESSION -------------------------------------------------------------------------------- CASE "X" WHEN 'N' THEN NULL ELSE "X" END SQL>
Can I trust the optimizer always did a rewrite such as performed when the index was created?
This index might live throughout the years and many versions of the optimizer. But the expression stays (I guess)
This is going into production this weekend, so I wanted to hear,
ideas / comments?
Best regards
Peter
PS: NULLIF is nothing else than a syntactic sugar for the CASE expression equivalent?SQL> select *from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi PL/SQL Release 10.2.0.3.0 - Production CORE 10.2.0.3.0 Production TNS for Linux: Version 10.2.0.3.0 - Production NLSRTL Version 10.2.0.3.0 - Production
docs say:The NULLIF function is logically equivalent to the following CASE expression:
edited by: Peter on February 9, 2012 05:32
CASE WHEN expr1 = END expr1 expr2 THEN NULL ELSEHi Peter
In the docs for NULLIF, he said
The NULLIF function is logically equivalent to the following CASE expression:
CASE WHEN expr1 = expr THEN ELSE NULL expr1 END 2
http://docs.Oracle.com/CD/B10501_01/server.920/a96540/functions85a.htm
http://docs.Oracle.com/CD/B19306_01/server.102/b14200/functions102.htm
http://docs.Oracle.com/CD/E11882_01/server.112/e26088/functions116.htmWhich would explain the behavior you saw. As you pointed out, it is possible that the transformation of NULLIF expression BOX equivalent is likely to change? It seems unlikely - indeed, it seems to be an alias or a macro for the instruction box unless there is some way technically superior to implement this logic, it seems to be here to stay. Certainly, it has remained unchanged since the 9i.
Not sure how that helps.
David
-
Function index and virtual columns
I just read the documentation of Oracle on the FBI. In the context of optimization with a function-based index, it is said that "a virtual column is useful for speed of access to data from expressions.". Here is the link Index-Organized Tables and indexes.
My question is, does Oracle already not create a virtual column when we create a function-based index?
Concerning
Charlie
Hi CharlieYes, the database engine creates a virtual column. But this column is hidden. Reproduced in 11.2.0.3 example:SQL> CREATE TABLE t (n NUMBER);SQL> CREATE INDEX i ON t (round(n,0)); SQL> SELECT column_name, hidden_column, virtual_column 2 FROM user_tab_cols 3 WHERE table_name = 'T'; COLUMN_NAME HIDDEN VIR ------------------------------ ------ --- N NO NO SYS_NC00002$ YES YES
HTH
Chris Antognini
Troubleshooting performance Oracle, Apress 2008/2014
-
Indexing and the integrity constraint functionality difference
Hello
Sometimes I confuse me, how we can distinguish between indexing and the integrity of the features of constraint. Please let me know or if any available doc.
Kind regards
REDAI assume you mean unique vs unique index constraints?
The sole (or Primary Key) constraints provide additional metadata that can be used by the optimizer.
An index will be used to help the database to apply the constraint (it is created, or if there is it will be "captured" by coercion)Insofar as a document [url http://docs.oracle.com/cd/E11882_01/server.112/e25789/toc.htm] that's something, you should read
-
I'm reviewing an existing table in a database Oracle 11g and I do not understand a function based index that was created. The syntax is less than
CREATE INDEX abc. Orders_Date on abc. ORDERS
(CASE WHERE "ORDER_DATE" IS NOT NULL THEN "ORDER_DATE" ELSE NULL END)
LOGGING;
This table has about 90 000 lines with 32 000 values distinct order_date, 3000 lines have order_dates null. When you run a query on this table using the order_date column it makes a full table scan.
What does this function index based? because I do not see how it adds all the required features
Thank you
As others have said, this index is actually right on order_date, however, is a core function so it cannot be used in queries that use CASES WHEN "ORDER_DATE" IS NOT NULL THEN END NO OTHER "ORDER_DATE."
It is assumed that it might be possible that there is an index on (order_date) but it was found that it was used in the sql queries, which would have preferred to use other indexes. Some queries benefits so maybe that option based function was created as the sql must refer to the phrase exactly, requests that have received have been rewritten and others were left so that they could avoid the new index of the index.
Of course, if this were the case then maybe you can take a look at your stats.
-
Function Index problem.
Hello
I have a problem regarding a function function index.
example:
TableName: Test
Column: A, B, C, D
I create the index on the table, column, a test using a user-defined function.
If I do a select on the column, he'll be fine. In other words, I'll get the results you want.
However, if I insert in the table and validation, and I do a query using the 'A' column in the where clause. I don't have any query hits. Its really weird.
Have you ever experienced this problem? and is there an index of function according to back and donts w.r.t.?
Thank you.
MichaelR
If you use a deterministic function really, it works:
create or replace function test_fn (p_number number) return number deterministic is vreturn number := 0; begin if p_number = 1 then vreturn := 55; end if; if p_number = 2 then vreturn := 89; end if; return vreturn; end;
Or, if you reverse the order of your second inserts (insert the folder before the recording of test1 test2) - it works fine.
The reason why you get no results is when you insert the file test1 with a = 2, Oracle executes the function and gets no data, so it assumes that the result is NULL and puts in the index. You said Oracle function is deterministic, so he starts from the principle that any time test_fn (2) is called, it retrieves a null response.
-
Question:
Fixes IE11 and Chrome on the Adobe web site ask you to put their new files in RoboHTML templates_stock folder. However, I need these fixes for RoboHelp for Word. Is there a such difficulty?
Background:
I use 10 RoboHelp for Word, generating WebHelp.
I try to solve the problems about the table of contents, Index, and search appears not not or not being not completely functional IE11 or Chrome, not including many of our customers use. I found a couple of workarounds that my boss doesn't like.
- In IE11, if the end user adds the web site to the compatibility view list, they all appear and function correctly, but my boss is adamant about not wanting the end user having to do anything to solve the problem.
- In Chrome, I can get a table of contents and a non-functional search to appear if the user turns off JavaScript for the site, but this solution also violates the lists see also in help. Again, made my boss wants to not that the end user to have to do.
His solution is just to generate using pure HTML, but then the search won't work in IE11 or Chrome (I'm not sure about Firefox). I are based largely on the research, when I'm working on the product, so I really don't want to lose the search function.
Help, please.
Kind regards
Jenn
As I said in my reply to your message in the RoboHelp for Word forum, there is no patch for this.
I can understand your not wanting to Manager end users will do anything and agree with him. However, the fixes for these issues in HTML HR are simply not available in RoboHelp for Word.
See www.grainge.org for creating tips and RoboHelp
-
SQL tuning advisor recommnds to create the function SYS_OP_C2C function index
I have a large table and an index on it. I use a tool to fill data, this simple tool submits the sql for Oracle DB and it does NOT index to use for requests. When I run the sql tuning advisor, he recommends to create additional indexes and use the SYS_OP_C2C function, which I don't want.
When I run the query through sql plus picks it up in the index.
Someone of you came, why its recommend that additional nonsense?
create index abc.xxxx on this_table (SYS_OP_C2C ("this_column"));
Thank youThe internal Oracle SYS_OP_C2C function perform the conversion of a set of characters to another set of characters - C (haracterSet) 2 c (haracterSet). There are situations where you will see this conversion without explicit, as in this case command that should be a sign that the data types are not the same and the implicit conversion takes place and this could also be a problem from the point of view performance because it can disable the use of the index.
Make sure you the characterset and nls set of all of the database and the tool are the same.
Make sure that the data type of the column in the index is the same as the database.
Confirm the ETL vendor for your database support and fixes, etc..Optimizer will only advise to use this function when the data type or the character set does not match.
Thank you
Kerry -
index and exponent with the text field dynamic flash
Hi all
Is there a function / TextFormat property / property textField to text index and exponent.
I have to write @,®,TM , 1025 ABC type of value which are in fact from xml file.
Thanks in advance!
Kishor
Yes, you need to use special fonts for this purpose
-
RoboHelp 5.0 - indexing and search problems
Hello
I use RoboHelp HTML 5.0.2 and I'm having problems with the Index and search functions.
1 index: whenever I click on the key Index Designer icon in RoboHelp, the system hangs. By clicking on the Smart Wizard of Index in the menu Tools will give the same result. We can give up to have an index on our help site, but I wonder if this problem is somehow related to our research questions.
2. search: search terms as we enter do appear which seems to be random results. As a general rule, the search term does not appear in the results pages, while other pages that do not contain the term are not displayed.
Could our version of RoboHelp has been corrupted, or is there something else we can try?
Thank you!
Connie
Hi Connie.
Where are the sources files located? It is good practice not to do on a network drive, because this can cause file corruption. Try moving them to a local drive.
-
Why cannot avoid the sort ORDER BY STOPKEY function index
SQL> alter session set nls_language=american; Session altered. SQL> create table test_sort(name,object_name) as select 'select',object_name from 2 dba_objects; Table created. SQL> create index i_test_sort_1 on test_sort(substr(name,0,3),object_name); Index created. SQL> exec dbms_stats.gather_table_stats(user,'TEST_SORT'); PL/SQL procedure successfully completed. SQL> set autot trace SQL> select * from (select * from test_sort where substr(name,0,3)='sel' order by 2 object_name) where rownum<11; 10 rows selected. Execution Plan ---------------------------------------------------------- Plan hash value: 4202652051 -------------------------------------------------------------------------------- ------------- | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU )| Time | -------------------------------------------------------------------------------- ------------- | 0 | SELECT STATEMENT | | 10 | 740 | | 504 (3 )| 00:00:07 | |* 1 | COUNT STOPKEY | | | | | | | | 2 | VIEW | | 49902 | 3606K| | 504 (3 )| 00:00:07 | |* 3 | SORT ORDER BY STOPKEY| | 49902 | 1559K| 3928K| 504 (3 )| 00:00:07 | |* 4 | TABLE ACCESS FULL | TEST_SORT | 49902 | 1559K| | 60 (5 )| 00:00:01 | -------------------------------------------------------------------------------- ------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter(ROWNUM<11) 3 - filter(ROWNUM<11) 4 - filter(SUBSTR("NAME",0,3)='sel') Statistics ---------------------------------------------------------- 139 recursive calls 0 db block gets 279 consistent gets 0 physical reads 0 redo size 695 bytes sent via SQL*Net to client 400 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 5 sorts (memory) 0 sorts (disk) 10 rows processed sql doesn't choose index ,so I use hint to force oracle choose index SQL> select * from (select /*+ index(test_sort) */ * from test_sort where substr(name,0,3)='sel' 2 order by object_name) where rownum<11; 10 rows selected. Execution Plan ---------------------------------------------------------- Plan hash value: 1978014138 -------------------------------------------------------------------------------- ------------------------ | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | -------------------------------------------------------------------------------- ------------------------ | 0 | SELECT STATEMENT | | 10 | 740 | | 22869 (1)| 00:04:35 | |* 1 | COUNT STOPKEY | | | | | | | | 2 | VIEW | | 49902 | 3606K| | 22869 (1)| 00:04:35 | |* 3 | SORT ORDER BY STOPKEY | | 49902 | 1559K| 3928K| 22869 (1)| 00:04:35 | | 4 | TABLE ACCESS BY INDEX ROWID| TEST_SORT | 49902 | 1559K| | 22424 (1)| 00:04:30 | |* 5 | INDEX RANGE SCAN | I_TEST_SORT_1 | 49902 | | | 278 (1)| 00:00:04 | -------------------------------------------------------------------------------- ------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter(ROWNUM<11) 3 - filter(ROWNUM<11) 5 - access(SUBSTR("NAME",0,3)='sel') Statistics ---------------------------------------------------------- 1 recursive calls 0 db block gets 22393 consistent gets 0 physical reads 0 redo size 695 bytes sent via SQL*Net to client 400 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 1 sorts (memory) 0 sorts (disk) 10 rows processed From the explain ,the sql chooses the index,but SORT ORDER BY STOPKEY doesn't avoid,so oracle must read all rows satisfy substr(name,0,3)='sel' ,the I rewrite the sql as the following,we can see that sort ORDER BY STOPKEY does't happen,so oracle return 10 rows fast. SQL> select * from (select /*+ index(test_sort) */ * from test_sort where substr(name,0,3)='sel' 2 order by substr(name,0,3),object_name) where rownum<11; 10 rows selected. Execution Plan ---------------------------------------------------------- Plan hash value: 4154852915 -------------------------------------------------------------------------------- --------------- | Id | Operation | Name | Rows | Bytes | Cost (%C PU)| Time | -------------------------------------------------------------------------------- --------------- | 0 | SELECT STATEMENT | | 10 | 740 | 8 (0)| 00:00:01 | |* 1 | COUNT STOPKEY | | | | | | | 2 | VIEW | | 10 | 740 | 8 (0)| 00:00:01 | | 3 | TABLE ACCESS BY INDEX ROWID| TEST_SORT | 49902 | 1559K| 8 (0)| 00:00:01 | |* 4 | INDEX RANGE SCAN | I_TEST_SORT_1 | 10 | | 3 (0)| 00:00:01 | -------------------------------------------------------------------------------- --------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter(ROWNUM<11) 4 - access(SUBSTR("NAME",0,3)='sel') filter(SUBSTR("NAME",0,3)='sel') Statistics ---------------------------------------------------------- 1 recursive calls 0 db block gets 11 consistent gets 0 physical reads 0 redo size 695 bytes sent via SQL*Net to client 400 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 10 rows processed
Jinyu wrote:
Hi, I think that this may be an optimizer bug 10g or flaw optimizer 10 g, although substr (name, 0, 3) = 'salt' is not selective, but oracle can also use indexes to find the top 10 by object_name result orderJinyu,
Indeed, it seems to be a gap in the mode of optimization 10.2 FIRST_ROWS_n. I could reproduce your problem in 10.2.0.4 and watching the 10053 trace, it looks like that the optimizer does not consider the option "Recost for ORDER (with the HELP of indexes)" where you have a composite index based function. It does when using a 'normal' composite index, and it does - as you mentioned - when using the main column in the ORDER BY expression as well. You don't need to use INDEX indicator in this case, moreover, the recosting for ORDER BY then works very well and chooses the index without specified indicators.
11 g the "recalculate for ORDER BY" appears again in the first place it looks like an obvious limitation / bug of 10.2.0.3/4 at least.
Kind regards
RandolfOracle related blog stuff:
http://Oracle-Randolf.blogspot.com/SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676 /.
http://sourceforge.NET/projects/SQLT-pp/ -
clustered index and non-clustered indexes
Hi ihave read on index qqustion
in SQL Server, table has 1 clustered index and 280 (average) no clustered index.
SqlServer hold a clustered index and the data on the same location. index if cluster command firm data
but sqlserver hold index non-clustered on another file and do not directly order data.
oracle index how does this? for example, I have 3 indexes on the table. how they work? is oracle this clustered index and indexes not clustrered?Oracle has no cluster & nonclustered indexes.
Oracle has Btree, bitmap, text, index basis functionDisappeared through the link
http://www.lorentzcenter.nl/awcourse/Oracle/server.920/a96520/indexes.htm -
Index and MATCH with several conditions
Hi all! I hope I can explain what I'm trying to do here clearly. This is my first shot:
In the table below "Office entry Worksheet - area 1" I am trying to insert a formula in column B which will result in an answer ' true / false ' and be used for conditional highlighting
The first condition that must be met is that the checkbox in the table "Labor and material Checklist" column A or check, if it is not checked, then move to the next line. If the box is checked, then the following condition would need to index and match with column C of table "Office entry Worksheet - area 1" in column B. If there is a match in column C, then move to the next line of column B in the table 'labor and material Checklist '. This continues until there is a 'match', then highlight column B in the table "entry Office sheet - surface 1" in red (or something like "MISSING task")
It is an estimate and the idea is to ensure that the Phases that are checked in the table "Labor and material Checklist" will not miss when you use the table "entry office map - zone 1".
Thank you very much for your help!
Tim
Is it possible that I can download this spreadsheet file?
-
Satellite A660 - 1 H 7 function keys and Logo lights went out
It may seem a little ridiculous to the experience of users of Toshiba laptops, BUT I have my laptop recently and there are a few days, I've lost the lights on my (next to the power switch) function buttons and the 'objective' logo in the lower left corner.
I don't know if I've done something to turn them off?
Unfortunately I don't know how to get the lights back on.Can someone please help and tell me how (step by step if poss) to get back them.
Thank you in advance.
> I don't know if I've done something to turn them off?
> Unfortunately I don't know how to get the lights back on.As far as I know this feature is controlled by Backlight.exe and you can find it in
Program Files\Toshiba\TBS\Backlight.exeIt is usually part of the VAP (value added package) to reinstall this package should help you get it working again.
You can also assign this file exe button again with the Support of TOSHIBA Button tool
Someone wrote in the forum:
+ When I go into "TOSHIBA button Support", I only have empty fields with the choice in the background to set "TOSHIBA Assist" or "Presentation". Empty fields are 'Description', 'Option' and 'path of the target. There is a button 'Browse' to select a program manually, but I have no idea where the exe "backlight on / off" is, when one exists. + -
After you download the security update 2015-008 I lost the function of the function keys and some other functions. Have already played with the keyboard f nothing helps. Are also past system on and outside... need help pls
PS noticed the update downloaded twice
disregard my previous question... I found the answer: F1, F2 has been ticked on.
Maybe you are looking for
-
HP laptop - 15-f162dx: cannot install the latest graphics driver
I just got this new laptop and came to HP update after that utility graphics drivers from Intel driver told to do because of the compatibility. So I put the code on my laptop to HP laptop - 15-f162dx, I'm graphic driver Intel high definition (HD) to
-
I'm fighting a few questions on my tablet pc with help on this site and you can see in my questions - including the 10 page long end topic Nows. But that has been resolved with the great help of 4 of you on my Question 12 END NOWS each logout or rest
-
M277dw: Name of the hotspot wifi M277 dw concerned consumer energy and security
My HP M277dw printer is connected wireless to all my home devices (desktop, laptop). A very strange thing is that the printer itself has a name without password wifi access point. I even tried to connect my mobile phone, although there is no internet
-
Values for RadioInfo.getNetworkCountryCode)
I do not know what values are returned by this routine at the Canada and the United States, and it doesn't seem to be documented anywhere. Anyone know?
-
Art brush strokes in Illustrator CC glitching
I bought a subscription to Illustrator CC a week ago, and it's been non-stop problems.After finally solving some problems with the time of execution and crashing, I am experiencing a little problem with my art brushes now. Whenever I use them, the ra