Select * v/s select specific in oracle

Dear Friends please proivde your valuable opinions:
how does oracle behaves internally in case when all records are selected (select * from X) and in case when few records ( select A, B from X) selected.
I had a discussion with my DBA DBA says even if you select specific column oracle internally selects the whole row (all columns) and then selects specific columns out of it.
Being an application developer I believe that specific column selection is fast and oracle should not be selecting all columns internally.
Arpit Bansal

Aside from the fact that selecting a particular column list is a heck of a lot safer, since it doesn't break when new columns are added to a table, selecting a subset of the columns may be more efficient, particularly if it reduces the amount of data that needs to be sorted or hashed or if it allows all the data to be fetched from an index. If Oracle has to read data from the table itself, it will generally have to read the entire row into the buffer cache (overflow segments in an IOT being the biggest exception I can think of).
Justin
Added clarification about queries that can be satisfied exclusively via indexes.
Message was edited by:
Justin Cave

Similar Messages

  • HT1848 how do you transfer selected purchases (i.e. specific songs, not everything)  from iPad to your Mac?

    how do you transfer selected purchases (i.e. specific songs, not everything)  from iPad to your Mac?

    See your duplicate post : https://discussions.apple.com/message/21574694#21574694

  • Why do i get integer values instead of decimals when selecting a mysql table through an oracle xe DB?

    Hi
    My company just started a new project that implies migrating every hour operational data from a mysql database located at another company to our main DB (oracle10gR2). Between these two DB, we have an oracle XE DB which contains the database links to both DB and a procedure to get (from mysql) and insert (oracle10g) the values. What happens is that in the mysql DB, the values have decimals and, when i select the table in oracle, i only see integer values (no decimals). Here is an example of the select i use:
    SELECT "v_hour", "v_date", "v_type", "v_tabstamp","v_value"
    FROM "tab1"@mysql;
    How can i work around this problem?
    Many thanks!

    Maybe just a HS_LANGUAGE setting issue.
    You could try that:
    1a) in the gateway init file, please set HS_LANGUAGE=GERMAN_GERMANY.WE8ISO8859P1
    2a) now open a new SQL*Plus session ans select from your table using the gateway based database link
    => if the values are now including the decimal part then your foreign database is set up to use a comma as the decimal separator and you have to make sure that the HS_LANGUAGE contains a territory that uses as decimal separator a comma.
    If you still do not get the decimal values, then change it to:
    1b) HS_LANGUAGE=american_america.we8iso8859P1
    2b) Make sure you start again a new SQL*Plus session (the gateway init file is only read when you use the database link in your session for the first time (or explicit closed it before). Select again from your table.
    => is the decimal part now visible?
    More details can be found in the gateway note: Gateway and Decimal Digits(Doc ID 1453148.1) available from My Oracle Support portal.
    - Klaus

  • A very slow select with sub selects sql statement on Oracle

    Hi,
    I'm moving an application from MySql to Oracle. The following select were very efficiently executed in MySql. In oracle its slow like a snail.
    Do anyone have a hint on how to speed it up?
    The slow part is the four sub selects in the select part. Removing them makes the select about 50 times faster on Oracle.
    Best Regards,
    Stephane
    select
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and (rr.relation_type_id = 'link' OR rr.relation_type_id = 'product')) as relationList,
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and rr.relation_type_id = 'number') as relationNumber,
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and rr.relation_type_id = 'title') as relationTitle,
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and rr.relation_type_id = 'content') as relationText,
    d.*
    from document d,(
    select distinct r.document_id id
    from relation r
    where
    r.product_id = ?
    ) dd
    where d.id=dd.id

    You are accessing the relation-table too many times, so a rewrite to a query like this
    SQL> select dept.deptno
      2       , dept.dname
      3       , count(decode(job,'CLERK',1)) clerk
      4       , count(decode(job,'MANAGER',1)) manager
      5       , count(decode(job,'SALESMAN',1)) salesman
      6    from dept, emp
      7   where dept.deptno = emp.deptno (+)
      8   group by dept.deptno
      9       , dept.dname
    10  /
        DEPTNO DNAME               CLERK    MANAGER   SALESMAN
            10 ACCOUNTING              1          1          0
            20 RESEARCH                2          1          0
            30 SALES                   1          1          4
            40 OPERATIONS              0          0          0
    4 rijen zijn geselecteerd.will be worth the effort.
    If still not satisfied, you have to do some investigation, as described [url http://forums.oracle.com/forums/thread.jspa?threadID=501834&tstart=0]here
    Regards,
    Rob.

  • Selecting the first n rows with Oracle

    Please help,I am very confused with this.
    For example,lets take a table called "items" which has
    ID    NAME    PRICE
    1    cup              1.2
    2    book         49.99
    3    mobile        89.99
    20    bike        1250
    19    egg            0.8
    18    bun           2.5
    17    color          2.22
    16    tv             310
    15    air            0
    14    laptop         999.5
    13    pack         21.53
    12    cd/r           1.2
    11    table         198
    10    apple         1.05
    9    carpet         122.4
    8    oracle         19999
    7    door           150
    6    dollar         1
    5    pencil        1.35
    Next,say, we want to retrieve the five cheapest items.
    select name, price
    from items
    where rownum < 6
    order by price;
    NAME                      PRICE
    coke                        .78
    cup                         1.2
    pencil                     1.35
    book                      49.99
    mobile                    89.99
    This is wrong. In the result set above, the item with id no 19 (egg) is missing which only  costs 0.80 (currency units). We get this because
    Oracle first retrieves the first five  rows and then orders them by price. This is because of the fact  that we didn't explicitly enough state what we meant with first.
    This problem can be solved by using row_number with a option--->below
    select name, price
    from (
    _*select name, price, row_number() over (order by price) r*_
    _*from items*_
    where r between 1 and 5;
    NAME                      PRICE
    air                           0
    coke                        .78
    egg                          .8
    dollar                        1
    apple                      1.05
    **Question is in the above select if i ADD the clause "WHERE rownum <= 6"---The above result set goes wrong again.I dont get the correct order as above.
    Please help.Can we have the order by done first and then take 5 records of them.
    select name, price
      from (
        select name, price, row_number() over (order by price) r
          *from items WHERE rownum <= 6*
    where r between 1 and 5

    wrote:user_7000011
    Thanks.
    *But, what i wanted is  in the inner most select where we select from item --I need to add a where qualification as below.*
    select * from
    (select name, price, dense_rank() over (ORDER by price desc ) rank from item where rownum &lt;=6
    ) a
    where a.rank&lt;6
    Well, the rank limitation is having the same effect in that query, so there's no need to try and put "rownum &lt;=6" in that case.What you need to understand is that "rownum" is a pseudo column that is generated when the results of a query are already determined, but it is applied before any ordering takes place (as the where clause is evaluated before the order by clause).
    So if you try and say "where rownum &lt;= 6 order by x", you are under the misunderstanding that it will order the data first and then take the first 6 rows. This isn't the case. It will take the first 6 rows (whatever they may be) and then order those.
    In order to order first and then take 6 rows you have to order your data without restriction and then wrap that in a query to restrict it.
    Hence...
    select x
    from tableX
    where rownum &lt;= 6
    order by xbecomes
    select x
    from (select x
          from   tableX
          order by x)
    where rownum &lt;= 6This ensures that the data is selected and ordered first and then the first 6 rows are taken from that.

  • Bug report select statement nested select in FROM Clause on Oracle 10g

    The SELECT statement below does not return the appropriate result; it used to work on Oracle 8, but it does not on 10g (10.2).
    Here is the table
    create table T (
    A numeric(4),
    B numeric(4)
    Some data
    insert into T (A,B) VALUES (1,null);
    insert into T (A,B) VALUES (2,1);
    insert into T (A,B) VALUES (3,1);
    insert into T (A,B) VALUES (3,2);
    The select statement returning the worng result
    select totals.A, totals.totalBbyA
    from (
    select t1.A, sum(t1.B) totalBbyA
    from T t1
    group by A
    ) totals
    where
    totals.totalBbyA >= all
    select sum(nvl(t2.b,0)) from T t2 group by t2.a
    it returns "no rows selected"
    An equivalent select that does return the good result
    select t1.A, sum(t1.B) totalBbyA
    from T t1
    group by A
    having
    sum(t1.B) >= all
    select sum(nvl(t2.b,0)) from T t2 group by t2.a
    It returns
    A TOTALBBYA
    3 3
    Best regards

    910893 wrote:
    but it does not on 10g (10.2).Works fine in:
    SQL> select  *
      2    from  v$version
      3  /
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> select  *
      2    from  t
      3  /
             A          B
             1
             2          1
             3          1
             3          2
    SQL> select totals.A, totals.totalBbyA
      2  from (
      3  select t1.A, sum(t1.B) totalBbyA
      4  from T t1
      5  group by A
      6  ) totals
      7  where
      8  totals.totalBbyA >= all
      9  (
    10  select sum(nvl(t2.b,0)) from T t2 group by t2.a
    11  )
    12  ;
             A  TOTALBBYA
             3          3
    SQL> SY.

  • "select count(*)" and "select single *" returns different result

    Good day!
    product version SAP ECC 6.0
    oracle10
    data transfers from external oracle db into customer tables using direct oracle db link
    sometimes I get case with different results from 2 statements
    *mytable has 10 rows
    *1st statement
    data: cnt type I value 0.
    select count( * ) into cnt from mytable WHERE myfield_0 = 123 and myfield_1 = '123'.
    *cnt returns 10 - correct
    *2nd statement
    select single * from  mytable WHERE myfield_0 = 123 and myfield_1 = '123'.
    *sy-dbcnt returns 0
    *sy-subrc returns 4 - incorrect, 10 rows are "invisible"
    but
    1. se16 shows correct row number
    2. I update just one row from "invisible" rows using se16 and 2nd statement returns correct result after that
    can not understand why
    thank you in advance.

    Thank you, Vishal
    but,
    general problem is that
    1. both statements have the same WHERE conditions
    2. 1st return resultset with data (sy-dbcnt=10), 2nd return empty dataset, but must return 1 in sy-dbcnt
    Yes, different meaning, you are right, but must 2nd must return 1, because of "select single *" construction, not 0.
    Dataset to process is the same, WHERE conditions are equal...
    I think the problem is that how ABAP interperets select count(*) and "select single *".
    Maybe "select count (*)" scans only PK from index page(s)? and "select single *" scans data pages? and something is wrong with that?
    I'm new in SAP and didn't find any SAP tool to trace dump of data and indexes pages with Native SQL.
    se16 shows all records.
    And why after simple manual update of just one record using se16 "select single *" returns 1?
    I've just marked one row to update, didn't change any data, then pressed "save".

  • Adhoc Query : Error during selection; check the selection conditions

    Hi
    We have a report set-up and which we want to run using our adhoc query report tcode S_PH0_48000513
    The report, has a few different selection criteria in it to look at all action IT screen data in the system for ee's in specific personnel areas. There is also a criteria to allow us to paste in specific employee numbers we are interested in. The issue I am facing is that over about 3000 ids, the system automatically returns me a message when I click on the Output button to run the report which states:
    Error during selection; check the selection conditions
    Message no. PAIS206
    I am not sure why this is happening. The selection criteria are fine and the other day I ran the report and I experienced no issues. The report ran successfully. Now though, if I try and paste in all the ids I am interested in (about 8000) I get this message straightaway.
    Can anything be done to overcome this issue?
    Any advice would be much appreciated.
    Nicola

    Hi
    The message in full is:
    Error during selection; check the selection conditions
    Message no. PAIS206
    Diagnosis
    A runtime error occurred during dynamic selection.
    System response
    The runtime error will be caught; no short dump will be created. This error should not occur as a rule. However, very large select statements may trigger the runtime error SAPSQL_STMNT_TOO_LARGE or DBIF_RSQL_INVALID_RSQL. There is no way to prevent this happening. In this case, the error can only be caught.
    Procedure
    Check the selection conditions to see whether the error was caused because the option "Import from text file" included too many objects in the "Multiple selection" dialog. If this is so, you must limit the number of individual values.

  • Using ORDER BY for column that's not in SELECT statement of select list?

    Hi all.
    I have a select list on an APEX page at apex.oracle.com, and I would like to order this by the value of column UnitOrder.
    The SQL is as follows:
    SELECT DISTINCT foodunit.name AS display_value, foodunit.foodunitid AS return_value
    FROM foodunit, food
    WHERE foodunit.foodid = :P18_FOODID
    ORDER BY foodunit.unitorder ASC;Off course, this code won't work. And since it's a select list, I can't just add foodunit.unitorder to the SELECT statement. Also, I can't get rid of the DISTINCT, because then for some reason it tends to display an infinite amount of the same row...
    The point of ordering it by UnitOrder is that all units who begin with gram, ml, mg, kg,... etc, will be shown on top of the select list. All other food units will be shown on the second place and so on.
    The column UnitOrder holds either 1 or 2 as a value. 1 is the value for all rows that should be displayed at the top of the select list, 2 is the value for all the rest.
    So, what I want is that all rows in which the UnitOrder is 1, get displayed on top of the select list. Usually only 2 list items get shown in the select list at a time, depening on which food item a user has selected. The select list then refines to certain rows that match the foodid etc etc..
    If anyone has an idea, I'd be very happy to hear about it.

    Thanks! I didn't think about using a join. Code works now, and is as follows:
    SELECT foodunit.name AS display_value, foodunit.foodunitid AS return_value
    FROM foodunit
    INNER JOIN food
    ON food.foodid = foodunit.foodid 
    WHERE foodunit.foodid = :P18_FOODID
    ORDER BY foodunit.unitorder ASC;

  • Select all / Delete selection Translation

    Hi,
    although I am running my Web Dynpro ABAP in Swedish the "Select all / Delete selection" table options are displayed in English. Anyone who knows whether or not this is a bug or a known limitation ... or perhaps something that I can fix?
    Thanks!

    Hi Peter,
    I still do not understand why all the other standard functionalities are translated but not "Select all/Delete selection". Could you be a little more specific how/what you mean with domain translation?
    Thanks!

  • Refresh classic report based on select list value selected

    hello,
    can anyone please help me out with this issue. I have a parameterized classic report based on a select list and I want to refresh this report whenever the select list value is changed. I am using oracle apex version 3.2. i just want to have a javascript function onchange event for the select list which refreshes my report whenever a value is selected.
    My select list item is p1_datastore
    select distinct datastore d,datastore r from my_table1 order by 1;
    My classic report query is
    select * from my_table2 where datastore = :p1_datastore order by last_updated_dt desc;
    ****************************************************thanks,
    orton

    can anyone please help me out with this issue.
    thanks,
    orton

  • Send E-mail of selected databases to selected Mail profiles

    Hi All,
    I want to send e-mails to selected users from selected databases and hosts in Oracle Enterprise Manager 11g?
    How do i configure this issue?
    Regards,
    Edited by: user5199319 on Jun 21, 2012 6:43 AM

    Please follow the doc
    http://docs.oracle.com/cd/E11857_01/em.111/e16790/notification.htm#BABJFFCJ

  • [JPA] SELECT NEW inside SELECT NEW in Named Query

    Suppose i have two JPA entities Master and Detail as follows:
    @Entity
    public class Master implements Serializable{
        private static final long serialVersionUID = 1L;
        private long id;
        private String masterField1;
        private String masterField2;
        private String masterField3;
         private String masterField4;
        private String masterField5;   
        //A lot of other fields till masterFieldn...
        private String masterFieldn;
        private List<Detail> detailList;
        //getters and setters here...
        @OneToMany(mappedBy = "master", cascade = { CascadeType.ALL }, fetch=FetchType.EAGER)
        @OrderBy("detailField1 DESC")
        public List<Detail> getDetailList() {
            return detailList;
    @Entity
    public class Detail implements Serializable{
        private static final long serialVersionUID = 1L;
        private long id;
        private String detailField1;
        private String detailField2;
        private String detailField3;
         private String detailField4;
        private String detailField5;   
        //A lot of other fields till detailFieldn...
        private String detailFieldn;
        private Master master;
        //getters and setters here...
        @ManyToOne
        @JoinColumn(name="MASTER_ID", referencedColumnName="ID")    public Master getMaster() {
            return master;
        }Both Master and Detail entities have a lot of fields, but i only need a subset of those fields when these entities are queried. So, i have two helper classes which i use in named queries in Master JPA entity :
    @NamedQueries({
            @NamedQuery(name = "Master.findMaster",
                query = "SELECT NEW MasterHelper(" +
                    "t.masterField1, t.masterField2, t.masterField3, " +
                    " SELECT NEW DetailHelper(" +
                    "td.detailField1, td.detailField2, td.detailField3 FROM Detail td WHERE " +
                    " td.master.id = t.id)) FROM Master t WHERE t.id = ?1")MasterHelper and DetailHelper have only the fields i want to query, getters and setters, and a constructor matching the SELECT NEW.. in @NamedQuery :
    public class MasterHelper implements java.io.Serializable {
        private String field1;
        private String field2;
        private String field3;
        private <DetailHelper> detailList;
        //Constructor matching SELECT NEW
        public MasterHelper(String field1, String field2, String Field3, List detailList) {
           this.field1 = field1;
            this.field2 = field2;
            this.field3 = field3;
            this.detailList = detailList;
         //getters and setters
    public class DetailHelper implements java.io.Serializable {
        private String field1;
        private String field2;
        private String field3;
        //Constructor matching SELECT NEW
        public DetailHelper(String field1, String field2, String Field3) {
           this.field1 = field1;
            this.field2 = field2;
            this.field3 = field3;
         //getters and setters
    }So, basically when i query for a particular Master entity, what i want in return is a List of MasterHelper objects with just the fields i want; each MasterHelper object must include a list of MasterDetail objects, again with just the fields i want.
    When the above named query is executed by Toplink Essentials against an Oracle database, i get the following exception regarding the "second" SELECT NEW:
    EJBQLException
    Exception Description: Syntax error parsing the query [SELECT NEW
    ...unexpected token [SELECT]
    ...How can i achieve what i want? Doesn't JPA allows SELECT NEW inside SELECT NEW in named queries?
    Thanks in advance for any help.
    Edited by: savas_karabuz on May 16, 2008 3:59 AM
    Edited by: savas_karabuz on May 16, 2008 4:02 AM

    Hello,
    The build you are using is an older one, and there have been a few enhancements done for constructor expressions support (for instance
    https://glassfish.dev.java.net/issues/show_bug.cgi?id=1421)
    but an enhancement to allow constant values is still open: https://glassfish.dev.java.net/issues/show_bug.cgi?id=2452
    Best Regards,
    Chris

  • Diff b/w select endselect and select into table............

    what is the difference b/w
    Select
    Endselect
    and select into table....
    Akshitha..

    Hi,
      When ever u want to append data into the workarea then use select ... endselect. When u r appending data into the internal table then use select. Also when u use select single then also use only select.
    Eg: Using only Select
    data : begin of itab occurs 0,
    lifnr like lfa1-lifnr,
    end of itab.
    select single lifnr from lfa1 into itab.
    data itab like lfa1 occurs 0 with header line.
    select * from lfa1 into table itab.
    Eg: Using Select .. endselect.
    data : itab like lfa1 occurs 0,
    wa like lfa1.
    select * from lfa1 into wa.
    append wa to itab.
    endselect.
    Regards

  • The salesperson for my iphone 4 said on Christmas morning we could go to our online account, select my number, select to change my SIM card, and enter the ICCID number so that I'd be able to use my iphone 4 today. I have not seen any such steps. Help?

    The salesperson for my iphone 4 said on Christmas morning we could go to our online account, select my number, select to change my SIM card, and enter the ICCID number so that I'd be able to use my iphone 4 today instead of my old phone (not an iphone). I have not seen any such steps. Help?

    I suspect the salesperson that told you that meant your online account with your carrier...have you tried logging into your carrier account online? To do this will require the sim number on your sim card, as well as the phone's IMEI number...you get the sim number off the sim card & the IMEI number, for the phone, is printed on the box.

Maybe you are looking for