Why a method to create a constraint would allow the index to be used, but not another.

Hi all

With the help of:

Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production

SQL Developer Version 4.0.2.15

I had to do the following query on a table.

Select distinct chdrnum, tranno

of ractpf_pgr;

I ran the setup of SQL in SQL Developer, who told me that he was doing a full table scan,

(It's what you get using SEPARATE!)

After some research, I discovered that if I put in question on columns not null check constraints

and then recreated the index based on these columns, I'd get a full index scan instead of a table scan.

Good news - off, I went and tried using the following method (I think it's call a constraint of out-of-line)

and created one for each colmn using snytax below.

ALTER table RACTPF_PGR add constraint CS_CHDRNUM_NN check (CHDRNUM is not null) validate;

Ran my SQL Tuning Advisor again - no joy - a full table scan that was happening.

Did some more research and recreated the constraints with the help of an online method

ALTER TABLE RACTPF_PGR CHANGE (CHDRNUM CONSTRAINT CS_CHDRNUM_NN NOT NULL);

My SQL Tuning Advisor is represented - and yes the index was used.


But what I want to know why a method would cause the index to use another does not


Thanks in advance.


The second is a NOT NULL constraint.

The a ('is not null') is technically not a NOT NULL constraint.

Give me a moment to start my database, and I will demonstrate.

Edit: Here's the demo:

SQL> create table x (a number null, b number null);                  

Table created.                                                       

SQL> alter table x add constraint a_nn check(a is not null) validate;

Table altered.                                                       

SQL> alter table x modify (b constraint b_nn not null);              

Table altered.                                                       

SQL> select column_name, nullable
  2  from user_tab_cols
  3  where table_name = 'X';                                         

COLUMN_NAME
----------------------------------------------------------------------

N
-
B
N                                                                    

A
Y                                                                    

The index does not store registrations for the lines where all components of the index are null, then the optimizer needs to see that the columns are not nullable to be able to use an index scan.

Tags: Database

Similar Questions

  • Why disable Flash Player addon allow videos work on one site but not another?

    I am running Firefox 37.02, Windows 7. I also have flash shockwave V17.0.0.134 & V18.0.0.95 addons. The V18 version is beta and downloaded from Adobe to try to resolve this ongoing problem. He has not solved it. By trial and error, I have established that when I disable the addons above mentioned (notice, disabling seems to disable the other) I am able to get videos from Web site to play (for example: video on golfchannel.com) but not another (example: www.nbcphiladelphia.com). Conversely, if the addons are enabled, the videos on the site www.nbcphiladelphia.com work but those of the golfchannel.com are not. By 'not' I mean that commercial video games earlier but the video of the main object that is to run thereafter is not. I get a black screen and the commercial video recycled again and again. I contacted the golfchannel.com support group who said that they were not aware of all the problems. They suggested that I use the Chrome browser, which is what they use without problem.

    It's weird. You can try using the Firefox Add-on FlashBlock to disable flash on some websites but not others: https://addons.mozilla.org/En-us/firefox/addon/flashblock/

  • Why can't I get on facebook? I can't get into all the other websites I use but not facebook? need help!

    When my home page comes up, I can use internet as usual, I check hotmail, youtube and what not, but when I type in facebook, the first site to get indeed on facebook happens but once I like on facebook get on facebook homepage, nothing comes and the window is white. Nothing comes and its been like that for two days. I use facebook as a way to connect with the important people since I use it for networking and its become a problem, these last two days! need help!

    Hello

    1. what browse web is installed on your computer?
    2. don't you make changes to the computer before the show?
    3. what happens when you try to access the facebook?
    4. do you get an error message?

    I suggest you try the steps from the following link:

    Can't access some Web sites in Internet Explorer
    http://support.Microsoft.com/kb/967897

    Note: Reset the Internet Explorer settings can reset security settings or privacy settings that you have added to the list of Trusted Sites. Reset the Internet Explorer settings can also reset parental control settings. We recommend that you note these sites before you use the reset Internet Explorer settings.

    If the problem is with facebook, then I suggest you to post.
    http://www.Facebook.com/help/

  • Copy of complete site. I have a Web site. I would copy the entire site (complete with images) to another directory with a different name. Then, transfer to another hosting server. All ideas

    Copy of complete site. I have a Web site. I would copy the entire site (complete with images) to another directory with a different name. Then, transfer to another hosting server. Any ideas?

    Not sure that you need a different directory.

    If you are working on a local computer, create a new site with all the same settings for local files and change the remote server settings to match the second server.

    This ensures you that there is no difference between the two websites.

  • InDesign - how to re-enable the button "create a new item of the Index.

    When I was creating topics for my index finger, I saved the document after doing a subject - (because I had created topics yesterday and is not saved and lost all of my work) - when I tried to create a new item of the Index, the button wasn't dark - not active, so I was not able to add more topics to my Index. I rebooted my MacBook Pro (Mac OS X Version 10.6.8) and reopened my InDesign (Version 3.0.1) document and the palette Index box still lacks a button "Create a new item of the Index" assets to allow the action. I do not know how to do this - does anyone have any suggestions?

    I worked on the range of the Index of reference - adding items to the Index with a subject that I had already entered and when I went back to fashion topic, I noticed that the 'Create a new item of the Index' button is enabled - so I think everything is good now. Thanks for the forum.

  • I can't understand why the latter splits the live preview... but not in the browser?

    I finally got my site to the top and everything runs great... except that I can't understand why this page behaves as if it was too broad.

    http://www.johnnez.com/mainbooks.html

    He is defeated in the live preview... but not in the browser preview.

    Thanks for the tips...

    Jn

    Well, I was looking at your code for a longer period that is now in good health and the only thing I can think is to ask if you want to have two container div with a class of content?

    I don't know if it's the anser but you can try to delete one of these and then find an of the

    Tags to balance that up.

    Try just to comment on the following:

    Then put in the comment end tag and see if that helps.

    Just a thought

    Martin

  • Why can't I create an email address with the word "mail" in there?

    Why can't I create an e-mail address that contains the word "mail" in there? I want my real name as my user name and my name has the word "mail" in there

    original title: sign up for problems

    Hotmail.  I want her to be an address @hotmail.com

    Hello

    I'm sorry, but we cannot help with hotmail problems in these forums in response to vista

    Please repost your question in hotmail in the hotmail link below forums

    http://windowslivehelp.com/product.aspx?ProductID=1

    Forums
     
     

  • quick method to create a new layer under the current layer?

    would be the best way to quickly create a new layer slot rather than above the active layer to assign a script to a keyboard shortcut - or is it possible to change the default new layer shortcut (command + option + SHIFT + N) to create a new layer above the current layer to create rather a under the active layer?

    Thank you

    Command-click the new layer in the layers Panel button.

  • Cannot create a new user account, the user profile service service does not log and cannot install a program

    I can't create a new user account (Windows 7): the user profile service service has no logon.

    I have an administrative account which is the only account. I have problems with the installation of Autodesk Inventor so I need to create another user to see if I can solve the problem. But when I want to make a new user account and I get the following message: I can't create a new user account (Windows 7): the user profile service service has no logon.

    I haven't added new programs in a long time and I don't know when this question has been raised as I've had my laptop for 3 years and this is the first time I create another account than my original. I don't want to reset my computer manufactured settings.

    I also followed the http://support2.microsoft.com/kb/947215/en-us but I can't find any registry master in the list of profiles. In fact, I am the only user in there...

    It seems that my computer does not have a record in the system registry.

    In fact, the problem started when I tried to fix the "C:\windows\system32\config\systemprofile\desktop refers to a location that is unavailable. It could be on a hard drive on this computer.or on a network. Check to make sure that the disc is inserted correctly, or that you are connected to the Internet or your network, and then try again. If he can't always find the information could have been moved to another location. "I was at least able to connect in the new user but will load a default profile and therefore do not load the profile properly. It seems I've done worse the problem after doing

    gpupdate/force

    at the prompt as an administrator.

    The very initial problem started all this was when I was running from Autodesk Inventor, it gives me the following error: Mismatched Ole32.dll and Comcat.dll. And the support2.microsoft.com/kb/201364/en-us is to say that since I am under Win7, the solution is not applied. So I'm stuck. And the next move was trying to see if a new user profile may solve the problem.

    Any suggestions will be greatly appreciated.

    And if possible, please also suggest a "repair" method so I can get Win7 function correctly without reinstalling the whole machine. "" I use a laptop so I do not have installation media.

    Thank you.

    Hello

    Thank you for your update on the issue.

    I suggest that you try to run the file system (CFS) Checker scan to check all the corruption of .dll files.

    1. Go to Start, click all programs and open the Accessories.
    2. Right-click on command prompt in the list programs, and then select run as administrator. If you are prompted for an administrator password or for confirmation, type your password, or click OK.
    3. In the command prompt, type the following command and press ENTER:
      sfc/scannow

    For more information, see this link:

    http://support.Microsoft.com/kb/929833/en-us

    Please post back your results for assistance.

  • Is there a way to create oral assessments?  Allow the student to present audio answers?

    I am trying to create an asynchronous oral assessment.  I would like the student tell the answer and press on submit and not having to open another application, save an audio file, name it correctly and send or attach.  The public is not tech savvy so that the simplest best.

    This solution does not currently exist in Captivate and would require an application tailor-made to get the results you describe and you would need a budget measured in tens of thousands of dollars, if not hundreds of thousands.

    You don't mention having a budget for this project, so I guess it would be out of the question.

  • How to create a button that allows the user to check their form to find errors?

    Hello

    I use LiveCycle ES3.  I would like to add, at the end of my form (independent, NOT on a web form), a button that allows the user to check their form for errors, and then display a list of errors and highlight areas with errors.  Finally, he must turn off highlight these fields when the errors have been corrected.

    Also, in the form, if the user makes selections, they must include an attachment with their form.  I want to make sure when they make selections that requires an attachment, a field is generated at the end of the form that lists all required attachments.  Is this possible?

    Thank you.

    The button validate calls a Script called "controller" object If you look at the hierarchy of the form Variables example there are two Script objects: controller and validation. Script objects are used to maintain the reusable script functions.

    You have to re-create those for validation to work. If you right click on 'form1' (or whatever your node in the foreground is called in the hierarchy), you can select "insert a Script object. You will need to do it twice.

    In the hierarchy, there is then a node Variables with two Script objects. Name them even as the form of the sample and copy and paste the sample form scripts in them.

  • Why Google voice is no longer working in Firefox after the addition of extra credit, but not in Safari?

    I use Mac OS 10.10 with 30.0.2 FireFox as my browser. I did call OK On Goggle voice through my G-Mail account. When I ran out of credit. I loaded an extra credit and tried to resume the call. However, I kept get get the following error message "Please download the plugin from voice to make a call. After the link provided leads me in a blind ally. Tried to download a voice plugin and reinstall, but no luck. Tried to close Firefox and reopen, but again no luck. There are no problems when you use Safari as my browser. calls are directed very well.

    Can't understand why it has worked very well and thenstopped after laoding additional credit.

    Hello

    Try to clear your cookies and cache and then try to connect again.

    • History (or

      (> History) > clear recent history

    Or:
    "Clear the Cache":

    • Tools (or

      > Options > advanced > network > content caching Web: 'clear now '.

    'Delete Cookies' sites causing problems:

    • Tools (or

      > Options > privacy > "Use the custom settings for history" > Cookies: "show the Cookies".

    Make sure you that you allow the plugin on the site as it is maybe somehow it changed.

    In the world:

    • Tools (or

      ) > Addons > Plugins

    • For Google Talk Plugin (and Video Renderer), make sure it is set to "Always enable" or "ask at.

    By Site and:

    • On the site, click on the padlock or icon globe to the left of the web address in the address bar and click 'more information '.

      • Or go to: Tools > Page Info
    • Click the "Permissions" tab to see if the plugin is activated on the site.
    • Note: You can also go to the Subject: authorizations page and watch your permissions set for each site
  • Create a constraint to invoke the correct e-mail domain

    Hello

    I'm new to SQL, but trying to help a friend build a database for his company, he tries to start (think of a mechanic and the garage of the home).

    I am using Oracle 11 g Express. In the code below, how can I create a check constraint that requires that the value of 'Email' must use the domain of his company? For example - *@billsgarage.com

    Thanks for your help!

    CREATE TABLE EMPLOYEE

    (EmpNo NUMBER (6) PRIMARY KEY,)

    Title VARCHAR2 (30) NOT NULL,

    Fname VARCHAR2 (10) NOT NULL,

    Lname VARCHAR2 (10) NOT NULL,

    Phone VARCHAR2 (12) NOT NULL,

    E-mail VARCHAR2 (40),

    HireDate DATE DEFAULT GETDATE(),.

    Hello

    INSTR, as used above, tells if "@google.com" occurs anywhere in the email.

    If you want to insist that it comes at the end of the string (that is, if you do not allow "[email protected]") then is:

    E-mail VARCHAR2 (30)

    CONSTRAINT email_check

    CHECK (DOWNSTAIRS (e-mail) AS '% [email protected]')

  • Why can't I create a new folder in the documents?

    Never had problem before you create a new folder, but for the last few months have been unable to do.

    I have the same problem and this is the first time it happened, even though I made many attempts to create a new folder in my MY DOCUMENTS folder.  I did what you asked with the race of the order and I got no error message. So, now what?

    You have installed chrome? It is an update of Chrome, (mid), is responsible. Here are two patches.

    How to remove and restore the default context Menu items 'New' in Windows 7 and Windows 8
    http://www.SevenForums.com/tutorials/28677-new-context-menu-remove-restore-default-menu-items.html

    If still no joy, see the 'response' by Linda Yan in this thread.
    http://social.technet.Microsoft.com/forums/en-us/w7itprogeneral/thread/97de8a2a-12f2-4381-A409-a78f4ae551cf/#99395761-56de-4a76-8C2A-eab498ad735a

    Tip: When you save the text in Notepad, the default file format is .txt. Replace all files.

  • Why the e-mail application strips the CSS background-size property but not when it is used in shorthand?

    I came across the following in the Windows 8 messaging application today, behaviors regarding CSS3 support.

    -http://blog.jmwhite.co.uk/2014/10/03/windows-8-mail-app-background-size-css-property

    -https://litmus.com/community/discussions/550-windows-8-mail-app-and-background-size

    Essentially during the development of a email campaign which make use of the background-size property, the mail in Windows 8/8.1 and same Windows 10 Technical preview application will remove altogether, when it is expressed as follows:

    background-size: 200px 200px;

    If you use the background with a shortcut property it still works OK:

    Background: URL(image-2x.jpg) 0 0 / 200px 200px no-repeat;

    Can someone explain why this behavior is present in the mail application? Is this a bug?

    Hello James,.

    Thanks for posting your query in Microsoft Community Forum.

    I suggest that you re - ask your question in the MSDN forum rather than on this forum to check the settings. MSDN is examined by developers and other it professionals who would more than likely be able to help.
    http://social.msdn.Microsoft.com/forums/en-us/windowsgeneraldevelopmentissues

    Hope this information is useful.

Maybe you are looking for

  • Why are applications open on their own?

    I'm under 10.11.6. I checked the system for any strange process, I ran malwarebytes and avira. Application "Mail" and "iMessage" open themselves. Usually to connect to wifi. Any ideas? Thanks in advance.

  • HP 1315v printer connected to D-Link router

    I would like to know if I can connect my printer (HP 1315v) directly to my D-Link router with a wire and then use the printer as a network printer. The printer has a firewire connection I think.  Is it possible to put some type of adapter on it so th

  • After compaction folder, emails disappear

    I recently posted to 'after compacting folders Inbox is completely empty' on one similar problem with another folder that I use for email archiving. After reaching "Compact" in the right-click on this file, all the emails just disappeared. Pouf! Fort

  • Pavilion dv7: password of BIOS Pavilion dv7

    My brother-in-law died the year without writing a number of passwords, including for its Pavilion dv7 BIOS password. I try to recover the system for his son, but cannot fand of suggestions for the 70116276 hash code that appears with the system off m

  • Cannot connect Windows 7 to iHome iBT70

    I'm unable to connect my IHomeiBT70 to my computer. The wireless speaker is to connect to my laptop, but not with the computer. I can see devices in the bluetooth devices list, but when I click it, it gives me an error saying view bluetooth service I