Avoiding the use/cost of Select Distinct ?

I have inherited some PLSQL code that does a Select Distinct. Does anyone have any ideas as to how to best go about tuning a SqlPlus Statement that has a Select Distinct ?
Thanks :-)

It really, really depends on the specifics of the statement. There aren't going to be any general rules that we could give you.
Of course, having said that, my eyes tend to perk up when I see a SELECT DISTINCT because it is commonly misused in situations where the query developer is covering up a missing join condition or some other condition in the WHERE clause. The DISTINCT clause can "fix" lots of these problems by eliminating the duplicate rows, but it's almost always more efficient to prevent the duplicate rows from being returned in the first place.
Justin

Similar Messages

  • Use of substr function will avoid the use of indexes in a table

    i have one table which will contain some 3,00,000 records, it contains some 11 primary keys i am using some update statements to update some fields in the records (of 3,00,000 i will compare some 1,50,000 records with 1,50,000 another records) i am using substr function in all the select statements. whether usage of substr function will avoid the use of index
    can any one clarify?

    contains some 11 primary keys by this I suppose you mean to say the table has a composite PK on 11 columns.
    i am using substr function in all the select statementsCould you please post your SQL statement?

  • What is the use of Lead selection?

    Hi Experts
    i am new to webdynpro.
    i would like to understand what is the use of lead selection and why do we need it?
    Thanks
    Abdul Hakim
    Moderator Message: Basic WDA question. Please search before posting
    Edited by: Suhas Saha on Aug 14, 2011 1:11 PM

    Lead selection is used to set the values to the context element.
    if you have a table and if you use lead selection , it will show that particular record highlighted.
    If you are using a drop down and used a set_lead_selection method for that, you can actually set the desired option in the list of entries.
    Basically you have an option , to set the desired entry in the list of options.
    if you are using a get_lead_selection method, you can get the selected value to the context element.

  • [svn:bz-trunk] 21292: Fix BLZ-639 - avoid the use of "==" when comparing strings.

    Revision: 21292
    Revision: 21292
    Author:   [email protected]
    Date:     2011-05-25 12:09:39 -0700 (Wed, 25 May 2011)
    Log Message:
    Fix BLZ-639 - avoid the use of "==" when comparing strings.  Just check for null explicitly.
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-639
    Modified Paths:
        blazeds/trunk/modules/common/src/flex/messaging/config/ClientConfiguration.java

    Adobe has donated BlazeDS to the Apache Flex community, and the source code is hosted on the Apache Flex website in a GIT repository.
    http://flex.apache.org/dev-sourcecode.html

  • HR PNP Logical Database Using Cost Center selection: error!?

    Hi all,
    I'm using PNP logical data base and using the selection-fields available through HR Class Reports (a copy of PAY_DEF) but what happens is if in selection-screen I fill the personnel number say 1000, i get the payroll data I'm trying to get, but if i use the search field cost center of that exact person i get nothing. Does anyone has a clue on what i might be doing wrong? Because all the other search fields work, company code, HR area, everyone, but cost center, and I'm positive that i use the right cost center.
    Thanks in advance,
    Paula

    Even though nobody answered me, i finally found the solution for my problem. so and because someone might need it here it is:
    Go to Spro->Personnel Management->Human Resources Information System->Reporting->Adjusting the Standard Selection Screen and then:
    1st Create Report Categories and
    2nd Assign Report Categories
    Since not all rep. categories on the 1st assignment is explicit on how will sel screen appear i advice you to go to the 2nd point, and execute some of the programs that appear there, and that might look alike to what you are looking for, and if you are so lucky as to find one exact use the same report category in your program, if its very alike, well, copy the Report Category into one of your own and change it the way you need it to be.
    Hope this be helpfull for someone.
    Paula.

  • How to avoid the same songs being selected by Genius playlists

    I love iTunes Genius for making play lists, but I am annoyed by the fact that some songs are chosen again and again. For some reason "16 by 32" by the Decemberists pulled nearly every time I make a Genius playlist even though I've never chosen to play the track directly. Amazingly, it has racked up 150% of the plays of the next closest track that I actively listen to. Is there some way to have Genius ignore tracks or artists entirely without removing them from my iTunes library? Are there any ways to tweak Genius to provide a better sampling of tracks rather than the same old same old?
    thanks,
    Derek

    You can uncheck the little check box to the left of track's name.
    This will mean iTunes always skips it unless you specifically select it. It has other side effects too.

  • What is the use of selection -screen on field

    Hi,
    Can anyone tell me the use of at selection-screen on field and its syntax?
    Regards,
    Hema

    Hi Hema,
    AT SELECTION-SCREEN selscreen_event.
    <b>Effect</b>
    This statement defines event blocks for different events selscreen_event that are triggered by the ABAP runtime environment during selection screen processing.
    Selection screen events occur immediately before sending a selection screen and after certain user actions on a displayed selection screen. They assist in selection screen processing in the ABAP program.
    AT SELECTION-SCREEN is triggered at least twice during actions on selection screens that are linked into another selection screen as a subscreen - first for the linked selection screen itself, and then for the linking selection screens.
    Note
    The event blocks after AT SELECTION-SCREEN are implemented internally as procedures. Declarative statments in these event blocks create local data.
    <b>Differenct Options:</b>
      | { ON {para|selcrit} }
      | { ON END OF selcrit }
      | { ON BLOCK block }
      | { ON RADIOBUTTON GROUP radi }
      | { }
      | { ON {HELP-REQUEST|VALUE-REQUEST}
      |   FOR {para|selcrit-low|selcrit-high} }
      | { ON EXIT-COMMAND }.
    <b>Example</b>
    REPORT demo_at_selection_screen.
    Global data
    DATA: sflight_tab TYPE TABLE OF sflight,
          sflight_wa  LIKE LINE  OF sflight_tab.
    Selection screens
    PARAMETERS p_carrid TYPE spfli-carrid.
    SELECTION-SCREEN BEGIN OF SCREEN 500.
      SELECT-OPTIONS s_conn FOR sflight_wa-connid.
      DATA s_conn_wa LIKE LINE OF s_conn.
    SELECTION-SCREEN END OF SCREEN 500.
    Handling selection screen events
    AT SELECTION-SCREEN ON p_carrid.
      IF p_carrid IS INITIAL.
        MESSAGE 'Please enter a value' TYPE 'E'.
      ENDIF.
      AUTHORITY-CHECK OBJECT 'S_CARRID'
                          ID 'CARRID' FIELD p_carrid
                          ID 'ACTVT'  FIELD '03'.
      IF sy-subrc = 4.
        MESSAGE 'No authorization for carrier' TYPE 'E'.
      ELSEIF sy-subrc <> 0.
        MESSAGE 'Error in authority check' TYPE 'A'.
      ELSE.
        IF sy-ucomm = 'ONLI'.
          CALL SELECTION-SCREEN '0500'.
        ENDIF.
      ENDIF.
    AT SELECTION-SCREEN.
      IF sy-dynnr = '0500'.
        IF s_conn IS INITIAL.
          MESSAGE 'Please enter values' TYPE 'W'.
        ELSE.
          SELECT *
                 FROM sflight
                 INTO TABLE sflight_tab
                 WHERE carrid = p_carrid AND
                       connid IN s_conn.
          IF sy-subrc <> 0.
            MESSAGE 'No flights found' TYPE 'E'.
          ENDIF.
        ENDIF.
      ENDIF.
    Main program
    START-OF-SELECTION.

  • Select distinct...again

    I have data that contains a column of emails, a column of
    names and
    addresses... and so on.
    some of the emails are the same and I don't want those to
    show up.
    I want to be able to pull a column of emails, a column of
    names and a
    column of adresss but I want to pull only those that have
    distinct email
    addresses.
    When I
    SELECT Distinct email, FName, LName
    FROM table1
    WHERE (MailList = 1)
    It doesn't filter out the distinct. I'm guessing that you're
    going to
    say it's pulling from the row...
    How would I make it so that I only see rows with distinct
    emails?
    Thanks
    Lionstone?

    Philo wrote:
    > for MSSQL: The DISTINCT keyword is optional with SUM,
    AVG, and COUNT.
    > When DISTINCT is used, duplicate values are eliminated
    before the sum,
    > average, or count is calculated.
    >
    > Basically it eleminiates duplicates. That does not seem
    to be what you
    > are doing. By distinct do you mean none null emails
    addresses? If so
    > than something like "where email is not null" is what
    you want.
    >
    > Art wrote:
    >
    >> I have data that contains a column of emails, a
    column of names and
    >> addresses... and so on.
    >>
    >> some of the emails are the same and I don't want
    those to show up.
    >>
    >> I want to be able to pull a column of emails, a
    column of names and
    >> a column of adresss but I want to pull only those
    that have distinct
    >> email addresses.
    >>
    >> When I
    >>
    >> SELECT Distinct email, FName, LName
    >> FROM table1
    >> WHERE (MailList = 1)
    >>
    >> It doesn't filter out the distinct. I'm guessing
    that you're going to
    >> say it's pulling from the row...
    >>
    >> How would I make it so that I only see rows with
    distinct emails?
    >>
    >> Thanks
    >>
    >> Lionstone?
    It sounds like he wants to email all the unique email
    addresses, so
    DISTINCT should work as it avoids duplicates.
    Maybe try:
    SELECT DISTINCT TOP 100 email, FName, LName
    FROM table1
    WHERE MailList = 1
    Steve

  • Select Distinct and join in ODI

    Hi,
    I have following task to perform: I am loading metadata into Planning dimension from Oracle database. I have two tables
    1. "Sales"
    Columns: Name, Number, Value
    Sample Data:
    Product 1, 10, 200
    Product 2, 30, 100,
    Product 1, 15, 500
    2. P&R
    Columns:
    Name, Alias
    Product 1, SampleSoda1
    Product 2, SampleSoda2,
    Resource 1, CanForSoda,
    Resource 2, CO2
    What I need to do is: I have to select name and alias from second table of all products that were sold.
    So I need to select distinct Name from Table 1, naxt join it with Table 2 (so I have Name and Alias) and load it to planning.
    I am a little confused how to do it.
    Any help would be great!
    Best regards,
    Greg

    Hi Greg,
    What you can do is either :
    - Create a yellow interface with your table Sales as source. Map the name column directly in the target. In the flow tab, click on your target and select "Distinct rows".
    - Create a second interface, with your first interface as source. Select the "Use Temporary Interface as Derived Table (Sub-Select)" checkbox.
    - Add your second datastore and join it. Or you can use a lookup table.
    OR
    - Create an interface with Sales and P&R as source (or set P&R as a lookup table).
    - Go on the flow tab and select "Distinct rows".
    If you've a lot a data in the first table, I would go for the first solution.
    Hope it helps.
    Regards,
    JeromeFr
    Edited by: JeromeFr on Feb 14, 2013 9:52 AM
    To be more clear in the first step of solution 1

  • Equivalent of select distinct

    Hi all,
    I have a dataset brought into my Flex app by a server-side database call as XML. I then need to use this same dataset in a couple of different places, eg in a grid, as chart data, in a combo etc. So far no problem.
    Now, for the combo entries what I would like to do is the equivalent of SQL "select distinct field_name from table_name", but applied directly to the XML I have brought back already. Is there such a beast in the XML-handling methods? I have found a work-around which sets up an Array, then cycles round the XML nodes and either adds the relevant field value as the next entry or skips it accordingly. But this seems unduly manual and (I suspect) will not be very snappy as the data set grows. Just now I am working with a fairly small test set but that will change.
    Any suggestions?
    Thanks in advance,
    Richard

    You're welcome I think that so far there isn't a method like that 
    probably an enhance request. In that case you'll need to traverse the 
    XML and add the items to another XMLList or an AC.
    Sincerely,
    Michael
    El 27/04/2009, a las 8:51, Richard_Abbott <[email protected]> escribió:
    >
    Thanks Michael and Barna, but this doesn't really address the 
    problem. The data is well structured and I am using E4X methods. But 
    the examples don't (I think) meet the need. Take the trilemetry 
    example. In the XML file we have two individuals named "John". The 
    requirement is to come up with a reduced list of unique elements so 
    including Bob, John, Jane, Art, Brad... ie John only the once as we 
    already have that name in. Clearly in this case not much of a 
    reduction but where I am generating a selection box where the 
    categorisation is much more common it is essential. Take Fisher's 
    Iris data - you have 150 rows consisting of 50 each of three kinds 
    of iris. Obviously in the drop-down selector you just want 3 names 
    not 150. I think it would be much neater if I could just pull them 
    out with an E4X-style query, but so far I haven't found a method for 
    this, hence the work-around of manually looping and testing.
    Richard
    >

  • Remote host supports the use of SSL ciphers that offer weak encryption

    Dear All,
    Our Internal security audit suggests to avoid the use of Week SSL ciphers for our SAP PI 7.0 servers.
    We have followed the SAP note 510007 - Setting up SSL on Web Application Server ABAP
    as mentioned in the point 6 we have added below parameter in the instance profile of application server  and restarted our server but still the issue is not resoved.
    ssl/ciphersuites=MEDIUM:HIGH:EXPORT:!LOW:!eNULL
    Clients are accessing our PI server through SAP Web dispatcher.
    Kindly suggest the action to be taken to resolve the issue.
    Please find the below comment from Audit.
    The remote host supports the use of SSL ciphers that offer weak encryption.
    Note: This is considerably easier to exploit if the attacker is on the same physical network
    Regards,
    Lalitha.

    Hi Jim,
    The remote host is the PI(7.0) server.
    PI server profile
    FN_JSTART = jcontrol$(FT_EXE)
    ssl/ciphersuites = HIGH:MEDIUM:!mMD5
    jstartup/recorder = java -classpath ../j2ee/cluster/bootstrap/launcher.jar com.sap.engine.offline.OfflineToolStart com.sap.engine.flightrecorder.core.Collector ../j2ee/
    cluster/bootstrap -node %nodeID% %startTime% -bz $(DIR_GLOBAL) âexitcode %exitcode%
    login/accept_sso2_ticket = 1
    SAPSYSTEMNAME = APQ
    SAPSYSTEM = 00
    INSTANCE_NAME = DVEBMGS00
    DIR_CT_RUN = $(DIR_EXE_ROOT)/run
    DIR_EXECUTABLE = $(DIR_INSTANCE)/exe
    jstartup/trimming_properties = off
    jstartup/protocol = on
    jstartup/vm/home = /opt/IBMJava2-amd64-142
    jstartup/max_caches = 500
    jstartup/release = 700
    jstartup/instance_properties = $(jstartup/j2ee_properties):$(jstartup/sdm_properties)
    j2ee/dbdriver = /oracle/client/10x_64/instantclient/ojdbc14.jar
    PHYS_MEMSIZE = 512
    exe/saposcol = $(DIR_CT_RUN)/saposcol
    rdisp/wp_no_dia = 10
    rdisp/wp_no_btc = 3
    exe/icmbnd = $(DIR_CT_RUN)/icmbnd
    rdisp/j2ee_start_control = 1
    rdisp/j2ee_start = 1
    rdisp/j2ee_libpath = $(DIR_EXECUTABLE)
    exe/j2ee = $(DIR_EXECUTABLE)/jcontrol$(FT_EXE)
    rdisp/j2ee_timeout = 1800
    rdisp/frfc_fallback = on
    icm/HTTP/j2ee_0 = PREFIX=/,HOST=localhost,CONN=0-500,PORT=5$$00
    icm/server_port_0 = PROT=HTTP,PORT=80$$
    # SAP Messaging Service parameters are set in the DEFAULT.PFL
    ms/server_port_0 = PROT=HTTP,PORT=81$$
    rdisp/wp_no_enq = 1
    rdisp/wp_no_vb = 1
    rdisp/wp_no_vb2 = 1
    rdisp/wp_no_spo = 1
    # Jcontrol: Migrated Profile Parameter
    #      create at Wed Mar 25 20:20:02 2009
    j2ee/instance_id = ID0079698
    Web dispatcher profile
    SAPSYSTEMNAME = WD0
    SAPSYSTEM = 00
    INSTANCE_NAME = W00
    DIR_CT_RUN = $(DIR_EXE_ROOT)/run
    DIR_EXECUTABLE = $(DIR_CT_RUN)
    wdisp/shm_attach_mode = 6
    # Accesssability of Message Server
    #rdisp/mshost = asapq00.b.com
    #ms/http_port = 8100
    #ms/https_port = 8101
    wdisp/system_0 = MSHOST=asapq00.b.com, MSPORT=8100, SID=APQ
    # Configuration for medium scenario
    icm/max_conn               = 16350
    icm/max_sockets            = 32768
    wdisp/HTTPS/max_pooled_con = 16350
    icm/req_queue_len          = 8000
    icm/min_threads            = 100
    icm/max_threads            = 500
    mpi/total_size_MB          = 700
    mpi/buffer_size            = 32768
    mpi/max_pipes              = 21000
    wdisp/HTTP/max_pooled_con  = 8192
    wdisp/HTTPS/max_pooled_con = 8192
    # SAP Web Dispatcher Ports
    icm/server_port_0 = PROT=HTTP,PORT=80,EXTBIND=1
    icm/server_port_1 = PROT=ROUTER,PORT=443,EXTBIND=1
    #icm/host_name_full= asapq00.b.com
    icm/host_name_full= qtyh2h.k.co.in
    icm/HTTP/admin_0 = PREFIX=/sap/wdisp/admin,DOCROOT=./admin,AUTHFILE=/sapmnt/WD0/global/security/data/icmauth.txt
    ssl/ssl_lib=/usr/sap/WD0/W00/sec/libsapcrypto.so
    wdisp/HTTPS/dest_logon_group = PUBLIC
    wdisp/HTTPS/max_client_ip_entries = 100000
    wdisp/HTTPS/sticky_mask = 255.255.255.0
    #Additional Parameters
    wdisp/add_client_protocol_header = true
    wdisp/auto_refresh = 120
    wdisp/max_servers = 100
    wdisp/handle_webdisp_ap_header = 1
    #Registering SAP Web Dispatcher in the SLD
    #wdisp/system_0 = HOST=asapq00.b.com, PORT=8100, SID=APQ, NR=00
    #Parameter to avoid week SSL ciphers
    ssl/ciphersuites=HIGH:MEDIUM:!mMD5
    Regards,
    Lalitha

  • Something´s going wrong with select distinct (Oracle 10g)

    Our database is oracle 10g release 2 and the query statement is:
    select distinct last_name
    from students;
    and the query returns all of the last_names without an specific order..
    If I execute the same query in oracle 9i the query returns all of the last_name in alphabetic order.
    Why is it different on Oracle 10g?

    See also this blog entry from Mr. Kyte.
    C.

  • OraException from Command.ExecuteReader with SELECT DISTINCT

    Hello
    I am trying to fill an OraDataReader object from a OraCommand object.
    It appears that whenever the statement includes a SELECT DISTINCT, the command fails (even though the SQL statement works fine when executed e.g. in TOAD)
    Dim Conn As OraConnection = New Oracle.DataAccess.Client.OraConnection("[Valid connection string]")
    Conn.Open()
    Dim Command As OraCommand = New OraCommand()
    Command.CommandType = CommandType.Text
    Command.CommandText = "select DISTINCT nvl(SUBFAMILY_COMPETENCY_ID, 0) SUBFAMILY_ID, nvl(NAME, ' ') NAME, FAMILY_COMPETENCY_ID FAMILY_ID " & _
    " from TAXONOMY_RELATIONAL, COMPETENCY " & _
    " where TAXONOMY_RELATIONAL.CL_ID = :1 " & _
    " AND COMPETENCY.cl_id (+) = TAXONOMY_RELATIONAL.cl_id and COMPETENCY.language_id (+) = :2 " & _
    " and COMPETENCY.COMPETENCY_ID (+) = TAXONOMY_RELATIONAL.SUBFAMILY_COMPETENCY_ID " & _
    " order by FAMILY_ID, SUBFAMILY_ID"
    Command.Parameters.Add("@CL_ID", context.Session!CLID)
    Command.Parameters.Add("@LANGUAGE_ID", context.Session!LANGUAGEID)
    Dim DataReader As OraDataReader = Command.ExecuteReader(CommandBehavior.CloseConnection)
    An Oracle.DataAccess.Client.OraException is raised when executing the last statement, but no further details are given in the error message. The stack trace begins as follows
    [OraException]()
    Oracle.DataAccess.Client.OraException.HandleErrorHelper(Int32 errCode, OraConnection conn, IntPtr opsErrCtx, IntPtr opsSqlCtx, Object src, String procedure) +639
    Oracle.DataAccess.Client.OraCommand.ExecuteReader(+737)
    Oracle.DataAccess.Client.OraCommand.ExecuteReader(CommandBehavior behavior) +8
    The exception disappears as soon as I remove the DISTINT keyword from my SQL statement.
    Is this a bug or am I doing something wrong?
    Thanks for help,
    Bernt Fischer

    This issue is same as the one mentioned in the thread with title "Problem with 'Select distinct'" and the fix would be available in the next release.

  • Is there any way to have an ipad wifi 3G but not use the 3G (therefore avoiding the extra data plan costs) and just use the wifi?

    i am looking to buy an ipad 2 or the new ipad (preferably 32gb) but dont want to buy the 3G version as i have unlimited data usage in my mobile phone plan, i know the wifi only ipad is generally cheaper, but i was wondering if there was a way to buy the ipad with 3G capabilities but not use the 3G and avoid the cost of paying the extra unnecessary data plan? (I know this is a really weird question but i have the opportunity to buy a 3G ipad and was curious of the possibility? any help would be greatly appreciated. cheers

    Yes to your questions.
    You can download a complete iPad User Guide here: http://manuals.info.apple.com/en/ipad_user_guide.pdf
    If you want an iPad 2 32GB it will have to be a refurb model. The only new iPas 2 is 16GB.
    What are all the differences between the iPad 3rd Gen and the iPad 2? Is the iPad 2 worth the cost savings?
    http://everymac.com/systems/apple/ipad/ipad-faq/differences-between-ipad-3rd-gen -2012-ipad-2-2011.html
    What are all the differences between the iPad 3rd Gen models? Which should I buy?
    http://everymac.com/systems/apple/ipad/ipad-faq/differences-between-ipad-3rd-gen -early-2012-models.html
    Should I Buy a New iPad? Or an iPad 2?
    http://www.maclife.com/article/blogs/should_i_buy_new_ipad_or_ipad_2
    iPad 3 vs iPad 2 vs iPad 1- Feature comparisons with iOS 5
    http://ipadhelp.com/ipad-help/ipad-3-vs-ipad-2/
    iPad Q&A
    http://www.everymac.com/systems/apple/ipad/ipad-faq/differences-between-ipad-3rd -gen-early-2012-models.html
    A Few Questions (and Answers) About the New iPad
    http://pogue.blogs.nytimes.com/2012/03/15/a-few-questions-and-answers-about-the-   new-ipad/?ref=personaltechemail&nl=technology&emc=edit_ct_20120315
    New iPad: A Polishing of the Old
    http://www.nytimes.com/2012/03/15/technology/personaltech/the-new-ipad-is-much-t he-same-only-better.html?nl=technology&emc=edit_ct_20120315
    iPad 1, 2 and New Specifications
    http://www.everymac.com/systems/apple/ipad/index-ipad-specs.html
    16GB vs 32GB vs 64GB: Which new iPad storage capacity should you get?
    http://www.imore.com/2012/03/08/16gb-32gb-64gb-ipad-capacity/
    How much content will fit on my iPod or iPhone?
    http://support.apple.com/kb/HT1867
    If you think you may get an iPad 2:
    Refurbished iPad Prices
    http://store.apple.com/us/browse/home/specialdeals/ipad
    New 16GB iPad 2 Prices
    http://store.apple.com/us/browse/home/shop_ipad/family/ipad/select_ipad2
    When iOS 6 comes out in the fall, the iPad 3 will get Siri, but the iPad 2 won't.
     Cheers, Tom

  • Select distinct is using the wrong index

    Hello,
    I have an indexes question?
    I have a table with 1M rows, the table structure is as follows:
    create table X(aTime DATE , a1 NUMBER(28,0), a2 NUMBER(28,0), a3 NUMBER(28,0), .... , a20 NUMBER(28,0) );
    I have also 2 indexes:
    - IDX1 is defined on (aTime, a1, a2, a3).
    - IDX2 is defined on (a1, a2, a3).
    I run the following query: "SELECT DISTINCT A1, A2, A3 from X;" and see that the optimizer chooses to do a FTS (full table scan) though I was expecting him to use IDX2 because it looks like a "covering" indexes giving all the answers to the query without fetching data rows.
    When I try to force him to use indexes, using the following hint "/*+INDEX(X IDX2)*/" the optimizer chooses IDX1.
    When I use same hint after I dropped IDX1 the optimizer still prefers to make FTS .
    Some general info:
    - a1, a2 and a3 have about 500 distinct values each).
    - db version 8.1.7.4.
    - all tables and indexes are analyzed.
    I have two questions:
    ===============
    1.
    Why does the optimizer prefers IDX1 (aTime, a1, a2, a3) over IDX2 (a1, a2, a3) when the query specifically requests distinct values of (aTime, a1, a2, a3), isn't there a shortcut the optimizer should use here?
    2.
    When I request the optimizer to use specific index (using hints), shouldn't it use the index I request regardless of his calculations? If not, is there any way to change this behavior?
    Tal Olier
    [email protected]

    You said you analyzed the tables and indexes. Did you also analyze the indexed columns?
    A full table scan may be a better execution plan than using an index, especially if you are selecting the full table.
    Remember that a hint is jut that, a hint. It suggests to the optimizer to do something, but the optimizer may still choose a different plan.

Maybe you are looking for