NLSSORT function not used with CHAR and VARCHAR2 column index

Hello!

Create a test bench:
CREATE TABLE scott.nls_demo
      (
      col_varchar            varchar2(4),
      col_char               char(4),
      col_varchar_NLS_GERMAN varchar2(4),
      col_char_NLS_GERMAN    char(4)
      );
 
INSERT INTO scott.nls_demo (
      col_varchar,
      col_char,
      col_varchar_NLS_GERMAN,
      col_char_NLS_GERMAN  )
  SELECT 
         substr(object_name,1,4),
         substr(object_name,1,4),
         substr(object_name,1,4),
         substr(object_name,1,4)
  FROM all_objects where rownum<5000;

COMMIT; 

create index scott.i_varchar on scott.nls_demo (col_varchar);  
create index scott.i_char    on scott.nls_demo (col_char);

create index scott.i_varchar_NLS_GERMAN on scott.nls_demo ( NLSSORT(col_varchar_NLS_GERMAN,'nls_sort=''GERMAN_CI'''));  
create index scott.i_char_NLS_GERMAN    on scott.nls_demo ( NLSSORT(col_char_NLS_GERMAN,   'nls_sort=''GERMAN_CI'''));
 
Now "explain plan" these 8 select statements in SQL * more:
variable c char(4);
variable v varchar2(4);

exec :c:= 'abc';
exec :v:= 'abc';

explain plan for SELECT /* 1*/ * FROM scott.nls_demo where col_varchar=:v;
SELECT * FROM TABLE(dbms_xplan.display);

explain plan for SELECT /* 2*/ * FROM scott.nls_demo where col_char=:c;
SELECT * FROM TABLE(dbms_xplan.display);

explain plan for SELECT /* 3*/ * FROM scott.nls_demo where col_varchar_NLS_GERMAN=:v;
SELECT * FROM TABLE(dbms_xplan.display);

explain plan for SELECT /* 4*/ * FROM scott.nls_demo where col_char_NLS_GERMAN=:c;
SELECT * FROM TABLE(dbms_xplan.display);

ALTER SESSION SET NLS_COMP = linguistic;
ALTER SESSION SET NLS_SORT = german_ci;

explain plan for SELECT /* 5*/ * FROM scott.nls_demo where col_varchar=:v;
SELECT * FROM TABLE(dbms_xplan.display);

explain plan for SELECT /* 6*/ * FROM scott.nls_demo where col_char=:c;
SELECT * FROM TABLE(dbms_xplan.display);

explain plan for SELECT /* 7*/ * FROM scott.nls_demo where col_varchar_NLS_GERMAN=:v;
SELECT * FROM TABLE(dbms_xplan.display);

explain plan for SELECT /* 8*/ * FROM scott.nls_demo where col_char_NLS_GERMAN=:c;
SELECT * FROM TABLE(dbms_xplan.display);
 
What I see on 11.2.0.2 is:

1.) statement 1 would use the I_VARCHAR index, that is what I expected.
2.) statement 2 would use the I_CHAR index, that is what I expected.
3.) no clue used, because none are available right here for you. Understood.
4.) no clue used, because none are available right here for you. Understood.

And when define us NLS_SORT = german_ci:

5.) no clue used, because none are available right here for you. Understood.
6.) no clue used, because none are available right here for you. Understood.
7.) I_VARCHAR_NLS_GERMAN we used. Large.
8.) no index used, although I think that "i_char_NLS_GERMAN" would do the job...

Why the index 'i_char_NLS_GERMAN' is not used with the 8 statement? Jonathan? Someone else?

Thanks for your help!
Marcus

Not really a reason to not use TANK - although there are many of them.

More than one reason to not always rely to "explain the plan for?

All the variables passed in EXPLAINING the PLAN for are treated as VARCHAR2.
In addition, there is no point setting the values of the variable because they will not cast a look either with MAP to EXPLAIN.

SQL> CREATE TABLE nls_demo
  2        (
  3        col_varchar            varchar2(4),
  4        col_char               char(4),
  5        col_varchar_NLS_GERMAN varchar2(4),
  6        col_char_NLS_GERMAN    char(4)
  7        );

Table created.

SQL>
SQL> INSERT INTO nls_demo (
  2        col_varchar,
  3        col_char,
  4        col_varchar_NLS_GERMAN,
  5        col_char_NLS_GERMAN  )
  6    SELECT
  7           substr(object_name,1,4),
  8           substr(object_name,1,4),
  9           substr(object_name,1,4),
 10           substr(object_name,1,4)
 11    FROM all_objects where rownum<5000;

4999 rows created.

SQL>
SQL> commit; 

Commit complete.

SQL>
SQL> create index i_varchar on nls_demo (col_varchar);  

Index created.

SQL> create index i_char    on nls_demo (col_char);

Index created.

SQL>
SQL> create index i_varchar_NLS_GERMAN on nls_demo ( NLSSORT(col_varchar_NLS_GERMAN,'nls_sort=''GERM
AN_CI'''));  

Index created.

SQL> create index i_char_NLS_GERMAN    on nls_demo ( NLSSORT(col_char_NLS_GERMAN,   'nls_sort=''GERM
AN_CI'''));

Index created.

SQL>
SQL> variable c char(4);
SQL> variable v varchar2(4);
SQL>
SQL> exec :c:= 'abc';

PL/SQL procedure successfully completed.

SQL> exec :v:= 'abc';

PL/SQL procedure successfully completed.

SQL>
SQL> ALTER SESSION SET NLS_COMP = linguistic;

Session altered.

SQL> ALTER SESSION SET NLS_SORT = german_ci;

Session altered.

SQL>
SQL> SELECT /* 8*/ * FROM nls_demo where col_char_NLS_GERMAN=:c;

no rows selected

SQL> SELECT * FROM TABLE(dbms_xplan.display_cursor);

PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
SQL_ID  9su0j5vzuwzyj, child number 0
-------------------------------------
SELECT /* 8*/ * FROM nls_demo where col_char_NLS_GERMAN=:c

Plan hash value: 2830339923

-------------------------------------------------------------------------------------------------
| Id  | Operation                   | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |                   |       |       |     3 (100)|          |
|   1 |  TABLE ACCESS BY INDEX ROWID| NLS_DEMO          |    50 |  2150 |     3   (0)| 00:00:01 |
|*  2 |   INDEX RANGE SCAN          | I_CHAR_NLS_GERMAN |    20 |       |     1   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("NLS_DEMO"."SYS_NC00006$"=NLSSORT(:C,'nls_sort=''GERMAN_CI'''))

Note
-----
   - dynamic sampling used for this statement (level=2)

23 rows selected.

SQL> 

Published by: Dom Brooks on February 21, 2011 15:39

Tags: Database

Similar Questions

  • Hi, can someone give me some ideas on what type/brand of usb cameras are not suitable for labview? I need to use with labview and IMAQ Cheers acquisition image vision module

    Hi, can someone give me some ideas on what type/brand of usb cameras are not suitable for labview? I need to use with labview and image acquisition IMAQCheers vision module

    Hi, I use a 1.4MP USB camera with LabView. The brand is ID - a German company.

  • Lightroom 6.4 not work with nikon and nikon d610 d810 in 10.10 mac, anyone else have this problem?

    Lightroom 6.4 not work with nikon and nikon d610 d810 in mac10.10, anyone else have this problem?

    When you say won't work, what are the exact symptoms that you see on the screen? Error messages? Codes?

    How do get you pictures from the camera to the computer? If you use the Nilkon software, try using a card reader instead.

  • (1) char and varchar2 (1)

    Can someone tell me the difference between (1) char and VARCHAR2 (1), I need to use the flag of 1 byte column.

    What is the best to use

    Read this link
    [http://asktom.oracle.com/pls/apex/f?p=100:11:0:P11_QUESTION_ID:123212348063]

  • I do not use outlook express and still get msg, oe can compact the message. How to stop

    I do not use outlook express and still get msg, oe can compact the message.  How do I prevent this every time that I turn on computer to come.

    You must tell Windows Search to stop indexing OE.

    In the control panel. Indexing Options. Change. Clear the check box for Outlook Express.

    If you see the prompt again, let the compact once to reset the counter and it should be.

  • Why pes 2012 does not work with me and my video card is 1699 MB Intel HD Graphics(core i3)?

    Why pes 2012 does not work with me and my video card is 1699 MB Intel HD Graphics(core i3)?

    Hello

    You receive an error message?

    Method 1:

    You can update the drivers of graphics cards and check.
    Updated a hardware driver that is not working properly
    http://Windows.Microsoft.com/en-us/Windows7/update-a-driver-for-hardware-that-isn ' t-work correctly


    Method 2:

    You can also perform a clean boot and check if it works:
    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
    http://support.Microsoft.com/kb/929135
    Note: after a repair, be sure to set the computer to start as usual as mentioned in step 7 in the Knowledge Base article

    You can also check out the link:
    The problems of the game performance
    http://Windows.Microsoft.com/en-us/Windows7/fixing-game-performance-problems
    Diagnose problems running DirectX
    http://Windows.Microsoft.com/en-us/Windows7/diagnosing-basic-problems-with-DirectX

  • Lightroom does not use my gpu and it says it is compatible, and the driver is updated, what do I do now?

    Lightroom does not use my gpu and it says it is compatible, and the driver is updated, what do I do now?

    As far as I could see, your card supports OpenGL 3.2 only that OpenGL 3.3 is necessary.

  • Why some functions of "click on" does not work with Firefox and Ebay and my mailbox?

    When you go to my mail (especially Yahoo mail) I can't click on the boxes that allow me to delete or anything else. In addition, I can't hardly use Firefox at all with Ebay and other sites because of a similar problem. For example, the cursor will not change even a 'hand' on 'Sign In' on Ebay, or it will allow me to change the page number, if I have multiple items to sell or buy. I had to change all my Bill pay sites for IE for this same reason. You have any ideas? I am currently using Firefox 17.0.1.

    Start Firefox in Safe Mode to check if one of the extensions (Firefox/tools > Modules > Extensions) or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox/tools > Modules > appearance).

    • Do not click on the reset button on the start safe mode window or make changes.
  • Remote index not used with INSERT in the local table on dblink

    Hi all

    I don't know if anyone has come across this problem before, but for some reason any the remote index remains unused ONLY* in the insertion on the local database operation. Let me explain this pseudo-device code

    insert into LOCAL_TABLE
    Select / * + index_combine (alias_remote_tab IDX_LOG_DATE) * /.
    trunc (log_datetime),
    Count (*)
    of REMOTE_TABLE@DBLINK alias_remote_tab
    When trunc (log_datetime) = trunc(sysdate-1)
    Trunc Group (log_datetime);

    where:
    REMOTE_TABLE is a table partitioned on log_datetime (monthly)
    IDX_LOG_DATE is an index of bitmap of based on a valid function on log_datetime created in the trunc (log_datetime)
    local database: 10 gr 2
    remote database: 11 GR 1 material
    OS: windows (both)

    More funny thing is when I just run the select query independently on the only both local and remote, the index is used. I checked by printing the command explain for the select query plan. But when I prefix the query with the insert lose all hell breaks and local database plays the ignorance about the index. The command for the insert query explain plan has no mention of the index even when I explicitly place the index indicator in the select part of the query.

    If this should not be simple enough for ORACLE? Am I missing something here?

    Jonathan describes the details and the reasons for the behavior you see in following blog post http://jonathanlewis.wordpress.com/2008/12/05/distributed-dml/
    Your SELECTION is performed remotely (filtering and grouping) and sends only the (relatively) small results via dblink local database while the in an INSERTION, filtering only occurs at the remote and data site (relatively) important are sent via dblink to the local database, the consolidation takes place.
    You can give a try to the approach proposed by michaels2. If the approach from the view result grouping and filtering which will take place in the remote database, you will see improved performance.

    PS BTW, if the sql code that I suggested to check the plane, in my previous post using an index, then the cause of your performance issue is certainly not due to the index not used and is due to the amount of data transferred to dblink.

  • Why goolgeearth does not work with Chrome and Safari but not Firefox

    When in firefox using Google maps and click on "EARTH", I get a window indicating that, to use the 3D, I have to install 21.0 Google Earth plugin with option click on 'Download '. Note: Firefox 21.0 and MAC OS 10.7.5 have all current software updates installed. Safari and Chrome are asking not for any plug-ins and 3D Earth option works very well. ANY HELP?

    PS my MAC has an Intel HD Graphics 3000 installed, but my MAC, Safari, and Chrome work fine.

    Google Earth requires a graphic that comes pre-installed with Chrome and Safari plug-in. If Google Earth works on other browsers, install the Firefox plug-in is the solution. To install this on Firefox, download it from the prompt window, or go to https://www.google.com/earth/explore/products/plugin.html.

  • New window Bookmark not filled with location and the name of Web site

    I just set up a new computer with firefox and import my favorites. I noticed that when I go to make a new bookmark, the fields are not filled for the fields name and location they are on my other filrefox facilities. I wondered why, and what can I do about it?

    Have you tried disabling hardware acceleration?

    • Tools > Options > advanced > General > Browsing: "use hardware acceleration when available.
  • Zbook 15u: AMD GPU on Zbook 15u not used with Windows 10.

    I have recently upgraded to Windows 10, downloaded and updated all readers.  No matter what I do, I can't do GPU AMD do any work. its always at 0% in any program, I use Adobe Premiere or DXO Optics.

    It worked fine on windows 7.

    I am not getting any errors and I have reset the Catalyst dashboard and set all applications we high power mode.

    But nothing seems to trigger the gpu

    Help, please!

    Nevermind the fact that I paid all the money for a powerful system only when I booted up first AMD to determine when I can or cannot use the gpu. I was under the impression that I could pass betweedn both as my old system for Viao. But Nevermind that, I just need the GPU to run on windows 10...

    Thank you

    PER DAY

    It turns out that it was system AMD monitor who was at fault.

    It doesn't detect my gpu with the latest drivers. Other monitors GPU confirmed that everything works as on windows 10 must then I'm happy on this subject!

  • New footprint software does not work with IE8 and FF3

    I downloaded the latest version, but still, it does not solve problems with IE8 and FF3...

    Please, please...

    The main problem of the software cannot save the login information of website with Internet Explorer 8 + and Firefox 3 +.

    Thank you
    Stewart Grainger

    First of all, you know that's not Toshiba software but application of AuthenTec and I m sure that the manufacturer of this software knows this problem.
    Then if you want to always use applications more recent you know that these problems of compatibility can always happen.
    I think that it of not really difficult to understand this

  • Thumbnail images do not match with images and file names

    I got a surprise this morning! Thumbnails of my photos do not match with the real images and file names. File names correctly matching the real images. Pls help how to fix. Could it be caused by a virus?

    I got a surprise this morning! Thumbnails of my photos do not match with the real images and file names. File names correctly matching the real images. Pls help how to fix. Could it be caused by a virus?

    ==========================================
    What version of the program / are you use ot see the pictures?

  • Why can I not use Clipboard, copy and paste? instead of a picture, I get javascript

    I try to use the clip and paste on a document. I select an image and click on copy. It's not going in the clipart.all I get is the word javascript on the document.

    Are copy you the image you are viewing using a right click > copy the Image?

    You copy a Web site to another program (such as Word or paint), or in another page in Firefox? There may be special numbers, stick it in an online editor.

    Web sites can use scripts to change what happens when you right-click. Sometimes it is used for good, as custom menus, but it can also complicate copies images... If you want to try to disable (all) sites to do this, you can make some changes in the subject: configuration preferences editor. I'll look at the details if you are interested.

Maybe you are looking for

  • What is an IDN-based email?

    On the last update, one of the features was that you could now send emails to addresses based on IDN. What the heck is an IDN email address?

  • iTunes Sign-in check failed

    Hello I get an error of check by connecting to iTunes for Windows 10, but the connection works fine on iPhone and iPad. I am also able to manage my Apple ID. It's only when connecting to iTunes (12.3.3) on my Windows 10 I get this error. "The check h

  • DIAdem 2010 Runtime error R6030

    Since noon yesterday, DIAdem will not start. The error message is not helpful for me: DIAdem version: 11.2.0f4178Operating system: Windows XP SP3 (en) Can anyone give some advice how to locate and fix this bug? I already tried this: Restart the syste

  • How to rename the disc

    Changing the name of ORIGINALT TITLE: partition? Errored score named E: can you change it in C:

  • Laptop HP 250 3 g (J0Y21EA): problem of unknown devices

    I installed Windows 8.1, but my Device Manager shows 5 mistakes of devices in the section "other devices." They are as follows: Unknown device (location: on system compatible ACPI Microsoft) ACPI\VEN_HPQ & DEV_6001ACPI\HPQ6001* HPQ6001 Unknown device