How to write 'AND' and 'OR' query

Oracle: 11 GR 2

OS: Linux

Friends, I am rewriting the simple select query that really takes time.

Some experts can let me know how else I can rewrite below for better performance?

SELECT username

To apu app_users

WHERE)

(user_access_pkg.functionRights (apu.username, 'FINANCE') = 'Z'

AND user_access_pkg.functionRights (apu.username, 'NON_FINANCE') = 'Z '.

)

OR user_access_pkg.functionRights (apu.username, 'MAJOR') = 'Z '.

);

Table has 1.5 mil rows with indexes.

I checked explain plan and does Oracle INDEX_FULL_SCAN

Table / index stats are uptodate.

Thanks, Mike

Friends, I am rewriting the simple select query that really takes time.

Sorry - I don't know what "very long" is supposed to mean.

Some experts can let me know how else I can rewrite below for better performance?

SELECT username

To apu app_users

WHERE)

(user_access_pkg.functionRights (apu.username, 'FINANCE') = 'Z'

AND user_access_pkg.functionRights (apu.username, 'NON_FINANCE') = 'Z '.

)

OR user_access_pkg.functionRights (apu.username, 'MAJOR') = 'Z '.

);

Why do you use a function instead of SQL tables?

That each of these predicates mean?

You call the same function THREE times and Oracle has no way of knowing what will be the real function cardinality unless you manually create the appropriate statistics.

The most likely cause of any performance issue is the function and had to call three times.

View code for the function, so we can see what he does.

If you use such a function, you have to set the predicate checks in the function itself, so they can be applied in the execution of the function.

Tags: Database

Similar Questions

  • How to write a simple select query to get the data of the table as an XML.

    How to write a simple select query to get the data of the table as an XML. In the query, I'm just adding items below which i need be there in the XML document
    select '<test_tag>'||EMP_NAME||'</test_tag>','<date>'||sysdate||'</date>' 
    from temp_table where id_num BETWEEN 1 AND 10;
    I have need to add the root tag as well in the beginning and the end of < root > < / root > this xml file. Please advice if this is possible with the select query
    without using XMLGEN, XMLQUERY or any other packages built and function?

    I need to URL escapes with the UTF-8 code points that we have already achieved using the utl_http package. Please help how to do that without using the utl_http package.

    What is wrong with him?

    At present, the only way I can think of to avoid a call to UTL_HTTP. SET_BODY_CHARSET is to write your own little wrapper.
    In this way, you can specify the Boolean parameter or omit it if you choose to use named parameters:

    SQL> create or replace function my_url_escape (url in varchar2)
      2  return varchar2
      3  deterministic
      4  is
      5  begin
      6   return utl_url.escape(url, false, 'AL32UTF8');
      7  end;
      8  /
    
    Function created
    
    SQL> select my_url_escape('http://some.uri.com/param?lang=fr&text=contrôle') from dual;
    
    MY_URL_ESCAPE('HTTP://SOME.URI
    --------------------------------------------------------------------------------
    http://some.uri.com/param?lang=fr&text=contr%C3%B4le
     
    
  • How to write and format for excel

    I am currently using labview 2010 and I try to write my timestamp data to Excel.  I have my time stamp formatted as a string and my data is in a table or a type of dynamic data. Writing custom vi does not work with my data for some reason any and I was not able to understand this possibility, but any suggestions on how to do, but also to format the column headers would be very appreciated.

    Thank you

    In the format string.  It has the format codes that will allow you to convert a timestamp into a string in any format you want.

  • How to write and read from the cache in Labview?


    Hello

    I would use "the spreadsheet file reading" to read serial numbers stored on your hard drive. If your file has each serial number on each line of reading spreadsheet file will return an array of 2D with the first column containing numbers. Then use 'Index Array' to get a 1 d of your serial numbers table. In your loop, you will then use VI 'Picture 1 d of research' to check if the SN is in the table. It returns-1 if its not found. If to use build table to add the serial number. Then use 'Write the spreadsheet file' to save the new list of serial number in line.

    Hope this helps

  • How to write the following UPDATE query

    I have a table with data as below:

    Subscriber IMSI imsi_rank
    1123211
    123123412
    13324423
    13424
    15
    2232131
    2123212
    2123123
    24
    25

    Now, the data is dense and continuous for a SUBSRCIBER. Between there is no value for a SUBSCRIBER's IMSI null. However, where one or more IMSI is null, I need to update the table to move the IMSI values to the top of the IMSI_RANK.

    Say for example for Subscriber 1, IMSI value 2312341 and 332442 is set to NULL value. So I need to write an application Update or PLSQL that will update the data as below.

    Subscriber IMSI imsi_rank
    1123211
    13422
    13
    14
    15
    2232131
    2123212
    2123123
    24
    25

    I use 11g.

    You cannot perform SQL on any PL/SQL collection type. You need to loop through them and make the change.

  • How trigger if and object of the database will be created?

    Hi, how to write and trigger if any database object will be created? Concerning

    You can create a DDL trigger

    CREATE OR REPLACE TRIGGER trigger_name
      AFTER CREATE ON SCHEMA
    BEGIN
      <>
    END;
    

    Justin

  • How to write a program that allows an HTTPs connection to the APACHE TOMCAT server in blackberry JDE

    Hello.. I am very new to the blackberry JDE environment. But then, I have a project in which I should write a program that will make an HTTPs connection to the apache tomcat server using blackberry JDE. The simulator which I use is 8330-JDE.

    Here is my code...

    import java.io.IOException;

    Import java.io.InputStream;

    Import javax.microedition.io.Connector;

    Import javax.microedition.io.HttpsConnection;

    Import net.rim.device.api.ui.UiApplication;

    Import net.rim.device.api.ui.container.MainScreen;

    public class Httproto extends UiApplication

    {

    public public static void main (String [] args)

    {

    Httproto instance = new Httproto();

    instance.enterEventDispatcher ();

    }

    public Httproto()

    {

    pushScreen (new HttpsConnectionScreen());

    }

    }

    final class HttpsConnectionScreen extends screen

    {

    public HttpsConnectionScreen()

    {

    HttpsConnection c = null;

    InputStream is = null;

    int rc;

    try {String url =

    "https://192.168.2.3: 8443/cit/j_acegi_security_check? j_username = sanogo & j_password = redhat;

    c = (HttpsConnection) Connector.open (url);

    c.setRequestMethod (HttpsConnection.POST);

    System.out.println ("connection is open with the server");

    Get the response code is open the connection,

    Send the request and read HTTP response headers.

    The headers are stored until asked.

    RC = c.getResponseCode ();

    System.out.println ("response from the server" + rc);

    if (rc! = HttpsConnection.HTTP_OK) {

    throw new IOException ("HTTP response code:" + rc);

    }

    is = c.openInputStream ();

    Get the ContentType

    The string of type = c.getType ();

    The length and process data

    int len = (int) c.getLength ();

    if (len > 0) {

    int actual = 0;

    int BytesRead = 0;

    byte data = new byte[len]; while ((bytesread! = len) & (real! = - 1)) {

    real = is.read (data, bytesread, len - bytesread);

    bytesRead += real;

    }

    } else {}

    int ch;

    while ((ch = is.read (())! = - 1). {

    }

    }

    } catch (ClassCastException e) { throw new IllegalArgumentException ("not a HTTP URL");}

    }

    catch (IOException ioe) {}

    finally {

    Try

    {

    if (is! = null)

    is. Close();

    if (c! = null)

    c.Close ();

    }

    catch (IOException ioe) {}

    }

    }

    }

    When I run this program in the Simulator, I can do nothing. Please correct me if I'm wrong in coding.

    As I am new to this blackberry JDE environment, ideas and suggestions on how to write and run the sample applications in the blackberry are more welcomed.

    Concerning

    Hinduja

    Make sure that your MDS starts when the Simulator starts.  In the JDE will in Edition > Preferences > Simulator > General and click the checkbox "launch Mobile Data System connection with Simulator Service.

  • How to write a query to return rows with the varchar column that contains even a single occurrence of the characters, such as Ÿ and

    How to write a query to return rows with the varchar column that contains even a single occurrence of the characters, such as Ÿ and

    I have a table whose columns with values such as

    MINNEAŸPOLIS and ¿VV ¿A

    Only the characters that are allowed in this column are alphabets, numbers, spaces, points and supports.

    Please help to write a SQL SELECT with Regexp_like query or any other option.

    Thanks to you all! Under query worked for me. Thank you Frank to explain the concept of hooks inside regexp_like.

    SELECT * FROM testspecial, WHERE REGEXP_LIKE (sampletext, "[^] ^ A - Z ^ a - z ^ 0-9 ^ [^.]") ^ {^} ^]') ;

  • How to write a procedure to call and run the custom package backend

    Hi all

    Oracle 10g
    Oracle Apps R12

    I work with here oracle order management, we have a package called (Pick Release) to customize. Due to a problem, we have this concurrent program execution manually giving Route_id as parameter. The route_id comes from the road to the Table. By using this query

    Select distinct route@DB_LINK_APPS_TO_ROADSHOW route_id
    When trunc (route_date) = trunc (sysdate + 2).

    on a daily basis, we have almost 42 routes and we run this simultaneous program manually close times.

    so now how to write a procedure for this

    Step 1 make the route to the routing table. (By cursor we can get the route_id accordingly)

    Step 2 How to trigger custom backend package and run accordingly to this output of the cursor (route_id)

    If 40 routes of cursor get is - that the simultaneous program runs 40 times according to this route_id.


    can some could provide the steps to do this


    Thanks and greetings

    Srikkanth.M

    To submit a competing request from the back - end:

    FND_REQUEST. SUBMIT_REQUEST (Client or server)

    Summary

    function FND_REQUEST. SUBMIT_REQUEST

    (application IN varchar2 default NULL,

    program IN varchar2 NULL by default,

    Description IN varchar2 default NULL,

    start_time IN varchar2 default NULL,

    sub_request IN default boolean FALSE

    Argument1,

    argument2,..., argument99.

    Return to argument100 number);

    Description

    Submits a competing treatment by a simultaneous Manager. If the query is successful, this function returns the ID of the concurrent request; Otherwise, it returns 0.

    ATTENTION: FND_REQUEST needs to know information about the user and accountability whose application is submitted. Therefore, this feature works of concurrent programs or forms within the Oracle Applications.

    The FND_REQUEST. SUBMIT_REQUEST function returns the ID of the concurrent application after successfully. It is up to the caller to issue a commit to complete the application.

    Your code should retrieve and handle the error message generated if there is a problem of presentation (the ID of the concurrent request returned is 0). Use FND_MESSAGE. RETRIEVE and FND_MESSAGE. ERROR to retrieve and display the error (if the application is made on the client side).

    Related essays: overview of the Message dictionary (see page)

    You must call FND_REQUEST. SET_MODE before calling FND_REQUEST. SUBMIT_REQUEST of a database trigger.

    If FND_REQUEST. SUBMIT_REQUEST fails to go anywhere but a database trigger, database changes are cancelled until the time of the function call.

    After a call to the FND_REQUEST. SUBMIT_REQUEST function, installation of all parameters are reset to their default values.

    Arguments (input)

    short name of the application associated with the concurrent request for enforcement.
    short simultaneous program (not the executable) name of the program for which the application must be made.
    Description Description of the application that appears in the form of concurrent requests (optional).
    start_time time during which demand is expected to start running in the (optional) HH24 or HH24:MI:SS format.
    sub_request set to TRUE if the request is made by another application and should be treated as a subquery.
    From version 11, this parameter can be used if you submit requests for in a concurrent program of PL/SQL stored procedure.
    argument1... 100 arguments for the concurrent request; up to 100 arguments are allowed. If the Oracle Forms submitted, you must specify all arguments of 100.

  • How to write a letter and print it using Windows XP

    How to activate the programs that will allow me to write and print letters

    Windows comes with several.

    How to use wordpad: http://www.ehow.com/how_5726466_use-xp-basic-word-processing.html (after's done it, make sure that a printer is connected to your PC, then open the document and press Ctrl + P on your keyboard and click OK to print the file)

    Office Online (free, online version of MS Office): http://office.microsoft.com/en-us/web-apps

  • What is microsoft xps document writer and xps Viewer and how to use it?

    What is microsoft xps document writer and xps Viewer and how to use it?

    Original title: xps document writer and Viewer

    Hi arunin,.

    An XPS document is a file that is saved in the XML Paper Specification, or .xps, file format. You can create documents XPS (.xps files) by using any program that you can print from Windows; However, you can only view XPS documents by using an XPS Viewer, such as the one included in this version of Windows.

    See: http://windows.microsoft.com/en-in/windows/what-is-xps-viewer#what-is-xps-viewer=windows-7

    http://Windows.Microsoft.com/en-in/Windows-Vista/print-to-the-Microsoft-XPS-document-writer

  • How to write in Hebrew, from right to left, and not in the mirror?

    I have the master collection CS6 installed on windows 8

    all is well just that Hebrew writing is mirrored. How to write from right to left?

    Hi yonir,

    Please see the type Arabic and Hebrew in Photoshop

    Let us know if that helps.

    Kind regards

    Assani

  • I am a newbie to this and I was wondering how to write CSS Code for text, text color, size text and text effects...

    Please keep in mind that I am a newbie. For the moment, I don't know how to write code, so I use Muse to try to build a Web site that is not super fancy writing know, then improve or build or create a new site later. I called Adobe and they said someone in the forums may know how to write code and that he could help me. That said, if someone could answer my questions and help me somehow, I'd be really grateful.

    1. How can I write code, what code should I write to

    Text?

    Color of the text?

    Text size?

    Text/Font Style

    Text effects (such as fly in or fly out, bounce in and out bounce, spin in and spin out, fade in and fade out, etc)?

    Direction of text effect?

    Time that the effect occurs, if it is applied, initiated, comes in? example fly in or fade?

    Time than the last.

    After the effect stops, turns off? example: fly away or fade out?

    2. how to enter the code Muse?

    3. should I have a program to write the code?

    4. is there a function I could use on my computer, such as Notepad, to write the code, copy and paste it into Muse?

    5. What is the best book or books to learn how to write css, code and everything I need to do to be able to do the above and more?

    6. is there anything else I need to know or do to be able to do these things with the text?

    You can find more information on the style of your text (paragraphs, titles, etc. in some of the tutorials here: TUTORIALS |) Adobe Muse CC

    You can also check out tutorials on this page for scrolling effects that can do some of the other effects you need. Without exactly knowing your use case it's hard to give specific advice.

    Basically if it is not covered undressed under the text, scrolling Effects tutorials or in a third party widget already made, then you will need to create it yourself using CSS. You will need to use some sort of browser Firebug like developer tools in Firefox to find the ID of the element you want to add the CSS to write the CSS code and insert it into the head section of the page properties.

  • I'm new in indesign scripting, please tell me how to write a script to get the contents of an XML element and then sort all the content

    I'm new in indesign scripting, please tell me how to write a script to get the contents of an XML element and then sort all the content

    Hello

    Can the code below is useful for you, but I do not know how to sort.

    Change the tag based on your employment application.

  • How to write insert and update blocks about with an if

    Hai All

    How to write an insert and update block education about with in an if

    I had a condition Ie

    If the time is between 0630 and 1030


    then

    Insert into Daily_attend
    ----


    Update Daily_attend set

    -----

    Concerning

    Srikkanth.M

    There is nothing preventing you to do this:

    BEGIN
      INSERT INTO x (mycolumn) VALUES ('A');
    
      UPDATE x
      SET mycolumn = 'B'
      WHERE mycolumn = 'A';
    
      COMMIT;
    END;
    /
    

    other than the fact that he seems a bit inefficient. Yet once you try to do, and why, is not clear.

    Can you put an IF statement in there to choose one way or the other under certain conditions? Yes. But I wonder if what you
    are actually trying to do is to reinvent the MERGE statement.
    http://www.morganslibrary.org/reference/merge.html

Maybe you are looking for

  • Reset password BIOS of Pavillion G6

    Turn off the system code forgotten BIOS password on a laptop in Pavilion g6 series: 59178959 Any help would be really appreciated, I don't want to dismantle this baby!

  • Image acquisition turns off in Windows Server 2012

    I am running Windows Server 2012.  Kind of a necessity, that I also hosts the website of our company.  All updates are installed, and desktop experience is enabled.  Image acquisition Windows is listed in Services, but was originally set to manual by

  • Faster analysis

    Hello world I'm relatively new to LabVIEW and here's my work: I need to import a very large data (16 MB) of a long string of 16-bit binary numbers.  I will analyze these data in 4 columns of 16-bit numbers, until the end of the file. development: If

  • Limit hard drive under XP?

    I have a number of programs that are not supported under Win7. My solution was to install a third hard drive in my PC and when I need sometimes to run XP, I just start to HD using the selection of BIOS which HD to boot from. My Configuration: 500 GB

  • Belongs to IE8 SP3?

    I desperately want to get rid of IE8 and restore IE7. The program is NOT in my Add/Remove Programs, but when I run the Solution Explorer, he is still there? Thank you.