which way is the best to write this query?

Hello
consider the following 2 queries

SCENARIO 01
=========
Select a.company_name, a.company_address, a.company_contact, b.item_name, b.item_unit_price
of company_master an inner join company_items b on a.company_id = b.company_id

SCENARIO 02
=========
Select a.company_name, a.company_address, a.company_contact, b.item_name, b.item_unit_price
company_master a, company_items b
where a.company_id = b.company_id

which method is the fastest? (more than 1000 companies and 1000000 + elements) is 01 or 02?
and what is the 2nd method usually called? ;)

novicedba wrote:
Hello
consider the following 2 queries

SCENARIO 01
=========
Select a.company_name, a.company_address, a.company_contact, b.item_name, b.item_unit_price
of company_master an inner join company_items b on a.company_id = b.company_id

SCENARIO 02
=========
Select a.company_name, a.company_address, a.company_contact, b.item_name, b.item_unit_price
company_master a, company_items b
where a.company_id = b.company_id

which method is the fastest? (more than 1000 companies and 1000000 + elements) is 01 or 02?
and what is the 2nd method usually called? ;)

Queries are probably the same, the difference being one are written in ANSI SQL and the other in SQL ANSI traditional pre. To be sure, test the two - get execution plans, execution and execute the metrics.

What is the best, it is to you. Some people prefer ANSI that uses IT to indicate the joins and WHERE indicated condtions filter; Personally, I prefer the traditional syntax it is easier to read.

Outer joins make queries run more slowly. Avoid them if you can. Outer joins are used to return a row in a table if the join data does not exist in the other table. Once again, they degrade performance.

Cross joins are almost never necessary. They are useful to indicate joins Cartesian intentional for the results of Matrix Games. Cartesian joins are notorious for using too many system resources (especially when you work with a large amount of data) and returrning of incorrect results and can happen by running a join without specifying a join condition: all columns will be joined between the two tables, even when they do not match. In 10g and 11g the optimizer sometimes will perfom Cartesian joins make queries run faster but is always scary to see the "Cartesian" word in an execution plan

Tags: Database

Similar Questions

  • Which way is the best instantiate the Table level replication tables

    Hello

    I just got a doubt. Which way is the best to instantiate the tables of replication at the Table level.
    I need 20 100 tables replicate tables.
    In this way or

    DECLARE
    ISCN NUMBER;
    BEGIN
    ISCN: = DBMS_FLASHBACK. GET_SYSTEM_CHANGE_NUMBER();
    DBMS_APPLY_ADM. () SET_TABLE_INSTANTIATION_SCN
    source_object_name = > ' SCOTT. EMP',.
    source_database_name = > ' DB1. WORLD ',.
    instantiation_scn = > iscn);
    DBMS_APPLY_ADM. () SET_TABLE_INSTANTIATION_SCN
    source_object_name = > ' SCOTT. DEP. ',.
    source_database_name = > ' DB1. WORLD ',.
    instantiation_scn = > iscn);
    END;
    /


    This way:

    DECLARE
    ISCN NUMBER;
    BEGIN
    ISCN: = DBMS_FLASHBACK. GET_SYSTEM_CHANGE_NUMBER();
    DBMS_APPLY_ADM. () SET_TABLE_INSTANTIATION_SCN
    source_object_name = > ' SCOTT. EMP',.
    source_database_name = > ' DB1. WORLD ',.
    instantiation_scn = > iscn);
    END;
    /


    DECLARE
    ISCN NUMBER;
    BEGIN
    ISCN: = DBMS_FLASHBACK. GET_SYSTEM_CHANGE_NUMBER();
    DBMS_APPLY_ADM. () SET_TABLE_INSTANTIATION_SCN
    source_object_name = > ' SCOTT. DEP. ',.
    source_database_name = > ' DB1. WORLD ',.
    instantiation_scn = > iscn);
    END;
    /


    How can I apply ISCN even or the of the ISCN individual.

    Thank you
    Ray

    Hello

    Find the RCS of the source, and set if for all tables by using the dbms_apply_adm.set_table_instantiation_scn API.

    Thank you
    Florent

  • Why my game Center freezes when I go by parameters or directly by clicking on the center of games? Can I know which method is the best to use to solve this problem? Also, I use an iPhone 6 s, iOS 9.3.1

    Why my game Center freezes when I go by parameters or directly by clicking on the center of games? Can I know which method is the best to use to solve this problem? Also, I use an iPhone 6 s, iOS 9.3.1

    Have you ever tried to force reboot the phone by holding down the button sleep and home for 10 seconds, until the call logo comes back again?

    You won't lose data, but it can cure a few glitches.

    If this does not work, the initial Setup would be the next step:

    Use iTunes to restore your device to factory settings - Support Apple iOS

  • What is the best solution for this idea...

    I have a task I'm trying to test and understand what would be the best solution for this, any recommendations would be appreciated.

    Devices at your fingertips:

    -2 ESXi hosts

    -1 iSCSI SAN OpenFiler (new just installed the app)

    2 ESXi hosts run a small amount of virtual machines that are all in the same domain.  I want to have a file server (or a repository somewhere) that houses a folder with easily accessible software (OS, Office, etc.) on the field.

    According to me, that if I made a virtual machine with a large hard drive and share the software, this would not be the best way because it would be dependent on the OS.  Someone has talked about doing a separte VMDK for it and then install it on the operating system on the virtual machine. This way I could always remove the and mount it somewhere else.

    It seems a bit weird to me that the software within this "shared folder" will also be sitting on the data store (if I create a virtual machine and need to use the OS/etc).  Not that doubles the space for the same software (in the comments, then the data store)?

    What is the best approach to make this action which can be accessed at the prompt (mostly windows) in the field?

    What is the best way to stay away the software doubles in action and on the data store?

    Please forgive me if I put interpereted your question.

    The problem you seem to face is that you must mount the ISOs of VMS software and physical systems that are on the field.

    (please, correct me if I'm wrong on this)

    If this is the case, then the best way to do would be to create sharing NFS on the openfiler, if you use openfiler to main databases also then he would be better for sharing this was separated to prevent the other help to be able to tamper with the VMDK and VMX files for your virtual machines.

    This could then be mounted in ESX to access the ISOs. While being easy to install on Linux and Windows machines to access the ISOs.

    If you have questions about NFS mounting in windows, so, this link may help

    http://sagehacks.WordPress.com/2009/01/21/HOWTO-mount-NFS-shares-under-Windows-7

    If you are needing to access the VMs software and it is mainly the downloading ISOs then th ISO directly to the data store is possible.

    This allows you to use ESX to mount the ISO on the virtual machine.

    On the point that the software will use double disk space when you install the software on a machine virtual car will be on the network share and the VMDK virtual machines in the data store. That's right, and that's by design.

    Each virtual machine under ESXI is 'independent' (http://www.vmware.com/virtualization/virtual-machine.html)

    This means that each virtual computer must have its own copy of the application.

    This perspective reflection of each virtual machine as a separate system of 'physical '. They interact with each other as if they were physical systems.

    Each VMDK resembles a physical hard disk. Being accessible (in most configurations) 1 VM at a time.

    So if you had a set of physical systems connected to a domain and I wanted to install an application on each one, then each would have its own local copy of the application. It's the same thing with virtual machines.

    However

    If you configure a set of physical machines so that you run the software from a network share. It is possible to do the same thing using virtual machines using the exactly the same configuration. However, the chiefs more associated to this are important in both cases.

    Concerning

    Cyclooctane

  • Which battery was the best for endurance for Satellite A100-999

    Hello

    I just received an A100-999 and I wanted to know which battery was the best for endurance.

    From what I've seen, it's the pa3400u-1brs but I wanted just confirmation that I intend to buy it at the Japan because it is probably cheaper.
    Also, is there any information on how long does the battery last?

    Thank you

    Hello

    This battery would be for your 100% machine. I have the same one in almost the same machine. Don t worry, just to buy it.

    Welcome them

  • Which method is the best transfer songs (in Garageband) of an old, beginning to a 2013 09 macbook pro?

    Which method is the best transfer songs (in Garageband) of an older, early 09 to a 2011 macbook pro?

    Presentation of the material:

    FOR a Macbook pro 15 beginning 2011, intel core i7 at 2 ghz, memory 4 GB OS X ElCapitan

    Model name: MacBook

    Model identifier: MacBook4, 1

    Processor name: Intel Core 2 Duo

    Processor speed: 2.1 GHz

    Number of processors: 1

    Total number of cores: 2

    L2 Cache: 3 MB

    Memory: 2 GB

    Bus speed: 800 MHz

    You have the same version of GarageBand on Mac?

    Otherwise, some sounds from the old version of GarageBand may be missing in the new Mac.

    But you can simply copy the GarageBand project on a thumb drive or an external drive with enough storage and copy them on.  Or use your network - put the songs in the Public folder on the old Mac and from there copy them to your music on the recent Mac folder.

  • I have two reqwork and mycleanpc, downloaded on my computer which 1 is the best 1 for me to keep

    I regwork and mycleanpc.com downloaded on my pc.i want to know between the two of them which 1 I should keep and which 1 should I uninstall.which 1 is the best 1 to keep.thank you

    Hello.

    The answer: NONE of them.

    Registry cleaners / tuneUp Utilities programs are a waste of time and money and can do more harm that any who they claim to be able to do.

    See you soon.

  • I'm looking for the best way and the best way to get a product key for my windows 7 Edition family.

    Hello.  I'm looking for the best way and the best way to get a product key for my windows 7 Edition family.  Thanks Bob

    Original title: product windows keys 7

    The cheapest option is the OEM System Builder for Windows 7 Home Premium license, but has some license restrictions:

    Amazon.com: Windows 7 Home Premium 64 - Bit System Builder...

    The OEM of Windows 7 versions are identical to the versions commercial full license with the following exception:

    -OEM versions don't offer any free direct support from Microsoft technical support Microsoft

    -OEM Licenses are tied to the computer first you install and activate it on

    -OEM versions allow all hardware upgrades except for an upgrade to a different model motherboard

    -OEM versions does not move directly from an older Windows operating system

    What is OEM software? :
    http://support.Microsoft.com/GP/oemsupport_1/en-GB

    Licensing FAQ:
    http://www.Microsoft.com/OEM/en/licensing/sblicensing/pages/licensing_faq.aspx

    OR

    A detail that does not have these restrictions:

    Where can I still get Windows 7?

    Full version - Microsoft Windows 7 Home Premium

    Version upgrade - Microsoft Windows 7 Home Premium Upgrade

    Family Pack: Upgrade of Microsoft Windows 7 Home Premium Family Pack (3 users)

  • The older of the camera, there was a scene or stage spot. What is the best replacement for this scene selection

    The older of the camera, there was a scene or stage spot.  What is the best replacement for this scene selection

    The best replacement for staging Spotlight is probably the Night Portrait setting.

  • No idea how to write this query

    Hi, My Data is as below

    DocNum doc_date type of amount
    1154 15 November 11 232501.5 invoice
    200206 4 November 11 - 243672.64 credit memo
    Note flow 111 5 November 555.22 11

    Output must be

    DocNum doc_date amount Type AmountDR AmountCR
    1154 232501.5 15 November 11 Bill 232501.5
    Note credit 200206 4 November 11 - 243672.64 - 243672.64
    Note flow 111 5 November 555.22 11 555.22

    If the amount is > 0, then it must be displayed in the value of the amount to be AmountDR
    If amount < 0 then it must be displayed in the value of the sum amount CR



    Can help how to write this query
    with sample_table as (
                          select 1154 Docnum,date '2011-11-15' doc_date,232501.5 Amount,'Invoice' type from dual union all
                          select 200206,date '2011-11-04',-243672.64,'Credit Memo' from dual union all
                          select 111,date '2011-11-05',555.22,'Debit Memo' from dual
                         )
    select  Docnum,
            doc_date,
            Amount,
            type,
            case
              when Amount >= 0 then Amount
            end AmountDR,
            case
              when Amount < 0 then Amount
            end AmountCR
      from  sample_table
    /
    
        DOCNUM DOC_DATE      AMOUNT TYPE          AMOUNTDR   AMOUNTCR
    ---------- --------- ---------- ----------- ---------- ----------
          1154 15-NOV-11   232501.5 Invoice       232501.5
        200206 04-NOV-11 -243672.64 Credit Memo            -243672.64
           111 05-NOV-11     555.22 Debit Memo      555.22
    
    SQL> 
    

    SY.

  • best way to write this query

    Hello

    I have a problem and I realized a simplified version of it:

     
    
    create table deals (id_prsn number, id_deal number, fragment number); 
    create table deal_values (id_prsn number, id_deal number, value_ number, date_ date); 
    
    insert into deals values(1,1,50); 
    insert into deals values(2,2,40); 
    insert into deals values(1,3,50); 
    insert into deals values(2,4,80); 
    insert into deals values(1,5,20); 
    insert into deals values(2,6,80); 
    
    insert into deal_values values(1,1,10 ,sysdate - 3); 
    insert into deal_values values(2,2,208, sysdate - 3); 
    insert into deal_values values(2,4,984, sysdate - 3); 
    insert into deal_values values(1,null,134,sysdate - 3); 
    insert into deal_values values(1,1,13, sysdate - 2); 
    insert into deal_values values(2,2,118, sysdate - 2); 
    insert into deal_values values(2,4,776, sysdate - 1); 
    insert into deal_values values(1,null,205,sysdate - 1); 
    insert into deal_values values(2,null,-5,sysdate - 1); 
    The id of the requirement to join these two tables based on:

    1.) ID_PRSN and ID_DEAL
    2.) max DATE_ grouped per person and deal
    (3.) in the case that ID_DEAL is defined in the AGREEMENTS, but not defined in the DEAL_VALUES table, I have to join this records to DEAL_VALUES based on the person where id_Deal is null.

    Number 3 gives me headache. I realized the following query:
     
    
    select *from ( 
    select a.id_prsn, 
           a.id_deal, 
           a.fragment, 
           b.value_, 
           b.date_, 
           max(b.date_) over (partition by b.id_prsn, b.id_deal) max_date 
      from deals a 
    inner join deal_values b 
        on a.id_deal = b.id_deal or b.id_deal is null 
       and not exists  (select 1 from deal_values 
                                  where id_prsn = a.id_prsn 
                                    and id_deal = a.id_deal) 
       and a.id_prsn = b.id_prsn 
    ) 
    where date_ = max_Date; 
    It returns the correct result of he,


    ID_PRSN ID_DEAL FRAGMENT VALUE_ DATE_ MAX_DATE
    1 1 50 13 16.10.2012 09:59:48 16.10.2012 09:59:48
    1 3 50 205 17.10.2012 09:59:48 17.10.2012 09:59:48 OK
    1 5 20 205 17.10.2012 09:59:48 17.10.2012 09:59:48 OK
    2 2 40 118 16.10.2012 09:59:48 16.10.2012 09:59:48
    2 4 80 776 17.10.2012 09:59:48 17.10.2012 09:59:48
    2 6 80-5 17.10.2012 09:59:48 17.10.2012 09:59:48 OK



    but the join clause:
     
    
    
        on a.id_deal = b.id_deal or b.id_deal is null 
       and not exists  (select 1 from deal_values 
                                  where id_prsn = a.id_prsn 
                                    and id_deal = a.id_deal) 
       and a.id_prsn = b.id_prsn 
    in fact the query much slower.

    I was wondering is there a different way to write this join and manage the logic.

    Thanks in advance

    Here's a different approach:

    select * from (
      select a.id_prsn, a.id_deal, a.fragment, B.value_, b.date_,
      ROW_NUMBER() over(
        partition by a.ID_PRSN, a.ID_DEAL
        order by B.ID_DEAL nulls last, B.DATE_ desc
      ) RN
      from DEALS a
      join DEAL_VALUES B
      on a.ID_PRSN = B.ID_PRSN and a.ID_DEAL = NVL(B.ID_DEAL, a.ID_DEAL)
    )
    where rn = 1
    order by 1, 2;
    

    "nulls last" is the default sort order; I just put that for clarity.

    Published by: stew Ashton on October 18, 2012 12:58

  • Is an array, the best solution for this problem?

    Hello

    I work a demo where a couple of small games come in a Panel. There is a main menu which you bounce around to select the things (games as well as other applications.)

    When one party runs, it takes up the entire jury. When two or more run, they run in a format "mini." In addition, when a game is running, a special 'return to the game' button in the main menu.

    It is a click by dog and pony, see the demo. It is not a production application, but it should work well enough to be played with internal clients. So it must work well.

    At this moment I have a few variables put in place as follows:

    var gameActive:Boolean = false;
    var gameDual:Boolean = false;

    In the launch menu and my game function, I check these (and one or two others) variables to see if I should do things like show a mini-version of the game or show return to the play button. I added many features, it becomes a bit difficult to handle.

    At stake is the games. Let's say that I only have two. I could make a table and then load in the name of the game, when a game is started. I could check this table in my functions to see not only if the games is launched, but the game is launched so I can use the full or mini games as the case may be.

    Is this a good approach, or is there a better way? I'm rusty with my code and not super comfortable, making things right now. But I could go on like this if it was the best.

    There's not much to it.  This is the only 3 things that you are likely to need to do with your associative array:

    var yourAA:Object = {};

    function addAAItem (aa:Object, o: DisplayObject) {}

    AA [o.Name] = o;

    }

    function removeAAItem (aa:Object, {o: DisplayObject}

    AA [o.Name] = null;

    }

    function aaLength(aa:Object):int {}

    var i: int = 0;

    for (var s:String in aa) {}

    i ++ ;

    }

    Return i;

    }

  • Aspire v3 - 772 g nvidia gtx 760 m. who are the best drivers for this graphics card?

    I have used so many drivers for this graphics card... some of them drop fps, others are late or whatever... I would like to know which are the best drivers to use? SRY for my English. Thank you

    Click the help button at the top of this page. Choose your country. Click on drivers and manuals. Click on laptop aspire v3 - 772 g. Choose Win8 or Win8.1. Nvidia VGA drivers listed are recommended.

    Jack E/NJ

  • How can you fix error code 57F so microsoft updates can be downloaded? What is the best solution to this problem?

    57F error code

    Windows Update Forum:

    It comes with Vista, upgrade install and activate Forum.

    You will get the best help for any problem of Update/Service Pack in the Windows Update Forum; the link below:

    http://social.answers.Microsoft.com/forums/en-us/vistawu/threads

    When you repost here, kindly include the Error Codes, and exactly what is happening when you try to update.

    In this way, you will receive the best help.

    See you soon.

    Mick Murphy - Microsoft partner

  • File server Windows 2012, which version is the best?

    Hi guys

    I have to put in place a new file server 2012 which will be about 1 TB local storage and about 5 TB of storage which will be connected via iscsi, my question is will be a normal server standard edition 2012 with the role of server file you added the best solution or I have to look the edition of standard windows 2012 storage?

    Great, much appreciate if someone could clarify which of these options would be best?

    Thank you

    Clint

    This issue is beyond the scope of this site (for consumers) and to be sure, you get the best (and fastest) reply, we have to ask either on Technet (for IT Pro) or MSDN (for developers)
    *

Maybe you are looking for

  • After updating flash player youtube 11.4 will not play videos

    Videos that won't play, work on other browsers like IE and Chrome so I guess it's a matter of Firefox I tried to reinstall again and again the flashplayer, I even tried rolling back to 11.3 but youtube still doesn't work in the videos it shows an err

  • iPhone Bluetooth SE delivers

    I have a new iPhone SE and have so far combined with a 2014 BMW 328i and a 2011 Kia Optima and a Kia 2015 Santa Fe. In any case, I have terrible quality bluetooth call front desk... the audio during a phone call is very scratchy and distorted. If I p

  • How to turn on Atheros without keys FN on Satellite A210 (WIN XP)?

    Hello I had to downgrade to Windows XP Home edition because of the need to work.Everything works well, but for the WiFi connection: I think the case is that the Atheros is disabled by default and I should pass it on by pressing FN + F8. But the funct

  • shoot-syringe - KD scientific Legato 210

    Hello I have problems using my computer to connect and communicate with the 210 KDS Syringe Pump legato. I found this link of national instruments: http://sine.NI.com/apps/UTF8/niid_web_display.model_page?p_model_id=16884 but I failed to do the commu

  • I NEED TO CREATE CODE LIKE JKI

    Hi all I like to create the plugin like this jki state machine to block. How to create my own Vi block like that.