Any difference between distinct and aggregate function in sql query cost???

Hi,
I have executed many sql stmts patterns- such as:
a) using a single table
b) using two tables, using simple joins or outer joins
but i have not noticed any difference in sql stmts in cost and in execution plan....
Anyway, my colleague insists on that using aggregate function is less costly compared to
distinct....(something i have not confirmed, that's why i beleive that they are exactly the same...)
For the above reffered 1st sql pattern.. we could for example use
select distinct deptno
from emp
select count(*), deptno
from emp
group by deptno select distinct owner, object_type from all_objects
select count(*), owner, object_type from all_objects
group by owner, object_typeHave you found any difference between the two ever...????
Note: I use Ora DB 10g v2.
Thank you,
Sim

distinct and aggregate function are for different uses and may give same result but if u r using aggregate function to get distinct records, it will be expensive...
ex
select distinct deptno from scott.dept;
Statistics
0 recursive calls
0 db block gets
2 consistent gets
0 physical reads
0 redo size
584 bytes sent via SQL*Net to client
488 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
4 rows processed
select deptno from scott.emp group by deptno;
Statistics
307 recursive calls
0 db block gets
60 consistent gets
6 physical reads
0 redo size
576 bytes sent via SQL*Net to client
488 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
6 sorts (memory)
0 sorts (disk)
3 rows processed
Nimish Garg
Software Developer
*(Oracle & ASP.NET)*
Indiamart Intermesh Limited, Noida
To Get Free Oracle & ASP.NET Code Snippets
Follow: http://nimishgarg.blogspot.com

Similar Messages

  • Difference between Generic and Generating functions

    Hi,
    Can any body explain me the difference between Generic and Generating functions? Do also let me kwno which Standard functions are Genereic and which are Generating/
    Regards,
    Pranshu

    Hi Pranshu,
    All functions (regardless of whether they are standard or user-defined functions) that do not have input values are refered to as Generating Functions (Constant, Sender, Receiver and CopyValue() are generating functions). All other functions are generic.
    So, the standard XI functions can be generic or generating.
    Hope this helps
    Regards
    Kiran..

  • Is there any differences between black and white ipod touch ?? only the color or there are hardware differences?

    is there any differences between black and white ipod touch ?? only the color or there are hardware differences?

    You're welcome.
    What?
    Sorry, but no. The parts are identical with the only difference being a white housing or a black housing.

  • Is there any difference between 10g and 11g M Views?

    Hi,
    I need to give a demo on and working examples of materialized views. The requirement is this: Master tables are in a 10g R2 DB, MV is in a 11g.
    I just create a DB Link in 11g to point to the 10g DB and then create the MV in 11g.
    Will there be any problems creating a 11g MV using 10 Master tables?
    My question is are there any significant differences between 10g and 11g MViews??
    Thanks & Regards,
    Channa.

    You have to be careful about your versions. 10g could be 10.1 or 10.2 11g could be 11.1 or 11.2
    I wouldn't have an 11.2 database with a database link against a 10.1 database.
    In fact, even with 10.2, I would try to ensure that I have a "high patchset" (10.2.0.4 or 10.2.0.5) although, in theory, 10.2.0.1 should also work.
    See Oracle Support article
    Client / Server / Interoperability Support Between Different Oracle Versions [ID 207303.1]
    Hemant K Chitale

  • Is there any difference between iPhotobooks and Aperturebooks

    Hello,
    Can someone tell me if there is any difference in paperquality and covermaterials between iPhotobooks and books via Aperture.
    I did receive my first iPhotobook: it looks good in printing and coulor, but the paper is a bit thin(cheap look). It feels the same as the paper in the books of our warehouse. Apart from the design options will the quality be better if I print it vias Aperture?
    Thanks for any comment
    Suzanne

    No, there is no difference. Instance name is the same as SID.

  • Any difference between new and old wireless Mighty Mouse?

    Hello,
    I got an "old" wireless Mighty Mouse (the one with the grey side buttons) from my father. Now I am wondering if there is any difference between this mouse and the new one, besides the color change of the side buttons. I checked my mouse against the tech specs on the Apple Mighty Mouse site, and they seem to be absolutely identical, but still, I would like to hear this from an expert, which I hope to find here . Also, does anyone know where to find the user’s guide for the wireless mouse online? I have been searching the whole Apple site, but found it nowhere.
    Thanks in advance for your answers.

    Hi,
    This question is already discussed in sdn earlier.
    The follwoing thread give u complete details abt new GL & old GL :
    Re: Old & New GL, Balance Sheet and P&L Reports
    Regards
    Ram.

  • Are there any differences between black and white?

    Hi, this is the question:
    Are there any differences between a black and a white macbook (2,0 Ghz) except the coulor? I am thinking about buying a macbook but i dont know really what to do
    Coul someone help me plz?

    This page explains the differences between the two white macbooks and the black mac book: http://store.apple.com/1-800-MY-APPLE/WebObjects/AppleStore.woa/wo/0.RSLID?mco=A 4791B5D&nclm=MacBook
    It should answer any questions you have about all three.
    The lowest price macbook has a less fast processor, and the same size hard drive as the middle priced macbook. The lowest priced one also does not have a DVD burner while the middle priced white one does and the black one.
    The black macbook has a bigger harddrive then the middle priced macbook and thats about all thats different between the middle priced white one and the black one.

  • What is the difference between "= NULL" and "IS NULL" in SQL?

    Hi,
    I believe there is a difference between "= NULL" and "IS NULL" comparsion, but I couldn't find it. Anyone knows the difference?
    Thanks,
    Denny

    Aha, thanks:
    SQL> create table william_test_tab (col binary_double);
    Table created.
    SQL> insert into william_test_tab
      2  select rownum / (rownum - 1) from user_tables where rownum < 4;
    select rownum / (rownum - 1) from user_tables where rownum < 4
    ERROR at line 2:
    ORA-01476: divisor is equal to zero
    SQL> insert into william_test_tab
      2  select 1d * rownum / (rownum - 1) from user_tables where rownum < 4;
    3 rows created.
    SQL> select * from william_test_tab;
           COL
           Inf
      2.0E+000
      1.5E+000
    3 rows selected.
    SQL> select * from william_test_tab where col is infinite;
           COL
           Inf
    1 row selected.
    SQL>

  • Any difference between 16 and 32GB model other than capacity?

    Hi,
    I've just had my 16GB iPhone 4 stolen, and it's not looking like I'm going to be able to get it back. So I'm going to have to dig deep and buy a new one. But I'd want an upgrade at the same time, to allow me to better cope with the loss. So I'm thinking about the 32GB model (also, i was pushed for space with the 16GB).
    Is there any difference; Battery life, weight, speed, etc between the 16 and 32GB models? Beyond the obvious larger capacity?
    As most will know, bigger hard drives are faster, mainly due to higher areal density, but I don't know how/if this applies to solid state storage. I thought possibly it might use more battery life and be slightly faster.
    Thanks.

    No difference except for storage capacity.

  • Any difference between Java and Javaw, thanks

    I can launch my program with java successfully. But on the same setting, javaw failed. WHY?
    Thanks

    the only difference between java.exe and javaw.exe is that javaw.exe does no (system) output.
    see http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html
    "The javaw command is identical to java, except that with javaw there is no associated console window. Use javaw when you don't want a command prompt window to appear. The javaw launcher will, however, display a dialog box with error information if a launch fails for some reason. "

  • Any difference between "save" and "Save..." ?

    Hi there, does anyone knows the diffenrence between "save" and "Save..." ?
    To me it seems to opne the same dialog.
    Thanks for answering,
    Andrea

    Where are you seeing this?  Can you post a screen shot?

  • Difference between  aggregation and calculation tab in BEx Query Designer

    HI,
    I am using BEx Query Designer for my report, for the key figures in the coloumn area i slected one numeric key figures, in  the properties tab i found aggregation tab and calculation tab.
    I need to sum up the total values for that particualar coloumn, when i used calculation tab i found to sum all the values for a particular coloumn, then what is the use the aggreagation tab?
    I not able to used that Aggregation tab it is showing as a hidden fields...
    can any one tell me whats the exact difference between these tabs and when we need to use which tab?
    With Regards,
    Thanesh Kumar.

    Hi Thanesh Kumar,
    I moved this thread from forum Data Warehousing to Business Explorer since it is a query related question (as SDN moderator).
    I could explain to you the difference between these two tabs.
    For "calculation" tab, it changes the display of result and does not change the calculation logic.
    It means that, if this key figure is used further in formula, still the original number (without "calculation" tab setting)  is used for further formula calculation.
    For "aggregation" tab, it changes the real calculation logic.
    The system takes the setting as the aggregation rule for records.
    The most common aggregation rule is of course summation. If you set to e.g. Average here, the system does the
    Average instead of summation when aggregating records. And the Average value will be taken for calculation
    in further formulas or other calculations.
    For "aggregation" tab, you could only use it for CKF (calculated key figure) or formula and you could not use it for
    a basic key figure. That should be the reason why you see it greyed-out.
    Regards,
    Patricia

  • Difference between values in 2 rows in SQL query

    I have to find the difference between inventory onhand in the same store in week1 and week2.
    I tried to do it in one "select" query something like :
    SELECT store_id, ( suppose to be function that calculates difference) FROM my_table WHERE week=week1 or week=week2 GROUP BY store_id
    however I have no idea how to find the difference between the valuues in two separate rows.
    thanks in advance.

    If you have only two weeks in your data. This can work.
    SQL> select * from emp
      2  /
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7839 KING PRESIDENT 17-NOV-81 5000 10
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7788 SCOTT      ANALYST         7566 09-DEC-82       3000                    20
          7876 ADAMS CLERK 7788 12-JAN-83 1100 20
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
          8888 KING PRESIDENT 17-NOV-81 7000 10
          9999 ADAMS CLERK 7788 12-JAN-83 7000 20
    16 rows selected.
    SQL> select ename, max(sal) - min(sal) diff
      2  from emp
      3  group by ename
      4  /
    ENAME            DIFF
    ADAMS 5900
    ALLEN               0
    BLAKE               0
    CLARK               0
    FORD                0
    JAMES               0
    JONES               0
    KING 2000
    MARTIN              0
    MILLER              0
    SCOTT               0
    SMITH               0
    TURNER              0
    WARD                0
    14 rows selected.
    SQL> Cheers
    Sarma.

  • External monitor - any difference between 2ms and 5ms?

    Are there any significant differences?
    Would I only notice on super fast graphics?
    Should I be fussed in choosing between monitors that have either 2ms or 5ms?
    Thanks
    Omar

    Between 5ms and 2ms is not a lot of difference.
    Once you get that low on response times narrow your field by looking for a monitor with little input lag.
    Input lag won't affect image quality, but it can add a bit of latency to your games.

  • Innaugural demo: Is there any difference between 'GO' and 'Search'?

    I'm still poking around in this demo, and it looks to me like
    a) The Go and Search buttons do EXACTLY the same thing
    b) There are some old objects in there that are no longer used (OLD_SEARCH). I see two sets of code to generate results for pg. 2, but one is never called. I figured it would be called by one button or the other. Perhaps it was at one time?
    c) Where is the "search" button gif, if that's what it is? I am assuming "go.gif" is the blue "go" image. How is the yellow "search" button created?
    Thanks!

    Michael:
    a) You are correct, they do exactly the same thing. The Search button has been removed in the new application shipped with the next release.
    b) P0_OLD_SEARCH does not seem to be used any longer. It is referenced in a condition for firing a before header reset pagination process on page 2, but I can't find where this item is ever populated.
    Both query regions on page 2 are in fact used. If you choose a time interval, do not enter anything in the Search field, and click "Go" or "Search" you will see the other query region. Note that it does not have a "Score" column.
    c) There is no "Search" button gif. It is a template based button, while the "Go" button is an image button. Buttons can be either an Image (like the "Go" button), template based (like the "Search" button), or normal HTML buttons. To see the template for the "Search" button, Under Shared components on the page definition of page 0, click the link to the "Einstein Normal" in the Templates section next to button.

Maybe you are looking for

  • How to use Satellite M500-ST5401 for mobil calls using Bluetooth

    Team, I would like to know more details about bluetooth connectivity of a laptop to the bluetooth compatible mobile phones.My Model is Toshiba Satellite M500-ST5401. What i like to get to know is,I am having a mobile phone Sony Ericsson and it has bl

  • Is it possible to lock account Groups of customers

    Hi, ist it possible to lock account Groups of customers? I don't want to delete some groups, because there some customers with this groups i want to lock, but i will avoid that there are new customers with this groups. Regards, Dieter

  • Illustrator files from Bridge creates Clipping mask.

    I would like to use Bridge as a library for my Illustrator files. Only when I pressed shift key when dragging a illustrator file into my (illustrator) document, he translate my Artboard into a clipping mask. Does anyone have a solution? I'm working i

  • Access variable in MainTimeLine

    I have preloader that loads another swf, game.swf. // this code is in the preloader var appRoot="localhost"; // load game var request:URLRequest = new URLRequest("game.swf"); var _loader:Loader = new Loader();   _loader.contentLoaderInfo.addEventList

  • Insert character with umlaut/accent

    How do you insert a character with an accent or umlaut into Appleworks 6? This may seem like a basic question, but I can't find it in any of the drop-down menus or the 'help' section. I particularly need German characters, such as 'ö' and 'ß' (both o