Why a table full scan when I've got the PK in the WHERE clause?

There is a very complex query that I need to optimize in an Oracle 10gR2 environment. I am deconstructing it into layers to see what is causing the first bottleneck. The innermost portion is fine, with an explain plan cost of 54. With a typical value for the bind variable, it returns 125 zero_id values. There are over 100,000 rows in table T_ONE in my test database, but my customer has over one million rows in their production instance.
              WITH t_merged_id AS (SELECT DISTINCT zero_id FROM t_zero WHERE NVL(column2, zero_id) = :i_id)
              SELECT   t_one.one_id
                  FROM t_one
                      INNER JOIN t_two
                          ON t_one.column1 = t_two.two_id
                      INNER JOIN t_merged_id
                          ON t_two.column10 = t_merged_id.zero_id
              UNION ALL
              SELECT   t_one.one_id
                  FROM t_one
                      INNER JOIN t_two
                          ON t_one.column2 = t_two.two_id
                      INNER JOIN t_merged_id
                          ON t_two.column10 = t_merged_id.zero_id
              UNION ALL
              SELECT   t_one.one_id
                  FROM t_one
                      INNER JOIN t_three
                          ON t_one.column3 = t_three.three_id
                      INNER JOIN t_merged_id
                          ON t_three.column10 = t_merged_id.zero_id
              UNION ALL
              SELECT   t_one.one_id
                  FROM t_one
                      INNER JOIN t_four
                          ON t_one.column4 = t_four.four_id
                      INNER JOIN t_two
                          ON t_four.column1 = t_two.two_id
                      INNER JOIN t_merged_id
                          ON t_two.two_id = t_merged_id.zero_id
              UNION ALL
              SELECT   t_one.one_id
                  FROM t_one INNER JOIN t_merged_id ON t_one.column5 = t_merged_id.zero_id
              UNION
              SELECT   t_one.one_id
                  FROM t_one INNER JOIN t_merged_id ON t_one.column6 = t_merged_id.zero_idHowever, the next step is to obtain a bunch of columns from T_ONE for each of those ONE_ID values. Adding that looks like the following, which causes a table full scan on T_ONE (and an explain plan cost over 1,500 for this query in my test system) and it takes far too long to return the results.
SELECT   t_one.*
    FROM     t_one
         INNER JOIN
             (--This is the start of the query shown above
              WITH t_merged_id AS (SELECT DISTINCT zero_id FROM t_zero WHERE NVL(column2, zero_id) = :i_id)
              SELECT   t_one.one_id
                  FROM t_one
                      INNER JOIN t_two
                          ON t_one.column1 = t_two.two_id
                      INNER JOIN t_merged_id
                          ON t_two.column10 = t_merged_id.zero_id
              UNION ALL
              SELECT   t_one.one_id
                  FROM t_one
                      INNER JOIN t_two
                          ON t_one.column2 = t_two.two_id
                      INNER JOIN t_merged_id
                          ON t_two.column10 = t_merged_id.zero_id
              UNION ALL
              SELECT   t_one.one_id
                  FROM t_one
                      INNER JOIN t_three
                          ON t_one.column3 = t_three.three_id
                      INNER JOIN t_merged_id
                          ON t_three.column10 = t_merged_id.zero_id
              UNION ALL
              SELECT   t_one.one_id
                  FROM t_one
                      INNER JOIN t_four
                          ON t_one.column4 = t_four.four_id
                      INNER JOIN t_two
                          ON t_four.column1 = t_two.two_id
                      INNER JOIN t_merged_id
                          ON t_two.two_id = t_merged_id.zero_id
              UNION ALL
              SELECT   t_one.one_id
                  FROM t_one INNER JOIN t_merged_id ON t_one.column5 = t_merged_id.zero_id
              UNION
              SELECT   t_one.one_id
                  FROM t_one INNER JOIN t_merged_id ON t_one.column6 = t_merged_id.zero_id
               --This is the end of the query shown above
               ) t_list
         ON t_one.one_id = t_list.one_idMy question is, why wouldn’t Oracle use the existing index PK_T_ONE, which is keyed on T_ONE.ONE_ID? I tried refactoring the query using a “WHERE t_one.one_id IN” construct instead of the INNER JOIN but it didn’t make any difference. Neither did adding an index hint, which I hoped would force the use of the PK index.
Any ideas?

I was able to completely resolve my problem, but I still want to understand why the original query wouldn't use an index.
(My solution was to move all the joins and where clauses from the query that wrapped the one we've been discussing and put them into each SELECT in the UNION, so there is no longer any inner subquery. So instead of trying to first get a list of ID values from the subquery, get the full records for the IDs from an outer query, and then joining to the outer query, I made SELECT in the UNION contain the full logic. This makes the query a lot more verbose, because all the joins and wheres are repeated six times, but it does use the index and returns in 0.04 seconds instead of over nine minutes in my test database.)
hoek wrote:
Values for optimizer_index_caching and optimizer_index_cost_adj are not the defaults. Any reasons for that?I am not a DBA and have no idea. However, I did a Google search and found this: http://decipherinfosys.wordpress.com/2007/02/13/optimizer_index_cost_adj-and-optimizer_index_caching/. Apparently Tom Kyte would approve more of our settings than the defaults.
hoek wrote:
Any chance to get a realistic dataset on your test server?Unfortunately, not for quite some time. The customer won't provide any real data, and generating data for testing is complex because of all the interrelationships. I have someone working on that. However, I was able to get back on the primary test server that has 136k records in the main table instead of only 2k. So far as I know, the Oracle configuration between the test server and the customer's server is the same. However, they have much more serious hardware that I do (more processors, more RAM, more platters). On the other hand, they have 10 times as much data.
hoek wrote:
Your second execution plan contains differents stats, they're not the 'common ones'. (E-rows etc.)The predicates are the same as the first. The 2nd plan was generated by the 10g-specific portion of Randolph's script using the command "select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));".
This is the result from running the script on the main test server:
NAME                                 TYPE                             VALUE
_optimizer_cost_based_transformation string                           OFF
optimizer_dynamic_sampling           integer                          2
optimizer_features_enable            string                           10.2.0.4
optimizer_index_caching              integer                          95
optimizer_index_cost_adj             integer                          10
optimizer_mode                       string                           CHOOSE
optimizer_secure_view_merging        boolean                          TRUE
db_file_multiblock_read_count        integer                          32
db_block_size                        integer                          8192
cursor_sharing                       string                           FORCE
SNAME                PNAME                     PVAL1 PVAL2
SYSSTATS_INFO        STATUS                          COMPLETED
SYSSTATS_INFO        DSTART                          04-04-2008 07:02
SYSSTATS_INFO        DSTOP                           04-04-2008 07:02
SYSSTATS_INFO        FLAGS                         1
SYSSTATS_MAIN        CPUSPEEDNW            646.57331
SYSSTATS_MAIN        IOSEEKTIM                    10
SYSSTATS_MAIN        IOTFRSPEED                 4096
SYSSTATS_MAIN        SREADTIM
SYSSTATS_MAIN        MREADTIM
SYSSTATS_MAIN        CPUSPEED
SYSSTATS_MAIN        MBRC
SYSSTATS_MAIN        MAXTHR
SYSSTATS_MAIN        SLAVETHR
SQL> SELECT st.*
  2    FROM t_senttsk st INNER JOIN (WITH t_mrgdusr AS (SELECT DISTINCT usr_id
  3                                                       FROM t_usr
  4                                                      WHERE NVL(usr_mrgemstr, usr_id) = 10000002                    /* i_payer_id */
  5                                                                                                )
  6                                  SELECT t_senttsk.setk_id
  7                                    FROM t_senttsk INNER JOIN t_mrgdusr
  8                                             ON t_senttsk.setk_affn_memb = t_mrgdusr.usr_id
  9                                  UNION
10                                  SELECT t_senttsk.setk_id
11                                    FROM t_senttsk INNER JOIN t_mrgdusr
12                                             ON t_senttsk.setk_ownr = t_mrgdusr.usr_id) t_affil
13             ON st.setk_id = t_affil.setk_id;
no rows selected
Elapsed: 00:13:14.54
Execution Plan
Plan hash value: 1241660758
| Id  | Operation                         | Name                        | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT                  |                             |   169K|    64M|  1403   (3)| 00:00:17 |
|   1 |  NESTED LOOPS                     |                             |   169K|    64M|  1403   (3)| 00:00:17 |
|   2 |   TABLE ACCESS FULL               | T_SENTTSK                   |   136K|    51M|  1400   (3)| 00:00:17 |
|   3 |   VIEW                            |                             |     1 |     6 |     1   (0)| 00:00:01 |
|   4 |    TEMP TABLE TRANSFORMATION      |                             |       |       |            |          |
|   5 |     LOAD AS SELECT                |                             |       |       |            |          |
|   6 |      TABLE ACCESS BY INDEX ROWID  | T_USR                       |     1 |     8 |     1   (0)| 00:00:01 |
|*  7 |       INDEX RANGE SCAN            | IX_NVL_USR_MRGEMSTR_USR_ID  |     1 |       |     1   (0)| 00:00:01 |
|   8 |     SORT UNIQUE                   |                             |       |       |            |          |
|   9 |      UNION-ALL PARTITION          |                             |       |       |            |          |
|  10 |       NESTED LOOPS                |                             |     1 |    25 |     3   (0)| 00:00:01 |
|  11 |        TABLE ACCESS BY INDEX ROWID| T_SENTTSK                   |     1 |    12 |     1   (0)| 00:00:01 |
|* 12 |         INDEX UNIQUE SCAN         | PK_T_SENTTSK                |     1 |       |     1   (0)| 00:00:01 |
|* 13 |        VIEW                       |                             |     1 |    13 |     2   (0)| 00:00:01 |
|  14 |         TABLE ACCESS FULL         | SYS_TEMP_0FD9D6608_399116CE |     1 |     6 |     2   (0)| 00:00:01 |
|  15 |       NESTED LOOPS                |                             |     1 |    22 |     3   (0)| 00:00:01 |
|* 16 |        TABLE ACCESS BY INDEX ROWID| T_SENTTSK                   |     1 |     9 |     1   (0)| 00:00:01 |
|* 17 |         INDEX UNIQUE SCAN         | PK_T_SENTTSK                |     1 |       |     1   (0)| 00:00:01 |
|* 18 |        VIEW                       |                             |     1 |    13 |     2   (0)| 00:00:01 |
|  19 |         TABLE ACCESS FULL         | SYS_TEMP_0FD9D6608_399116CE |     1 |     6 |     2   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   7 - access(NVL("USR_MRGEMSTR","USR_ID")=10000002)
  12 - access("T_SENTTSK"."SETK_ID"="ST"."SETK_ID")
  13 - filter("T_SENTTSK"."SETK_AFFN_MEMB"="T_MRGDUSR"."USR_ID")
  16 - filter("T_SENTTSK"."SETK_OWNR" IS NOT NULL)
  17 - access("T_SENTTSK"."SETK_ID"="ST"."SETK_ID")
  18 - filter("T_SENTTSK"."SETK_OWNR"="T_MRGDUSR"."USR_ID")
Statistics
        349  recursive calls
     275041  db block gets
    1239881  consistent gets
         26  physical reads
   52730252  redo size
       3312  bytes sent via SQL*Net to client
        240  bytes received via SQL*Net from client
          1  SQL*Net roundtrips to/from client
     136835  sorts (memory)
          0  sorts (disk)
          0  rows processed
SQL> SELECT /*+ gather_plan_statistics */ st.*
  2    FROM t_senttsk st INNER JOIN (WITH t_mrgdusr AS (SELECT DISTINCT usr_id
  3                                                       FROM t_usr
  4                                                      WHERE NVL(usr_mrgemstr, usr_id) = 10000002                    /* i_payer_id */
  5                                                                                                )
  6                                  SELECT t_senttsk.setk_id
  7                                    FROM t_senttsk INNER JOIN t_mrgdusr
  8                                             ON t_senttsk.setk_affn_memb = t_mrgdusr.usr_id
  9                                  UNION
10                                  SELECT t_senttsk.setk_id
11                                    FROM t_senttsk INNER JOIN t_mrgdusr
12                                             ON t_senttsk.setk_ownr = t_mrgdusr.usr_id) t_affil
13             ON st.setk_id = t_affil.setk_id;
no rows selected
Elapsed: 00:09:15.90
SQL>
SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
SQL_ID  2rc9d2c83a7ak, child number 0
SELECT /*+ gather_plan_statistics */ st.*   FROM t_senttsk st INNER JOIN (WITH t_mrgdusr AS (SELECT DISTINCT usr_id
                           FROM t_usr                                                     WHERE NVL(usr_mrgemstr, usr_id) = :"SYS_B_0"
            /* i_payer_id */                                                                                               )
               SELECT t_senttsk.setk_id                                   FROM t_senttsk INNER JOIN t_mrgdusr
           ON t_senttsk.setk_affn_memb = t_mrgdusr.usr_id                                 UNION                                 SELECT
t_senttsk.setk_id                                   FROM t_senttsk INNER JOIN t_mrgdusr                                            ON
t_senttsk.setk_ownr = t_mrgdusr.usr_id) t_affil            ON st.setk_id = t_affil.setk_id
Plan hash value: 1065206678
| Id  | Operation                         | Name                        | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
|   1 |  NESTED LOOPS                     |                             |      1 |    169K|      0 |00:09:02.47 |    1514K|       |       |          |
|   2 |   TABLE ACCESS FULL               | T_SENTTSK                   |      1 |    136K|    136K|00:00:01.64 |    7062 |       |       |          |
|   3 |   VIEW                            |                             |    136K|      1 |      0 |00:09:00.54 |    1507K|       |       |          |
|   4 |    TEMP TABLE TRANSFORMATION      |                             |    136K|        |      0 |00:09:00.12 |    1507K|       |       |          |
|   5 |     LOAD AS SELECT                |                             |    136K|        |      0 |00:08:24.31 |     548K|  1024 |  1024 |          |
|   6 |      TABLE ACCESS BY INDEX ROWID  | T_USR                       |    136K|      1 |      0 |00:00:06.12 |     410K|       |       |          |
|*  7 |       INDEX RANGE SCAN            | IX_NVL_USR_MRGEMSTR_USR_ID  |    136K|      1 |      0 |00:00:05.41 |     410K|       |       |          |
|   8 |     SORT UNIQUE                   |                             |    136K|        |      0 |00:00:19.10 |     822K|  1024 |  1024 |          |
|   9 |      UNION-ALL PARTITION          |                             |    136K|        |      0 |00:00:17.40 |     822K|       |       |          |
|  10 |       NESTED LOOPS                |                             |    136K|      1 |      0 |00:00:08.02 |     411K|       |       |          |
|  11 |        TABLE ACCESS BY INDEX ROWID| T_SENTTSK                   |    136K|      1 |    136K|00:00:06.36 |     411K|       |       |          |
|* 12 |         INDEX UNIQUE SCAN         | PK_T_SENTTSK                |    136K|      1 |    136K|00:00:03.68 |     273K|       |       |          |
|* 13 |        VIEW                       |                             |    136K|      1 |      0 |00:00:01.03 |       0 |       |       |          |
|  14 |         TABLE ACCESS FULL         | SYS_TEMP_0FD9D6609_399116CE |    136K|      1 |      0 |00:00:00.67 |       0 |       |       |          |
|  15 |       NESTED LOOPS                |                             |    136K|      1 |      0 |00:00:06.54 |     411K|       |       |          |
|* 16 |        TABLE ACCESS BY INDEX ROWID| T_SENTTSK                   |    136K|      1 |  34256 |00:00:05.87 |     411K|       |       |          |
|* 17 |         INDEX UNIQUE SCAN         | PK_T_SENTTSK                |    136K|      1 |    136K|00:00:03.46 |     273K|       |       |          |
|* 18 |        VIEW                       |                             |  34256 |      1 |      0 |00:00:00.25 |       0 |       |       |          |
|  19 |         TABLE ACCESS FULL         | SYS_TEMP_0FD9D6609_399116CE |  34256 |      1 |      0 |00:00:00.16 |       0 |       |       |          |
Predicate Information (identified by operation id):
   7 - access("T_USR"."SYS_NC00127$"=:SYS_B_0)
  12 - access("T_SENTTSK"."SETK_ID"="ST"."SETK_ID")
  13 - filter("T_SENTTSK"."SETK_AFFN_MEMB"="T_MRGDUSR"."USR_ID")
  16 - filter("T_SENTTSK"."SETK_OWNR" IS NOT NULL)
  17 - access("T_SENTTSK"."SETK_ID"="ST"."SETK_ID")
  18 - filter("T_SENTTSK"."SETK_OWNR"="T_MRGDUSR"."USR_ID")
hoek wrote:Does rewriting 'the heart of the issue' into like below make any difference?
select a.*
from   foo a
where  exists ( select null
from   bar b
where  a.foo_pk_id = b.foo_pk_id
and    b.some_col = :bind_var
The UNION in the subquery seems to make that difficult.

Similar Messages

  • Why does fix capitalization work when there is only one space after the period in pages 09?

    why does fix capitalization work when there is only one space after the period in pages 09?  For example:  "Turn on 3rd St. After the traffic light."  There is only one space after the period in "St."  shouldn't it only auto correct after TWO spaces..??  the word After, should be after..

    You may also use a noBreak space after the period at the end of the abbreviation.
    If I remember well, in such case the capitalization will not apply.
    Yvan KOENIG (VALLAURIS, France) mercredi 27 avril 2011 23:34:46

  • How can I avoid a full scan when ...

    Hello
    How can I avoid a full scan with I apply the aggregate function "MIN"
    SQL> select min(c1) from hh;
       MIN(C1)
             1
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE
       1    0   SORT (AGGREGATE)
       2    1     TABLE ACCESS (FULL) OF 'HH'Regards
    James King

    The table 'hh' does not have statistics. Assuming that there is an index on the column c1, statistics are computed on the table and its indexes, you may see a
    INDEX (FULL SCAN (MIN/MAX)) of the index on column 'c1'.

  • Why can I only sync when my Apple TV is showing on the TV

    Does anyone else have this problem?
    I can only sync my PC to the Apple TV when either my Apple TV is actually showing on the TV screen or the TV is OFF.
    I am connected via WiFi and Sync speed is good when it is working but why do I have to wait for the TV to be free. I have kids so it has to be either very late or I have to kick them off (no chance)???

    Your tv sounds as though it isn't entirely disconnecting the HDMI to the tv when switched to another source and causing it some problems. Whilst I can't suggest a fix, this isn't usual behaviour.

  • Hello: I am brand new to firefox why am I getting message when I go to a website that the page is not encrypted. This the first that this has happened.

    Hello,
    I have been told that firefox is the best. So, I thought I would try it. But, since I have downloaded it, which has been recently it is telling me when I click on information about a page that the page is NOT being
    encrypted. This is all new to me and I DESPERATELY NEED SOME HELP because I go to school and
    have to use my computer. Thank you! S. Howe

    Note that Firefox will tend to learn to go to secure sites. So once you visit a site using the secure option you will not see the message again.
    This forum may be read using
    # Not Secure <br />http://support.mozilla.org/en-US/questions/
    #Normally you would use Secure https://support.mozilla.org/en-US/questions/988901
    If you have already used the secure version Firefox will in future use that when you try to use the insecure version.

  • HT1918 why dose it tell me when i put card details in thats the payment processing is temporarily unavailable?   fix this bug cant download anything.

    It started sunday an now can even download any apps music or films so how can i correct this if they wont accept my security code to download stuff. plus i tryed setting up a new account an that dosnt let me add any details. I want apple to fix this bug right now

    The iTunes Store has no phone support and never has. Contacting them has always been via web form. Go here:
    http://www.apple.com/support/itunes/contact/
    and follow the instructions to report the issue to the iTunes Store.
    Regards.

  • Why does an error occur when downloading OS X Mountain Lion from the Mac Store? Help!

    I purchased it and was downloading it, until the very last moment i got an error message and i cant get it anymore

    http://www.apple.com/support/mac/app-store/contact.html?form=account

  • Why does Adobe Manager crash when I create to download programs from the creative cloud?

    I just signed on to Adobe Creative Cloud and trying to download apps to my desktop and Adobe Manager crashed everytime. I am running on OSX 10.9.4. Any suggestions?

    I would click the download button from the apps page. The Adobe Apps Manager would launch then crash. I didn't know what else to do, so I noticed I didn't have the latest Adobe App Manager.
    After I updated my AAM, the download worked fine. Thanks you for looking into it.

  • Why can't I scan from my pro8600

    Why can't I scan from my pro8600

    Howdy borrotolove,
    Thanks for using the Apple Support Communities.
    If you're having issues with FaceTime on your Mac, then go ahead and take a look at the link below.
    FaceTime for Mac: Troubleshooting FaceTime - Apple Support
    Have a good one,
    Alex H.

  • Monitors: SQL Server: Access Methods: Full Scans/sec

    Hello,
    I created a Monitor:
    Monitors: SQL Server: Access Methods:
    Full Scans/sec
    It appears in Heath explorer on the servers
    but is not available in the Performance Data for the Views...
    What did I miss? I need to create a rule but which type ? linked to the monitor?
    Should I use a Rule or a Monitor or a combination?
    Thanks,
    Dom
    System Center
    Operations Manager 2007 / System Center
    Configuration Manager 2007 R2 /
    Forefront Client Security
    / Forefront Identity Manager

    Hello,
    I got on the servers the
    1200:New Management Pack(s) requested. Management group "SCOM-MED", configuration id:"68 D8 86 93 7A 48 27 13 C0 6F B2 76 3C A4 07 87 DA 53 22 7F ".
    1201:New Management Pack with id:"xxxx.SQL.Servers", version:"1.0.0.1" received.
    1207... Rule/Monitor "Microsoft.Windows.SystemCenterDPM.DPMServerDiscovery" running for remote instance "MSQLCL1SQLBU.ad.medctr.ucla.edu" with id:"{A3100D57-1657-A51E-CD3E-6ACF2679A501}" will be disabled as it is not remotable.
    Management group "SCOM-MED".
    1210 New configuration became active. Management group "SCOM-MED", configuration id:"68 D8 86 93 7A 48 27 13 C0 6F B2 76 3C A4 07 87 DA 53 22 7F ".
    still waiting ...
    1204: Management Pack with id:"xxxx.SQL.Servers", version:"1.0.0.1" is no longer used by HealthService and will be deleted from cache.
    Is this 1204 okay !!!!!
    Thanks,
    Dom
    System Center Operations Manager 2007 / System Center Configuration Manager 2007 R2 / Forefront Client Security / Forefront Identity Manager

  • Keeping images full size when uploading from "Photos" after editing

    Is there any way that I can edit photos in the ”Photos” app and keep what I have edited and also keep them full size when I upload them Flickr?

    Highlight the images you wish to export.
    Ctrl-Shift-E to open the export dialog.
    Change the top drop-down list to Hard Drive.
    Choose a location for the files in the Export Location section.
    Adjust file naming if necessary.
    In the File Settings section make sure you have the correct output format selected and choose a quality (85 is fine for most things and keeps file size manageable).
    Make file size changes as appropriate in the Image Sizing section.
    If you are downsizing a lot then consider adding some output sharpening.
    Click Export.
    Hopefully that covers most things.

  • Partition key modification effect the performence of the table ?

    we have a partitioned table with more than 15 partitions(Range partition 9i version).
    now we want to modify the partition key using row movement option,
    but i found in forums and google that partition key modification may effetcs the database performence.
    i want to know it will effects the db performence or not,if yes, what extent it effects the db performence and what are the issues may rise ?
    Edited by: Nagendra T on Sep 19, 2011 9:32 PM
    Edited by: Nagendra T on Sep 19, 2011 9:34 PM

    >
    i want to know it will effects the db performence or not,if yes, what extent it effects the db performence and what are the issues may rise ?
    One thing I can think of is partition pruning.
    If the new partition key is not being used in the predicates then partition pruning may not occur.
    You should choose partition key wisely to ensure that pruning happens almost for all DMLs.
    >
    i want to know it will effects the db performence or not,if yes, what extent it effects the db performence and what are the issues may rise ?
    Well, due to lack of pruning, you may even see table full scan instead of single partition scan which will drastically hamper the performance

  • When formatting a date field in a where clause the template put dot instead of comma

    Hello to Headstart Workers !
    In a query find block the template construct a where clause, in some cases, and i dont know when the template is formatting a date field putting a dot instead of a comma.
    Ex.: to_date('19-01-2001'.'DD-MM-YYYY')
    Anybody knows why or where the template do this.
    Congratulations
    Nelson

    - We created it using the HS utilities.
    - "nls_numeric_character = ,.".
    - it onky happen when the field date is not the first field in the where clause.
    - i can see the problem just after pressing find button, already in the ls_block in last_query.
    - the find_query works normally but cannot edit any line in ls_block.
    Hope that i had helping
    Regards
    Nelson
    null

  • To count the records in the database table...

    I want to count the number of records in the database table (infotypes PA0000)
    is it possible to count ?
    Any function module is there?
    Thanks in advance..

    Hi dhavamani ponnusamy,
    SELECT COUNT(*) FROM <DB TABLE NAME> WHERE <CONDITION>.
    or
    SY-DBCNT Will have total no of records satisfying the given criteria in where clause.
    See below sample..
    Data: itab like mara occurs 0 with header line.
    Select * from mara into table mara.
    write:/ sy-dbcnt.
    Hope it will solve your problem...
    Reward points if useful..
    Thanks & Regards
    ilesh 24x7

  • Why  it is taking full table scan when index is available

    Hi all,
    I am facing a strange problem with index.
    I created index on a column like
    1. CREATE INDEX ASSETS_ARTIST_IDX2 ON ASSETS(artist).
    SELECT asset.artist AS NAME FROM ASSETS asset WHERE asset.artist LIKE 'J%'
    Explain Plan : INDEX RANGE SCAN
    2. CREATE INDEX ASSETS_ARTIST_IDX2 ON ASSETS(UPPER (TRANSLATE (artist, ',;:"', ' ')));
    SELECT asset.artist AS NAME FROM ASSETS asset WHERE UPPER (TRANSLATE (artist, ',;:"', ' ')) LIKE 'J%'
              Explain Plan : TABLE ACCESS FULL
    first time it is taking index range scan,but in second situation scaning full table.Please let me know how to avoid the full table scan.
    Regards,
    Rajasekhar

    Actually, I misseunderstood damorgan' s statement about NULL and OP did not provide table definition. So based on FTS I would say it is more likely column is NULLable, otherwise I would expect INDEX FAST SCAN:
    SQL> create table emp1 as select * from emp
      2  /
    Table created.
    SQL> create index emp1_idx1 on emp1(empno)
      2  /
    Index created.
    SQL> exec dbms_stats.gather_table_stats('SCOTT','EMP1');
    PL/SQL procedure successfully completed.
    SQL> desc emp1
    Name                                                                     Null?    Type
    EMPNO                                                                             NUMBER(4)
    ENAME                                                                             VARCHAR2(10)
    JOB                                                                               VARCHAR2(9)
    MGR                                                                               NUMBER(4)
    HIREDATE                                                                          DATE
    SAL                                                                               NUMBER(7,2)
    COMM                                                                              NUMBER(7,2)
    DEPTNO                                                                            NUMBER(2)
    SQL> explain plan for
      2  select empno
      3  from emp1 where UPPER(TRANSLATE(empno, ',;:"', ' ')) LIKE '7%'
      4  /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 2226897347
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |     4 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP1 |     1 |     4 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - filter(UPPER(TRANSLATE(TO_CHAR("EMPNO"),',;:"',' ')) LIKE '7%')
    13 rows selected.
    SQL> alter table emp1 modify empno not null
      2  /
    Table altered.
    SQL> explain plan for
      2  select empno
      3  from emp1 where UPPER(TRANSLATE(empno, ',;:"', ' ')) LIKE '7%'
      4  /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 2850860361
    | Id  | Operation        | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT |           |     1 |     4 |     1   (0)| 00:00:01 |
    |*  1 |  INDEX FULL SCAN | EMP1_IDX1 |     1 |     4 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - filter(UPPER(TRANSLATE(TO_CHAR("EMPNO"),',;:"',' ')) LIKE '7%')
    13 rows selected.
    SQL> SY.

Maybe you are looking for