Need to know which condition is better

Hi,
i have one table in which most of the records are unique.
What would be better , to create index or to continue without index.
I need faster response of the query . No of rows in table is 32 lac.
below is the output with index and without index for some sample data.
in first scenario i have two indexes.
in second scenario i have only one index
in third one i don't have any index.
here col2 is having only 2-3 distinct values while both other columns are having almost unique values ( different data )
SQL> set autotrace traceonly
SQL> SELECT COUNT(*)
FROM my_table
WHERE col1 =28582
AND col2='1'
AND col3 ='1452631' ;
Elapsed: 00:00:00.47
Execution Plan
Plan hash value: 2123134521
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 |16 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 |16 || |
|* 2 | INDEX RANGE SCAN| IND_my_table_1 | 1 |16 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("col1"=28582 AND "col2"='1' AND
"col3"='1452631')
Statistics
1 recursive calls
0 db block gets
3 consistent gets
0 physical reads
0 redo size
3882329993 bytes sent via SQL*Net to client
492 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> drop index Ind_my_table_1;
Index dropped.
Elapsed: 00:00:00.66
SQL> SELECT COUNT(*)
FROM my_table
WHERE col1 =28582
AND col2='1'
AND col3 ='1452631' ;
Elapsed: 00:00:01.52
Execution Plan
Plan hash value: 2881393183
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 16 | 4(0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 16 | | |
|* 2 | TABLE ACCESS BY INDEX ROWID| my_table | 1 | 16 | 4(0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | IND_my_table_2 | 1 | | 3(0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter("col2"='1' AND "col3"='1452631')
3 - access("col1"=28582)
Statistics
199 recursive calls
0 db block gets
31 consistent gets
2 physical reads
0 redo size
514 bytes sent via SQL*Net to client
492 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
6 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> drop index Ind_my_table_1 2;
Index dropped.
Elapsed: 00:00:00.07
SQL> SELECT COUNT(*)
FROM my_table
WHERE col1 =28582
AND col2='1'
AND col3 ='1452631' ;
Elapsed: 00:00:00.70
Execution Plan
Plan hash value: 1679787526
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 16 | 6431(2)| 00:01:18 |
| 1 | SORT AGGREGATE | | 1 | 16 | | |
|* 2 | TABLE ACCESS FULL| my_table | 1 | 16 | 6431(2)| 00:01:18 |
Predicate Information (identified by operation id):
2 - filter("col2"='1' AND "col1"=28582 AND
"col3"='1452631')
Statistics
169 recursive calls
0 db block gets
29754 consistent gets
0 physical reads
0 redo size
514 bytes sent via SQL*Net to client
492 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
5 sorts (memory)
0 sorts (disk)
1 rows processed
Pl suggest how should i create the index.

Hi,
KriC wrote:
... here col2 is having only 2-3 distinct values while both other columns are having almost unique values ( different data )
SQL> set autotrace traceonly
SQL> SELECT COUNT(*)
FROM my_table
WHERE col1 =28582
AND col2='1'
AND col3 ='1452631' ;
Pl suggest how should i create the index.There's no substitute for actually trying things on your system, with your full data.
You may not be able to try different ideas on your Production system, but your Test system is probably closer that anything that anyone else on this forum has.
My best guess, for queries like the one above, would be a compound index in (col1, col3, col2) or (co3, col1,col2). Col2 is least selective (that is, fewest unique values) so it should definitely be last. There may not be any advantage to including col2 in the index.
Assuming you do create a compound index that starts with col1: that will not help in queries where col1 is not specified, but col3 is. If you sometimes run queries like that, you might want a separate index on col3.

Similar Messages

  • Need to know which exit to be used in me21

    Hi Guys,
    i want to know which user exit to be used in me21 so that
    if the PO has a delivery address that is outside the US; then the tax code should be EX and the tax jurisdiction code should be 7777777770.
    i had found lots of user exits in me21 but i want to know which one will fullfill my requirement.
    i am waiting for ur replys,
    regards,
    maqsood

    by seeing the short description, u need to know which exit is suitable, its just a trial and error method.
    the requirement u r telling seems to be like field exit.
    u need to take help from basis guy to register first.
    then the procedure to create field exit can be seen in below :
    http://www.sap-img.com/abap/field-exits-smod-cmod-questions-and-answers.htm
    http://www.sappoint.com/abap/userexit.pdf

  • I need to know which install disk to buy for my mac serial number 17*****ZE4

    Need to know which install disk to buy since I lost my original.
    <Edited by Host>

    You have an 24" Early 2008 iMac. It came with Mac OS X 10.5, and you would need the disk set for your specific model. It's possible that if you call Apple Support, they can still sell you a set, but that model of iMac is no longer supported by Apple so Support may not be able to help. If not, then you'll need to look to private sellers or companies that sell obsolete software.
    You can also call the online Apple Store and purchase a retail copy of Mac OS X 10.6 Snow Leopard.
    Regards.

  • I need to know which country imei starts from 01254300

    I need to know which country imei starts from 01254300
    plzz. help me

    read this?
    http://en.wikipedia.org/wiki/International_Mobile_Equipment_Identity

  • Need to know which upgrade to purchase

    I'm staggered that Adobe makes it this difficult to even get advice.
    I have been using Photoshop CS3 on a MacbookPro.  I recently upgraded (was upgraded!) to Mavericks.
    Now Photoshop CS3 no longer works (of course).
    I need to know which product to purchase as an upgrade that WILL work.  I can't find any sales number to call to ask, or any way to chat with sales personnel.  I find a forum to be an extraordinarily time-consuming way to ask what is probably the simplest question out there.

    You have 2 choices:
    Join the Creative Cloud (monthly subscription) and get the current release PS CC 2014.
    Creative Cloud pricing and membership plans | Adobe Creative Cloud
    Or, purchase the older PS CS6 (the last  suite Adobe sold outright). 
    Creative Suite 6
    Understand that if you purchase CS6, it will never get the updates that Creative Cloud users get.
    Nancy O.

  • How to know which condition amount of PO will be added to invenotry

    Hi,
      I am making a report of material moving average price  vs  last Po price aginst which GR is made  so I want to know  how to know that  from the purchase order all conditions  which condition amount will be added to inventory  like in case of import PO along with material cost octri and fright  conditioon which are added as delivery cost  amount of those conditions are added to invenotry  and excise duty  which is also delivery cost are updated in cenvat,  so how to know  from all condition which amount will be added to invenotry.
    I dont want to take amoun which is updated at the time of GR.
    regards,
    zafar

    Hi,
      Thanks for your reply,  in case of FI  condition in OBQ3   if any accout key is assign there we can check this in OBCN  from there it is easy to understand whethere it is dedcuctible or non deductable  but in MM i am not getting details whethere the condition is deductable or non deductable 
    FRB1  delivery cost  condition account key Z04  is assign the amount of this codnition is added to the materila account
    JCVD delivery cost condition account key is Z07  the amount of this condition is not added to the material now in customizing of those account key Z04 and Z07  in Define Transaction/Event Keys there is no setting for this  then how to know  whether the amount of particular condition will be added to inventory or not.
    regards,
    zafar

  • Need to know which altec lansing speakers i have...

    Product name: HP Pavilion g6-1b54ca Notebook PC
    Serial number: 5CG1250FNX
    I blown off my speakers...i just need to know that which altec lasning speakers i have...that i can search on internet...please help...

    Hello MeetDave,
    Take a look in your Maintenance and Service Guide Manual, which should list all replaceable parts, part numbers, etc.  When I check the "product specifications" page, it says, "SRS Premium Sound with Altec Lansing speakers." 
    If the parts can be replaced, you will find them at HP Partsurfer
    Good luck!
    ↙-----------How do I give Kudos?| How do I mark a post as Solved? ----------------↓

  • Need help knowing which effect this is.

    Hey guys  I need some help with an effect in a video I saw and I was thinking maybe someone here would know which effect this is.
    So it's the effect that occurs after 10 sec.
    Thank you in advance

    What effect after 10 seconds? There's a scale/jitter effect then an over exposure effect with fades to black and there's a blue light streak? You mentioned brush strokes so I think it's the light streak.
    For that you can use Beam, or small solids stacked on top of each other with various blurs and blend modes set to Add or Screen and a lens flair, or a half dozen different particle effects, or . . .
    Catch a still frame and show us what you're trying to achieve and we can help more.
    or ??

  • I need to know which product will allow me to take a photo and enlarge it and segment it to be printed out on standard 8x10 sheet to be pieced together into one big print.

    Does photoshop have this function? I need to know before I buy since this is a primary feature I am looking for

    Only your local Sony Xperia Support can answer this try and contact them.
    http://support.sonymobile.com/global-en/contactUs/

  • Need to know which is better and faster for laptop memory upgrade

    What is the difference and which is better for a laptop memory upgrade:  SDRAM, DDR SDRAM, SIMM?  One site suggested DDR SDRAM and BB suggested SO DIMM

    SODIMM is the physical form factor of the module, DDR SDRAM is the actual memory type.
    SIMMs are an ANCIENT form of memory module.  If you have a system that uses SIMMS, you will spend less money throwing your computer in the trash and buying a new one.
    Non-DDR SDRAM is also ancient.
    Each system can only use one type of memory, i.e. you can't use DDR memory in a system that only used non-DDR memory, and you can't use DDR2 memory in a DDR system.
    To find out if the configuration is 2x256 or 1x512, you'll need to look at what is installed.
    *disclaimer* I am not now, nor have I ever been, an employee of Best Buy, Geek Squad, nor of any of their affiliate, parent, or subsidiary companies.

  • Can I know which mobile s better and louder in spe...

    can any one tell me which mobile is louder and better in its speakers sound in music playing N95 or N82??
    plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

    I want to know if the quality and loudness of internal speakers of N82 is the same in N95 in music playing or N95 is better and louder in its speakers sound in music playing ?? as I like to use my mobile as multimedia device so I want your help to choose best multimedia device of them

  • Need to know which nokia phone does not have keypa...

    Hi,
    i need to find out which phones doesnt have the keypad lag in my E52 as mentioned. I text a lot using T9 and this is really killing me.
    Hope to know if is a S60v3 problem or its just the E52.
    The problemis mentioned here. thanks.
    /t5/Eseries-Devices-and/E52-t9-typing-lag/td-p/665629

    Never noticed a lag in any of my phones. I have also used an E52 and did not notice any lag. Could be due to the set up or applications installed on your phone or maybe I don;t type as fast as you.
    Did you have this problems from the day you got the phone? If not then you could try resetting your phone to revert it back to the out of box state.

  • Need to know which query to use  in BI 7.0 BI Statistics

    Hi
    I want to develop a query that gives like user id, query name and how many times executed in a given period. We are using BI 7 stats content. I like to know what chars and key figures to be used on my query. My selection criteria is given a query name and period, retrieve userd ids and how many times executed.
    Is there any std query which I can use in BI version 7.
    Note :  I am NOT  interested in BW3.5 since have installed 7.0 version.
    Any help in this regard is a great help.

    i am not sure if some standard query is available
    but u can desing ur query quickly
    try to use the multiproviders 0TCT_MC01 &  0TCT_MC02
    0TCT_MC01-- FRONT END OLAP STAT AGGREGATED
    0TCT_MC02-- FRONT END OLAP STAT DETAILED.
    0TCT_MC02  has the detailed steps
    use USERNM , BI APPLICATION OBJECT & BI APPLICATION in rows  and then use COUNTER, COUNT OF BI APPLICATION & COUNT OF BI APPLICATION OBJECT in Columns.
    Design this query.
    try to use calday, and Timestamp in Free chars...
    try to run the query from both multiprovider and try to verify ur result.
    from my xperience if u use  0TCT_MC02 it will give u detail steps so try to use this....
    u can use standard queries, but as u r familiar with ur requirement the best approach is to design ur own query asu have to then spend time understanding the standard queries and change them.
    but the data that u need with respect to user id, query ran, etc is available in  0TCT_MC01 &  0TCT_MC02

  • Need to know which collaboration room to use for my requirement

    Hi All,
    I have a very limited idea of KMC. I am in Composite Developement
    I have a reqiurement in which a person A needs to invite some  other persons to discuss an issue and after the discussion with them needs to take a decision. But any of these persons can be offline. So they may not reply in real time but after they log into the portal.  The participants should be able to see the previous discussions which they missed so that they  can get info of what discussions has taken place while he/she was away.
    Please help me as to which collaboration room i should use for this and some guidance also how to set it up .
    Thanks
    Points assured for help.

    Hi Shobhendra
    You can use standard Discussion rooms for ur requirement.
    They are basically used for <b>asynchrnous collaboration</b> purpose in which case users might be offline.
    For details see
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/c7/a20741375cf16fe10000000a1550b0/frameset.htm
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/b9/9b0c42e1c25f24e10000000a1550b0/frameset.htm
    (Award points if found useful)

  • I need to know what laptop is better

    I have to know what laptop would be better [specs wise] for playing games like call of duty, crysis, grand theft auto, etc...
    The HP Pavilion DV6Z Quad Series or 
    The HP Pavilion DV6T Series
    Sorry if this is in the wrong section!
    Please reply ASAP

    Colin, welcome to the forum.
    I moved your thread to the correct forum and section.
    I realize that you are interested in the dv6t or dv6z series.  However, I would not recommend either for gaming.  The games that you want to play require some serious power to run properly.  I ran a search for gaming laptops.  Here are the two laptops that were recommended.  They cost more initially, but I feel that you would be far more satisfied with the performance and save money in the long run.
    As a gamer myself, I am not a fan of using laptops for gaming.  They can have a problem with heating.  There is not much space in the case for cooling.  The two in the link provided would be my choice if I had to choose for myself.
    If you have further questions, I would be glad to answer them.
    Please let us know if this solves your problem or not.
    Signature:
    HP TouchPad - 1.2 GHz; 1 GB memory; 32 GB storage; WebOS/CyanogenMod 11(Kit Kat)
    HP 10 Plus; Android-Kit Kat; 1.0 GHz Allwinner A31 ARM Cortex A7 Quad Core Processor ; 2GB RAM Memory Long: 2 GB DDR3L SDRAM (1600MHz); 16GB disable eMMC 16GB v4.51
    HP Omen; i7-4710QH; 8 GB memory; 256 GB San Disk SSD; Win 8.1
    HP Photosmart 7520 AIO
    ++++++++++++++++++
    **Click the Thumbs Up+ to say 'Thanks' and the 'Accept as Solution' if I have solved your problem.**
    Intelligence is God given; Wisdom is the sum of our mistakes!
    I am not an HP employee.

Maybe you are looking for

  • One single click to install air application without air runtime or Internet ?

    Hi Guys we want to install a air application on the end-user's computer.but the problem is that the end-user's computer will not have AIR Runtime and do not connect to the Internet, and we want to user just one click can install the AIR Runtime and o

  • Cisco Call Manager Attendant Console error

    When I try to transfer an incoming call to a mobile phone with this software I can't do it. What's happening?.

  • Editing While Loop Conditions hangs JDeveloper 10.1.3

    Hi Guys, Having a strange problem when I tried to edit the condition in a while loop after it was created and set first time. The IDE just hanged when I tried to open the expression builder and after a while, nothing happened, the expression builder

  • UCES licensing - External Users

    Has anyone had experience in regards to external user licensing and UCES. For example, I have a customer that will want to use the customer e Services. I have them create the user id and password, and they are able to perform the e services. Is this

  • VMS 2.2 On win2003 server

    Can VMS 2.2 or 2.3 be installed on windows 2003 server. if they can be then how