What query is good in Performance?

Hi all

I'm trying to find duplicate records, PK-based. I wrote 2 queries. Can someone tell me what is the best in performance & why?

Query 1
Select the rowid, * from my_table a
where ROWID is NOT in)
Select max (ROWID)
from my_table b
where a.COL1 = b.COL1
and a.COL2 = b.COL2
and a.COL3 = b.COL3)
and COL3 = to_char (to_date ('20090404', 'YYYYMMDD'), 'DD-MON-YYYY')


Query 2
Select * from my_table where rowid NOT IN (select MAX (ROWID) group by COL1, COL2, COL3 my_table)
and COL3 = to_char (to_date ('20090404', 'YYYYMMDD'), 'DD-MON-YYYY');

Thank you
ACE

Is COL3 in this example a VARCHAR2? Or a DATE?

It is useless to take a literal string ('20090404'), that convert a date, and then convert the date to a string in a different format. If COL3 is a DATE, which I guess it is, then that COL3 to be converted to a string (using NLS_DATE_FORMAT of the session, which is subject to change), the forces preventing the use all indexes on COL3. If you take a string, convert it to a date and convert into a string so that you can compare it to something that gets converted from a date to a string. That's a lot of conversion going on, some of them implicit and therefore fragile.

Especially if performance is a concern, you always want to compare the strings to strings, dates, dates. Comparison of strings to dates is fragile at best.

Justin

Tags: Database

Similar Questions

  • What is a good backup drive

    My Seagate Free Agent GoFlex Home cratered on me backup.  What is a good backup drive to replace it with?

    I use WD My Passport on x 6 Mac without issue for backups Time Machine and CCC clones, these are bus-powered readers.

    I have also used a WD My Book World Edition II nas drive but have just been crossed to a Synology Diskstation in after the use of this brand to work as a file server.

  • What is a good DVD Ripper?

    Didn't know where to post this question...

    In any case, what is a good DVD ripper software?

    I have some movies on DVD (with menus, etc.), which are non-commercial unprotected DVD.  I have full right to get video off them.

    They are actually in my storage in the form of ISO images.

    Right now I use the free version of WinX DVD Ripper.  I'm willing to pay for something better.

    The two most widely recommended are Handbrake (free) and MPEG Streamclip (free, but also requires the reading QT component, which Apple sells more).

    Russ

  • What is a good antivirus software for mac and do I need?

    What is a good antivirus software for mac and would need one. I'm under el capitan, later.

    There is no such thing. They all cause more problems than they were designed to solve.

  • What is a good replacement for Photos for Mac

    I got my photos sorted by year and month in iPhoto, app Photos The destroyed that.  What is a good replacement for Photos for Mac I had digital pictures in 1999.  It will take me months to recover.  So what is a good replacement, needless organized storage edition, just logical.   Is there a product that I can export Photos to the?   The Photos application is too slow and freezes; It's just all around a mediocre product.

    Migrating from iPHoto to Photos doesn't "destroy" anything - it keeps your albums events and converted into albums - pictures 2.0 vs iPhoto 9.6.1: features and capabilities - how many Photos handles content and metadata for iPhoto and Aperture - Apple Support

    and of course iPhotos 9.6.1 still works very well - if you do not keep your system up to date see can't update iPhoto because it is not available in the App Store

    You can export Photos in keeping the Organization of moments - you can export iPhotos keeping the exporting from iPhoto event organization

    As to products - it's your choice - you can use the finder to organize into folders and preview to display pictures - or you can use one of the many programs available ranging from the free to the very expensive

    I use Photos so am not upward on the different options and I suspect most of the volunteers here are the same and the answer is going to be personal anyway - no one but yo can do

    LN

  • What is a good cpu readings?

    What is a good cpu readings?

    Hello

    1. What is the brand and model of your processor?

    2. is your computer overheating?

    See the article and see if it helps.

    Different ways to determine CPU speed in Windows XP or Windows Server 2003

    http://support.Microsoft.com/kb/888282

    Previous post your answer for you help in this matter.

  • What DVDs are "good quality"? I have

    Hello.  I am about to create recovery disks for my new laptop (HDX 16 t) and the brochure says "you need CD - r high quality (even if they don't recommend because they hold no CD), DVD-r, DVD-r double layer or + r... TC"with a set of recovery disks can be created by computer, I think it should I use what they consider 'good quality' but I have not the slightest idea what it is.  I understand the DL will hold twice as much (and), so I think I'll buy a couple of people.  I have 100 pins pack of the cheapies like TDK, Sony and Memorex (4.7 GB), but I have a feeling that it may not be 'good quality '.  Can anyone give me some suggestions?  Thank you.  Nancy

    Sony always gives me good results.

  • What is a good figure for the average number of virtual machines per server?

    I hear everything from 10:1 to 100: 1.  What is a good average, and analysts say?

    So what are the good standards of processors and apps

  • What is a good gaming site?

    What is a good site that let's you download free games, no ads and no torrent. I'm also looking for good suggestions, 2D platform game games.

    Thank you.

    Steam has a number of games "Free to Play". 21 single player mode, but I've not bothered with them so don't know if they are good or not.
    EA has a 'Free to Play' section. I them have not tried either (lower limit of download here in Oz).
    I have a game - Mario Forever, you should be able to download from horizontal scrolling
    somewhere (mine from a disk magazine).

    Many sites that claim to be free let alone you play for free for a limited time, you give a demo version or will charge you different DLC that you will need to advance in the game.
    In other words - "Play for Free" = marketing hype.
    He money of cost to operate a site, or online, server, so if you can get decent playable games with just advertising I think this is what you can expect.

    If you're willing to pay, say $2-5 USD for a trial of game good old games. They have a lot of classics
    (much more for $10).
    http://www.Gog.com

    Platform games is not real currents on PC, but I bought the collection of the Oddworld Oddysee (four matches) Abe earlier on a sale of steam for about $8. I also bought Rayman Origins of steam on one of their periodic sales recently for a similar amount (don't remember exactly).

  • What is a good DVD ripper software?

    Didn't know where to post this question...

    In any case, what is a good DVD ripper software?

    I have some movies on DVD (with menus, etc.), which are non-commercial unprotected DVD.  I have full right to get video off them.

    They are actually in my storage in the form of ISO images.

    Right now I use the free version of WinX DVD Ripper.  I'm willing to pay for something better.

    XviD4PSP 7.0.267 / 5.10.346 - download

    Use version 5.

  • I have a SSD C drive and a larger secondary drive. Where to install the products. What is the best for performance?

    I have a SSD C drive and a larger secondary drive. Where to install the products. What is the best for performance?

    installation on your SSD will give better performance, but can consume a lot of disk space.

  • What is a good practice to manage LOV in jdev apps?

    Hi, experts,
    In jdev 11.1.2.3,.

    In our projects, there are numerous LOVs whose value are stored in a common dictionary table, for example in the refcode table:
    refcode (id, low_value, high_value, sense, domain_no),
    Different LOVs can extract value peers (low_value, meaning), or (high_value, sense) refcode table by using domain_no as the filter criteria.

    In the user interface of the user, the values of field/code number should be displayed by a sense of refcode password
    To achieve this, I'll create many links between the different tables with refcode,
    and create your entity refcode consider the secondary entity views.

    I feel some odd (because so many associations with the same table refcode),
    What is a good practice to manage LOV in this way?

    Thank you.

    The merger for Oracle Application Development Framework Developer's Guide
    10.3 defining an object of basic display for use with Lookup Tables
    (http://docs.oracle.com/cd/E37975_01/web.111240/e16182/bclookups.htm#BABIBHIJ)
    10.3.3 How to set the WHERE Clause of the view of search criteria to display object

    There is valuable information and suggestions on the search features to implement, in particular using view criteria
    (see criteria and display accessor is one of the important and a great idea in ADF)

    I think that, by using the view criteria, attribute derived to display information of fk can be implemented without definition of associations FK convinent way.

  • What are some good 'Add-ons', so I can change Thunderbird to use it to send mass e-mails? (200-300-400, at the same time)

    What are some good 'Add-ons', so I can change Thunderbird to use it to send mass e-mails? (200-300-400, at the same time)

    The limit for mail "in bulk" is defined by your email provider.

  • What query can we use... .for more than 30 days

    Select the PROPERTY, RELAVANTDATE,
    Sum (records) more)
    partition of property
    order of RELAVANTDATE
    between the '30' day interval preceding and the current line
    ) "SUM".
    of Test_Data

    What query can we use... .for more than 30 days
    can I use following or preceding
    SCOTT@soti_9> WITH Test_Data AS (
      2    select 10100 as property, to_date('25-JAN-07') as RelavantDate, 20 as notices from dual union all
      3    select 10100 as property, to_date('25-DEC-07') as RelavantDate, 5 as notices from dual union all
      4    select 10100 as property, to_date('02-JAN-08') as RelavantDate, 10 as notices from dual union all
      5    select 10100 as property, to_date('01-DEC-08') as RelavantDate, 10 as notices from dual union all
      6    select 10100 as property, to_date('02-DEC-08') as RelavantDate, 20 as notices from dual union all
      7    select 10100 as property, to_date('31-DEC-08') as RelavantDate, 20 as notices from dual union all
      8    select 10100 as property, to_date('03-JAN-09') as RelavantDate, 30 as notices from dual union all
      9    select 10100 as property, to_date('25-JAN-09') as RelavantDate, 20 as notices from dual
     10  )
     11  select PROPERTY,RELAVANTDATE ,
     12    sum(NOTICES) over (
     13      partition by property
     14      order by RELAVANTDATE
     15      range between current row and interval '30' day following
     16    ) "SUM"
     17  from Test_Data
     18  ;
    
      PROPERTY RELAVANTD        SUM
    ---------- --------- ----------
         10100 25-jan-07         20
         10100 25-dec-07         15
         10100 02-jan-08         10
         10100 01-dec-08         50
         10100 02-dec-08         40
         10100 31-dec-08         70
         10100 03-jan-09         50
         10100 25-jan-09         20
    
    8 rows selected.
    

    Kind regards
    Dima

  • What is a good way to use the queues for the model of consumers/producers?

    Hi all

    I am following the model of consumers/producers to use the queue to synchronize the following process: the producer is a loop to produce a number N, I will put each number generated in a table and after each 5 numbers generated, I put the table in the queue and pass it on to the consumer. I have to wait the use by consumers of the data and it will then remove the item from queue so that producers will have the chance to produce another 5 numbers. As I put the maximum size of the queue one, I expect that the producer and the consumer turns to produce / consume all five numbers and the opportunity to another. Here is my code

    When the checkbox is false, the code will be

    For the first 5 numbers, product will generate every thing right and put it in the table, and it's going to pass the array to the quere so that the consumer will have the chance to loop through the table. I except the procude loop will continue only when the queue is available (i.e. all items are deleted), but it seems that once the consumer starts the loop loop of the product will continue (if the indicator x + 1 and x 2 will be changed to numbers). But this isn't what I want, I know there must be something wrong, but I can't say it is.

    dragondriver wrote:

    As you say in 1, sequency structure to enforce the order of execution, that's why I put it here, in this example, the simple question, I replace the complete code with increase in the number, in the real case, the first markers + 1 and + 2 must be performed in this order.

    Mikeporter says:
    1. get rid of all the structures of the sequence. None of them are nothing but apply a work order which would have been the same without them.

    So even if you delete the sequence structure, there will be a fixed & defined order and it is because LabVIEW follows the MODEL of FLOW OF DATA.

    Data flow model (more precisely in the context of LabVIEW): a block diagram node runs when it receives the required inputs. When a node is running, it produces output data and transmits data to the next node in the path of the data stream. The flow of data on the nodes determines the order of execution of the VIs and functions on the block diagram (click here for reference).

    Now in your code, just remove the sequence structure will not make you order will be going to stay the same, but you need to do some very minor changes (as thread of the error in loop, before that he go to the node "Élément Dequeue").

    Come to the main point: it's a good way to use the queue for the consumer/pmodel that?
    The model you are using (and qualifying as consumer/pmodel) is much too deviated from the original consumer/pmodel which model.

    dragondriver wrote:

    For the second, Yes, it's my fault for delete, though. I'm actually the example of model of producer/consumer design pattern, but I do not pay attention to the while loop in the part of the consumer.

    While loops (two producers & consumers) are the essential part of this architecture and cannot be deleted. You can start your code using standard model.

Maybe you are looking for

  • How to save downloads to a flash drive?

    I use Ubuntu 10.4LTS & Firefox 9, when downloading a file in the box from Firefox I get 'open with' or 'save' window; but I want to save to a flash drive * NOT * downloads. How to achieve what should be a simple task? Thank you.

  • User spell String input

    Hello This is a fundamental question, no doubt, but it gives me a lot of trouble. I want to capture the user input double floating point via a digital control (azimuth & site), take double that and move the number as a hexadecimal string specifying a

  • picture on my monitor is huge

    I had to use my recovery disc on my windows xp desktop. Now the image on my monitor is huge and when I go into Control Panel, settings not offer or don't allow me to change the display resolution. No choice. All buttons or tabs associated changes are

  • The location where the windows update stores data has changed and needs to be repaired

    I couldn't down the updates for the month. I ran attach it to microsoft, but he told me that the situation has changed and it needs to be repaired. Someone knows how to do this?

  • Estimated time to upgrade Windows 8 for Windows 8 Pro

    I have a Toshiba laptop with a copy OEM Windows 8 pre - install and I want to upgrade to Windows 8 Pro with my retail key I bought. I was wondering how long it will take to do this, use add new features. I have a few programs installed, including all