CBO bug? Lack of SORT UNIQUE.

Hi all,
Let's consider following case:
create table tmp as select rownum id, 0 sign from dual connect by level <= 100;
create index tmp_i on tmp(id,sign);
create table t as
select mod(rownum,2) id, mod(rownum,3) val
from dual
connect by level <= 100000;
begin
   dbms_stats.gather_table_stats (
      user,
      'T',
      estimate_percent   => null,
      method_opt         => 'FOR ALL COLUMNS SIZE SKEWONLY',
      cascade            => true
end;
begin
   dbms_stats.gather_table_stats (
      user,
      'TMP',
      estimate_percent   => null,
      method_opt         => 'FOR ALL COLUMNS SIZE SKEWONLY',
      cascade            => true
end;
/As you can see it scans TMP_I 50 000 times for statement with max (irrespective of distinct in subquery).
Is there any way to enforce CBO to make SORT UNIQUE for max as well as for count so that it scans TMP_I only 3 times?
SQL> select --+ leading(t) use_nl(t tmp)
  2  max(id)
  3  from tmp tmp
  4  where tmp.sign = 0
  5  and tmp.id in (select val from t where id = 1);
   MAX(ID)
         2
| Id  | Operation           | Name  | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
|   0 | SELECT STATEMENT    |       |      1 |        |      1 |00:00:00.14 |     159 |
|   1 |  SORT AGGREGATE     |       |      1 |      1 |      1 |00:00:00.14 |     159 |
|   2 |   NESTED LOOPS      |       |      1 |  49750 |  33333 |00:00:00.13 |     159 |
|*  3 |    TABLE ACCESS FULL| T     |      1 |  50000 |  50000 |00:00:00.02 |     156 |
|*  4 |    INDEX RANGE SCAN | TMP_I |  50000 |      1 |  33333 |00:00:00.07 |       3 |
Predicate Information (identified by operation id):
   3 - filter("ID"=1)
   4 - access("TMP"."ID"="VAL" AND "TMP"."SIGN"=0)
SQL> select --+ leading(t) use_nl(t tmp)
  2  max(id)
  3  from tmp tmp
  4  where tmp.sign = 0
  5  and tmp.id in (select distinct val from t where id = 1);
   MAX(ID)
         2
| Id  | Operation           | Name  | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
|   0 | SELECT STATEMENT    |       |      1 |        |      1 |00:00:00.14 |     159 |
|   1 |  SORT AGGREGATE     |       |      1 |      1 |      1 |00:00:00.14 |     159 |
|   2 |   NESTED LOOPS      |       |      1 |  49750 |  33333 |00:00:00.13 |     159 |
|*  3 |    TABLE ACCESS FULL| T     |      1 |  50000 |  50000 |00:00:00.01 |     156 |
|*  4 |    INDEX RANGE SCAN | TMP_I |  50000 |      1 |  33333 |00:00:00.07 |       3 |
Predicate Information (identified by operation id):
   3 - filter("ID"=1)
   4 - access("TMP"."ID"="VAL" AND "TMP"."SIGN"=0)
SQL> select --+ leading(t) use_nl(t tmp)
  2  count(id)
  3  from tmp tmp
  4  where tmp.sign = 0
  5  and tmp.id in (select val from t where id = 1);
COUNT(ID)
         2
| Id  | Operation            | Name  | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
|   0 | SELECT STATEMENT     |       |      1 |        |      1 |00:00:00.03 |     158 |       |       |          |
|   1 |  SORT AGGREGATE      |       |      1 |      1 |      1 |00:00:00.03 |     158 |       |       |          |
|   2 |   NESTED LOOPS       |       |      1 |      3 |      2 |00:00:00.03 |     158 |       |       |          |
|   3 |    SORT UNIQUE       |       |      1 |  50000 |      3 |00:00:00.03 |     156 |  2048 |  2048 | 2048  (0)|
|*  4 |     TABLE ACCESS FULL| T     |      1 |  50000 |  50000 |00:00:00.01 |     156 |       |       |          |
|*  5 |    INDEX RANGE SCAN  | TMP_I |      3 |      1 |      2 |00:00:00.01 |       2 |       |       |          |
Predicate Information (identified by operation id):
   4 - filter("ID"=1)
   5 - access("TMP"."ID"="VAL" AND "TMP"."SIGN"=0)I can't figure out why SORT UNIQUE is absent for statement with max.
PS. 11gR2

Thanks for reply.
user503699 wrote:
I don't think it is a good idea to compare your last and first query timings as they are 2 different queries.Ok. I could compare query with max(id), sign(count(*)+1) vs max(id), sign(1). They always produce the same results so can be considered as the same.
But I think that max(id), count(*) vs max(id) was enough to explain my point.
user503699 wrote:
If you are so sure of that you can write something like following :
SQL> with data as (select /*+ materialize */ distinct val as val from t where id = 1)
select max(id) from tmp tmp where tmp.sign = 0 and tmp.id in (select val from data) ;  2 
I thought about that. I’m reluctant to use undocumented hints such as materialize. So folowing query has almost the best plan for my data:
with data as (select distinct val as val from t where id = 1 and rownum > 0)
select
max(id)
from tmp tmp
where tmp.sign = 0
and tmp.id in (select * from data);
| Id  | Operation               | Name  | Rows  | Bytes | Cost (%CPU)| Time     |                                                                    
|   0 | SELECT STATEMENT        |       |     1 |     8 |    50   (8)| 00:00:01 |                                                                    
|   1 |  SORT AGGREGATE         |       |     1 |     8 |            |          |                                                                    
|   2 |   NESTED LOOPS          |       |     3 |    24 |    50   (8)| 00:00:01 |                                                                    
|   3 |    VIEW                 |       |     3 |     9 |    50   (8)| 00:00:01 |                                                                    
|   4 |     HASH UNIQUE         |       |     3 |    18 |    50   (8)| 00:00:01 |                                                                    
|   5 |      COUNT              |       |       |       |            |          |                                                                    
|*  6 |       FILTER            |       |       |       |            |          |                                                                    
|*  7 |        TABLE ACCESS FULL| T     | 50000 |   292K|    47   (3)| 00:00:01 |                                                                    
|*  8 |    INDEX RANGE SCAN     | TMP_I |     1 |     5 |     0   (0)| 00:00:01 |                                                                    
Predicate Information (identified by operation id):                                                                                                  
   6 - filter(ROWNUM>0)                                                                                                                              
   7 - filter("ID"=1)                                                                                                                                
   8 - access("TMP"."ID"="DATA"."VAL" AND "TMP"."SIGN"=0)   And changing two hidden parameters may lead to the same plan as I expect:
alter session set "_gby_hash_aggregation_enabled" = false;
alter session set "_simple_view_merging" = false;
with data as (select distinct val as val from t where id = 1)
select
max(id)
from tmp tmp
where tmp.sign = 0
and tmp.id in (select * from data);
| Id  | Operation             | Name  | Rows  | Bytes | Cost (%CPU)| Time     |                                                                      
|   0 | SELECT STATEMENT      |       |     1 |    18 |    50   (8)| 00:00:01 |                                                                      
|   1 |  SORT AGGREGATE       |       |     1 |    18 |            |          |                                                                      
|   2 |   NESTED LOOPS        |       |     3 |    54 |    50   (8)| 00:00:01 |                                                                      
|   3 |    VIEW               |       |     3 |    39 |    50   (8)| 00:00:01 |                                                                      
|   4 |     SORT UNIQUE       |       |     3 |    18 |    50   (8)| 00:00:01 |                                                                      
|*  5 |      TABLE ACCESS FULL| T     | 50000 |   292K|    47   (3)| 00:00:01 |                                                                      
|*  6 |    INDEX RANGE SCAN   | TMP_I |     1 |     5 |     0   (0)| 00:00:01 |                                                                      
Predicate Information (identified by operation id):                                                                                                  
   5 - filter("ID"=1)                                                                                                                                
   6 - access("TMP"."ID"="DATA"."VAL" AND "TMP"."SIGN"=0)   But here I've got two additional questions:
1. no_use_hash_aggregation can be used instead of "alter session set "_gby_hash_aggregation_enabled" = false;"
What hint can be used instead of "alter session set "_simple_view_merging" = false;"?
2. Is there any way to enforce CBO to use for this one
select
max(id)
from tmp tmp
where tmp.sign = 0
and tmp.id in (select distinct val as val from t where id = 1 and rownum > 0);
| Id  | Operation                   | Name  | Rows  | Bytes | Cost (%CPU)| Time     |                                                                
|   0 | SELECT STATEMENT            |       |     1 |     5 |     3   (0)| 00:00:01 |                                                                
|   1 |  SORT AGGREGATE             |       |     1 |     5 |            |          |                                                                
|   2 |   FIRST ROW                 |       |     1 |     5 |     1   (0)| 00:00:01 |                                                                
|*  3 |    INDEX FULL SCAN (MIN/MAX)| TMP_I |     1 |     5 |     1   (0)| 00:00:01 |                                                                
|*  4 |     FILTER                  |       |       |       |            |          |                                                                
|   5 |      COUNT                  |       |       |       |            |          |                                                                
|*  6 |       FILTER                |       |       |       |            |          |                                                                
|*  7 |        TABLE ACCESS FULL    | T     |     2 |    12 |     2   (0)| 00:00:01 |                                                                
-------------------------------------------------------------------------------------  the same plan as for this
with data as (select distinct val as val from t where id = 1 and rownum > 0)
select
max(id)
from tmp tmp
where tmp.sign = 0
and tmp.id in (select * from data);
| Id  | Operation               | Name  | Rows  | Bytes | Cost (%CPU)| Time     |                                                                    
|   0 | SELECT STATEMENT        |       |     1 |     8 |    50   (8)| 00:00:01 |                                                                    
|   1 |  SORT AGGREGATE         |       |     1 |     8 |            |          |                                                                    
|   2 |   NESTED LOOPS          |       |     3 |    24 |    50   (8)| 00:00:01 |                                                                    
|   3 |    VIEW                 |       |     3 |     9 |    50   (8)| 00:00:01 |                                                                    
|   4 |     HASH UNIQUE         |       |     3 |    18 |    50   (8)| 00:00:01 |                                                                    
|   5 |      COUNT              |       |       |       |            |          |                                                                    
|*  6 |       FILTER            |       |       |       |            |          |                                                                    
|*  7 |        TABLE ACCESS FULL| T     | 50000 |   292K|    47   (3)| 00:00:01 |                                                                    
|*  8 |    INDEX RANGE SCAN     | TMP_I |     1 |     5 |     0   (0)| 00:00:01 |                                                                    
I don't have anything against subquery factoring clause. Just for personal interest.
(I have read topic "Thread: Materialize a Subquery without using "with" clause"
Materialize a Subquery without using "with" clause
user503699 wrote:
If you are not going to change other things (like stats collection method, table/index structures etc.) which allow optimizer to choose better plan and you know your data better, you may need to be very specific with the hints and also may have to use additional hints in order to influence optimizer decisions.
One way to do that would be to get the base details from oracle as follows (and tweak them) :I didn't find keyword "ADVANCED" in specification for DISPLAY_CURSOR Function in documentation. Nice trick.
But anyway outline data makes sense only in case when query already has desirable execution plan.

Similar Messages

  • Interactive Report BUG (hangs when sorting columns)

    Hi All,
    i have an interactive report, and when i click on a column to sort the data the report hangs.
    To circle in the screen keeps circeling and on the botom and i get an javascipt error in the apex_3_1.js file.
    i am working with apex 3.2.1.00.02 with an oracle 10G DB.
    I also can reporduce this error. When i have an interactive report in which the sorting works properly and i copy this page to a new page i get a report in which the interactive report sorting is not working.
    Can you please help me in resolving the issue, or is this a known bug ?
    Regards,
    Marco Schlicher

    Hello,
    I came across the same issue. I made a test IR report with the following query
    SELECT '<span class="blue">'||id||'</span>'||name as n_name, id
    FROM
    +(SELECT ''||fullname||'' name, id from users)+
    It all works fine on FF but IE returns this
    Webpage error details
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; InfoPath.2; AskTB5.5)
    Timestamp: Wed, 5 May 2010 07:53:11 UTC
    Message: Unknown runtime error
    Line: 1
    Char: 9270
    Code: 0
    URI: http://localserver/i/javascript/apex_3_1.js
    Using the IE debugging tool, error occurs upon this
    function $dom_AddTag(E,A,C)
    +{+
    var D=document.createElement(A);
    var B=$x(E);
    +if(B){B.appendChild(D)}+
    +if(C!=null){D.innerHTML=C}+
    return D}
    It all works fine if I remove the <a href... tag...But I need it and I can't use the column properties since it's quite a huge list of if's for the link creation.
    Thanks,
    Andrea

  • Nokia 5530 firmware v.30 bugs/lacks

    After updating my nokia 5530 (RM-504) to firmware v.30 I encountered the following bugs and lacks:
    1.The phone prompts for a lock code, even though it didn't before, and when I try 12345 I get code error. But the phone still seem to work as usual.
    2. I tried playing mpeg4 file. The audio played but not the video.
    3. brightlight app doesn't work anymore.
    I'll appreciate your ideas and solutions.

    OVI suite was able to recognize my phone and it said latest update v30 was available, so I proceed as per the screen instructions and it gave me two options.
    1. Take backup and then install the update
    2. Install the update without the backup.
    Both the options failed to install the update. It said the phone should be connected via OVI or PC suite even though it was connected using PC suite option in phone. I kept trying at one time it said the backup failed.
    It looks like to be a driver issue with the latest updates from Nokia for its applications. With the previous versions there was no issue like this. Sometimes OVI suite fails to detect the phone even the phone is recognized by the computer and I was able to access its contents.
    I have attached a screen shot of the error. I hope Nokia will fix this issue
    Attachments:
    Nokia Backup error.jpg ‏37 KB

  • Bug in report sorting? Sort doesn't work in last group level.

    Is this a known error? Is there documentation from Oracle about it?
    My query is a simple select from a table. I then created three group levels. Each group contains a value for sorting (up arrow next to column). However, data is not sorted by the value in the third group.
    Try:
    create table test_sort (a number, b varchar2(5), c varchar2(5));
    insert into test_sort (a, b, c) values (1, 'A', 'X');
    insert into test_sort (a, b, c) values (1, 'B', 'Y');
    insert into test_sort (a, b, c) values (1, 'B', 'Z');
    insert into test_sort (a, b, c) values (1, 'A', 'Z');
    insert into test_sort (a, b, c) values (2, 'A', 'Z');
    insert into test_sort (a, b, c) values (2, 'A', 'Y');
    insert into test_sort (a, b, c) values (2, 'A', 'X');
    insert into test_sort (a, b, c) values (1, 'A', 'Y');
    insert into test_sort (a, b, c) values (1, 'B', 'X');
    Create a query tabular report with the wizard (select * from test_sort). Then make the groups: first a, then b, then c. Make sure that there is an arrow next to the values (sorting).
    The report only displays a and b values sorted.
    Edited by: user489847 on Jun 3, 2010 1:19 AM

    Hello,
    This is the normal behaviour documented here :
    http://www.oracle.com/webapps/online-help/reports/10.1.2/topics/htmlhelp_rwbuild_hs/rwcontxt/props/pi_col_break_order.htm
    Restrictions
    Break Order has no effect on columns that belong to the lowest group of a particular query.
    Break Order only affects columns in groups that are above the lowest child group of a query.
    You have to add an "ORDER BY" in the SQL query in order to sort the columns belonging to the "lowest group"
    Regards

  • Invoice sort or lack of sort

    Got a weird one here,
    If go Payables Manger > Invoices > Inquiry > Invoices
    Enter a suppler and click find i then get a list of invoices.
    now the issue is this, one some suppliers they are sorted in date order, in others they aren't.
    I did a clone last week and when you look at that they apear in the correct order but not on the live system.
    Any idea's?
    The form's are the same version
    Current Form
    Form Application : Payables
    Form Name : APXINWKB
    Form Path : /app/oratest/appl/ap/11.5.0/forms/US/APXINWKB.fmx
    Form Version : 11.5.564.11591.13
    Form Last Modified : $Date: 2003/10/02 04:25 $
    Thanks
    Message was edited by:
    oraclebhoy

    Hello
    Further digging has found that it's doing the sort on the invoice_num column but this is NOT in the first three columns and it's not part of the order by clause in the SQL.
    Any idea's?

  • [Solved (Upstream bug, lack of header)] apngopt keep failing

    # Contributor: kusakata <shohei atmark kusakata period com>
    # Contributor: Pablo Lezaeta <prflr88 (arro'a) gmail.com>
    pkgname=apngopt
    pkgver=1.3
    pkgrel=1
    pkgdesc="Optimizes existing APNG animation"
    arch=("i686" "x86_64")
    url="http://sourceforge.net/projects/apng/files/APNG_Optimizer/"
    license=("zlib")
    source=("http://downloads.sourceforge.net/project/apng/APNG_Optimizer/${pkgver}/apngopt-${pkgver}-src.zip")
    build() {
    cd "${srcdir}"
    make DESTDIR="${pkgdir}" prefix=/usr sbindir=/usr/bin bindir=/usr/bin libdir=/usr/lib
    package() {
    cd "${srcdir}"
    make DESTDIR="${pkgdir}" prefix=/usr sbindir=/usr/bin bindir=/usr/bin libdir=/usr/lib install
    #install -Dm755 apngopt "${pkgdir}/usr/bin/apngopt"
    md5sums=('e2d2411ea9a704c5522dbcad482816f1')
    I suspect that something is misused in the source but that supersimplistic makefile is not helping, but I will deal with it later, for now the problem it keep failing during the last part of the build in the 7zip plugin (new to 1.3) "memcpy" "memset" "strcpy" "strrchr" "strcat" those are the culprits but as far ME know those are standard for c++ and also the makefile has -lstdc++ added, that as far ME know has the stadard c++ functions... so I'm a little clueles.
    I know who is the culprit but not why.
    Last edited by Jristz (2015-03-28 05:15:02)

    like this?
    ==> Making package: apngopt 1.3-1 (Sat Mar 28 01:31:10 CLST 2015)
    ==> Checking runtime dependencies...
    ==> Checking buildtime dependencies...
    ==> Retrieving sources...
    -> Found apngopt-1.3-src.zip
    ==> Validating source files with md5sums...
    apngopt-1.3-src.zip ... Passed
    ==> Extracting sources...
    -> Extracting apngopt-1.3-src.zip with bsdtar
    bsdtar: Failed to set default locale
    ==> Starting build()...
    mkdir -p obj/. obj/7z obj/zopfli
    gcc -o obj/./apngopt.o -c apngopt.cpp -I./. -I./7z -I./zopfli -Wall -pedantic -O2
    gcc -o obj/7z/OutByte.o -c 7z/OutByte.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/DeflateEncoder.o -c 7z/DeflateEncoder.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/InByte.o -c 7z/InByte.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/WindowOut.o -c 7z/WindowOut.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/LenCoder.o -c 7z/LenCoder.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/LiteralCoder.o -c 7z/LiteralCoder.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/LSBFEncoder.o -c 7z/LSBFEncoder.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/AriBitCoder.o -c 7z/AriBitCoder.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/7zlzma.o -c 7z/7zlzma.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/LZMADecoder.o -c 7z/LZMADecoder.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/HuffmanEncoder.o -c 7z/HuffmanEncoder.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/7zdeflate.o -c 7z/7zdeflate.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/IInOutStreams.o -c 7z/IInOutStreams.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/LSBFDecoder.o -c 7z/LSBFDecoder.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/LZMAEncoder.o -c 7z/LZMAEncoder.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/DeflateDecoder.o -c 7z/DeflateDecoder.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/CRC.o -c 7z/CRC.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/LZMA.o -c 7z/LZMA.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/7z/WindowIn.o -c 7z/WindowIn.cc -I./. -I./7z -I./zopfli -Wall -pedantic -O2 -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    gcc -o obj/zopfli/deflate.o -c zopfli/deflate.c -I./. -I./7z -I./zopfli -Wall -pedantic -O2
    gcc -o obj/zopfli/blocksplitter.o -c zopfli/blocksplitter.c -I./. -I./7z -I./zopfli -Wall -pedantic -O2
    gcc -o obj/zopfli/zopfli_lib.o -c zopfli/zopfli_lib.c -I./. -I./7z -I./zopfli -Wall -pedantic -O2
    gcc -o obj/zopfli/squeeze.o -c zopfli/squeeze.c -I./. -I./7z -I./zopfli -Wall -pedantic -O2
    gcc -o obj/zopfli/lz77.o -c zopfli/lz77.c -I./. -I./7z -I./zopfli -Wall -pedantic -O2
    gcc -o obj/zopfli/gzip_container.o -c zopfli/gzip_container.c -I./. -I./7z -I./zopfli -Wall -pedantic -O2
    gcc -o obj/zopfli/tree.o -c zopfli/tree.c -I./. -I./7z -I./zopfli -Wall -pedantic -O2
    gcc -o obj/zopfli/katajainen.o -c zopfli/katajainen.c -I./. -I./7z -I./zopfli -Wall -pedantic -O2
    gcc -o obj/zopfli/hash.o -c zopfli/hash.c -I./. -I./7z -I./zopfli -Wall -pedantic -O2
    gcc -o obj/zopfli/util.o -c zopfli/util.c -I./. -I./7z -I./zopfli -Wall -pedantic -O2
    gcc -o obj/zopfli/cache.o -c zopfli/cache.c -I./. -I./7z -I./zopfli -Wall -pedantic -O2
    gcc -o obj/zopfli/zlib_container.o -c zopfli/zlib_container.c -I./. -I./7z -I./zopfli -Wall -pedantic -O2
    apngopt.cpp: En la funci?n 'void compose_frame(unsigned char**, unsigned char**, unsigned char, unsigned int, unsigned int, unsigned int, unsigned int)':
    apngopt.cpp:98:25: error: 'memcpy' not declared in this scope
    memcpy(dp, sp, w*4);
    ^
    apngopt.cpp:103:25: error: 'memcpy' not declared in this scope
    memcpy(dp, sp, 4);
    ^
    apngopt.cpp:118:27: error: 'memcpy' not declared in this scope
    memcpy(dp, sp, 4);
    ^
    apngopt.cpp: En la funci?n 'unsigned int read_chunk(FILE*, CHUNK*)':
    apngopt.cpp:131:29: error: 'memcpy' not declared in this scope
    memcpy(pChunk->p, len, 4);
    ^
    apngopt.cpp: En la funci?n 'int load_apng(char*, std::vector<APNGFrame>&, unsigned int&, unsigned int&)':
    apngopt.cpp:274:60: error: 'memcpy' not declared in this scope
    memcpy(frameNext.p, frameCur.p, imagesize);
    ^
    apngopt.cpp:284:60: error: 'memcpy' not declared in this scope
    memcpy(frameNext.p, frameCur.p, imagesize);
    ^
    apngopt.cpp:287:68: error: 'memset' not declared in this scope
    memset(frameNext.rows[y0 + j] + x0*4, 0, w0*4);
    ^
    apngopt.cpp:313:54: error: 'memcpy' not declared in this scope
    memcpy(chunkIHDR.p + 8, chunk.p + 12, 8);
    ^
    apngopt.cpp:336:42: error: 'memcpy' not declared in this scope
    memcpy(chunk.p + 8, "IDAT", 4);
    ^
    apngopt.cpp: En la funci?n 'void optim_duplicates(std::vector<APNGFrame>&, unsigned int)':
    apngopt.cpp:414:53: error: 'memcmp' not declared in this scope
    if (memcmp(frames[i-1].p, frames[i].p, imagesize) != 0)
    ^
    apngopt.cpp: En la funci?n 'void optim_downconvert(std::vector<APNGFrame>&, unsigned int&)':
    apngopt.cpp:474:32: error: 'memset' not declared in this scope
    memset(&cube, 0, sizeof(cube));
    ^
    apngopt.cpp: En la funci?n 'void write_chunk(FILE*, const char*, unsigned char*, unsigned int)':
    apngopt.cpp:688:29: error: 'memcmp' not declared in this scope
    if (memcmp(name, "fdAT", 4) == 0)
    ^
    apngopt.cpp: En la funci?n 'void process_rect(unsigned char*, int, int, int, int, unsigned char*)':
    apngopt.cpp:864:38: error: 'memcpy' not declared in this scope
    memcpy(dp, best_row, rowbytes+1);
    ^
    apngopt.cpp: En la funci?n 'void deflate_rect_fin(int, int, unsigned char*, unsigned int*, int, int, unsigned char*, int, int)':
    apngopt.cpp:884:31: error: 'memcpy' not declared in this scope
    memcpy(dp, row, rowbytes);
    ^
    apngopt.cpp:902:30: error: 'memcpy' not declared in this scope
    memcpy(zbuf, data, size);
    ^
    apngopt.cpp: En la funci?n 'void get_rect(unsigned int, unsigned int, unsigned char*, unsigned char*, unsigned char*, unsigned int, unsigned int, int, unsigned int, unsigned int, int)':
    apngopt.cpp:1061:24: error: 'memcpy' not declared in this scope
    memcpy(pc, &c2, 3);
    ^
    apngopt.cpp: En la funci?n 'int save_apng(char*, std::vector<APNGFrame>&, unsigned int, unsigned int, unsigned int, int, int)':
    apngopt.cpp:1259:44: error: 'memcpy' not declared in this scope
    memcpy(temp, frames[i].p, imagesize);
    ^
    apngopt.cpp:1266:66: error: 'memset' not declared in this scope
    memset(temp + ((j+y0)*width + x0)*bpp, tcolor, w0*bpp);
    ^
    apngopt.cpp:1304:44: error: 'memcpy' not declared in this scope
    memcpy(rest, frames[i].p, imagesize);
    ^
    apngopt.cpp:1311:66: error: 'memcpy' not declared in this scope
    memcpy(rest + ((j+y0)*width + (k+x0))*3, &tcolor, 3);
    ^
    apngopt.cpp:1314:66: error: 'memset' not declared in this scope
    memset(rest + ((j+y0)*width + x0)*bpp, tcolor, w0*bpp);
    ^
    apngopt.cpp: En la funci?n 'int main(int, char**)':
    apngopt.cpp:1424:28: error: 'strcpy' not declared in this scope
    strcpy(szInput, szOpt);
    ^
    apngopt.cpp:1427:26: error: 'strcpy' not declared in this scope
    strcpy(szOut, szOpt);
    ^
    apngopt.cpp:1439:26: error: 'strcpy' not declared in this scope
    strcpy(szOut, szInput);
    ^
    apngopt.cpp:1440:36: error: 'strrchr' not declared in this scope
    if ((szExt = strrchr(szOut, '.')) != NULL) *szExt = 0;
    ^
    apngopt.cpp:1441:29: error: 'strcat' not declared in this scope
    strcat(szOut, "_opt.png");
    ^
    Makefile:25: recipe for target 'obj/./apngopt.o' failed
    make: *** [obj/./apngopt.o] Error 1
    ==> ERROR: A failure occurred in build().
    Aborting...
    the makefile of apngopts:
    PACKAGE = apngopt
    CC = gcc
    SRC_DIRS = . 7z zopfli
    CFLAGS = -Wall -pedantic
    CFLAGS_OPT = -O2
    CFLAGS_7Z = -Wno-sign-compare -Wno-reorder -Wno-maybe-uninitialized -Wno-parentheses
    LIBS = -lstdc++ -lm -lpng -lz
    INCUDE_DIRS := $(addprefix -I./, $(SRC_DIRS))
    OBJ_DIRS := $(addprefix obj/, $(SRC_DIRS))
    OBJECTS := $(addprefix obj/, $(wildcard $(addsuffix /*.c*, $(SRC_DIRS))))
    OBJECTS := $(OBJECTS:.c=.o)
    OBJECTS := $(OBJECTS:.cc=.o)
    OBJECTS := $(OBJECTS:.cpp=.o)
    all : $(PACKAGE)
    $(PACKAGE) : objdirs $(OBJECTS)
    $(CC) -o $@ $(OBJECTS) -s $(LIBS)
    objdirs :
    mkdir -p $(OBJ_DIRS)
    obj/%.o : %.cpp
    $(CC) -o $@ -c $< $(INCUDE_DIRS) $(CFLAGS) $(CFLAGS_OPT)
    obj/%.o : %.c
    $(CC) -o $@ -c $< $(INCUDE_DIRS) $(CFLAGS) $(CFLAGS_OPT)
    obj/%.o : %.cc
    $(CC) -o $@ -c $< $(INCUDE_DIRS) $(CFLAGS) $(CFLAGS_OPT) $(CFLAGS_7Z)
    .PHONY : clean
    clean :
    rm -rf $(PACKAGE) obj
    More like backstrace?

  • Bug: All emails containing unique large images show up with the image of the first viewed email

    After deleting all messages in my inbox and rebooting my Blackberry,
    Various emails arrive in my inbox, each containing a large image.
    Whichever email I choose to open, it will show the image that it contains, but after that, every other email I view that contains a large image, displays the image of the first email, and not the actual image in the email that I'm trying to view.
    This happens constantly.

    I have the same problem. Running Windows 7. This started to happen with in the last two weeks. Even my older e-mails from a year go does the same thing. 
    Been on tech support twice and have friends of mine over to look it over. 
    Does not happen on G mail. Happens on my laptop and pc and HTC verizon phone.
    Yes, they see it the image as fine. No help from them, verizon. 
    My images will have an X or show up half grey or like there Fios TV some time all blocks.
    I been with them for a long time too. Since they were call Bell Atlantic. 
    I am at work and I use Clear.com wifi. 
    Feel very disappointed in Verizon. 
    TomLingJr

  • File lacks any sort of Sharring or Permissions

    Not sure if this fits in the catagory here but I am having a problem between on of my 10.5.2 clients and the 10.4.11 server.
    The client connects to the server and drops a file onto one of the shared folders.
    Two things appear to happen here, 1) the client apparently can log on with any password and user name with no problem (which is a big problem)
    2) Once the file is on the server, we can not delete or even open it. The file is typically a .tif or .eps file. Getting info on the file shows that the file is not controlled by anyone. There is only one entry and it shows noneone. Privage is only read. Ther is no group or admistrator listing, like you find with all files.
    How is this happening and what can I do to get rid of this new file?
    Thanks for your help

    This forum supports setup of the .NET Framework.
    You appear to have a question about .avi file editing. Assuming you are developing a .NET application, this CodeProject article may be of some use to you:
    http://www.codeproject.com/Articles/7388/A-Simple-C-Wrapper-for-the-AviFile-Library
    For further help (assuming, again, that you are developing a .NET app), I suggest you ask here:
    For VB:
    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/threads
    For C#:
    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/threads

  • Bug in sort of numeric values in ( title and album ) string.

    The Bug in the sort-function of the iPod results in mixed up track list.
    An album with more then 9 tracks will be sorted in the wrong way, when only title or filename or album field is just to give a track a number. The play order is 1, 10, 11, 12, 13, 2, 3 , 4 , 5, 6.... instead of the correct order 1,2,3,4,5,6...10,11, 12...
    For example: After playing the track named "The Beatles - Yellow Submarine - 1 - Yellow Submarine" the ipod will play "The Beatles - Yellow Submarine - 10 - Baby, You´re A Rich Man" instead of "The Beatles - Yellow Submarine - 2 - Hey Bulldog."
    The programmer have to search the string for numbers and join all numeric values to a single number.
    Example: Sample data :abc123. is "a" a number? no. is "b" a number no. is "c" a number no. is "1" a number? yes. store. is "2" a number? yes. join to "1". (now we have "12"). is "3" a number? yes. join to "12". (Now we have "123") -> EOL
    Is "123" largen than "99"? yes! is "123" larger than 124. no!
    Thats it. In perl you need 1 line of sourcecode, in c and c++ this can be done in 10 lines. In java (there a objects for this type of sort).
    And every user will be happy and nobody has to do the 01, 02, 03 workaround or reimport their audiobooks.
    Alternativly Apple should thing about storing the original filename in the ID3 tag or itunes database. This would make sorting the files without id3 tags (believe me or not, there are many people using mp3 for 10 years and have no id3 tags in there mp3-library) in itunes possible. (there is a god free tagger for mac os but no for windows.)
    A company like Apple should have the ability to correct the error / bug in the iPod-firmware (have the same issue in classic and iphone) or itunes-softwar.
    This is a wellknown and very common error done by newbie programmers or people who have not read the documentation of the software-libraries.

    I still have an H140 in the cupboard. As I recall that needs leading zeros on filenames to sort properly. Since both WMP & iTunes include leading zeros it was never really an issue. THE Rename should be able to extract the track numbers from part of the filename and is also able to generate counters, along with the usual functions of setting tag fields from part of the file and/or folder name. Unfortuanetly THE Rename is still on the complicated side - I suspect there would be no easy way to lump together the variety of options that it has while keeping it very simple.
    Once you've used an external program to adjust the tags you can make iTunes re-read them just by selecting the group of files in question, using CRTL-I to "Get Info." and then clicking OK +without making any changes+. iTunes will recheck it's database against any values in the tag and update as required. Given the lack of existing tags I would imagine that you don't let iTunes reorganise your music at the moment and would suggest you keep things that way at least until you are sure that all the tags have been correctly applied and you have a suitable backup. I stick to a Artist/Album/## Track structure which I don't let iTunes manage so that I can always recover details from the filesnames if I should ever accidentally edit more tracks than I intend.
    tt2

  • My ipad just won't let me enter my apple password on FaceTime or iMessage, it works fine on my iPhone, I have tried numerous things but nothing works, can anybody help please, will a bug fix sort this out when they finally make one

    My ipad just won't let me sign in with my apple password on FaceTime or iMessage since updating to ios7 it says check my network connection, even though my iPhone works fine with the same password, can anybody help please, I have tried numerous things but nothing  works.  Will I have to wait for a bug fix to sort this? I hear they are working on one a the minute, I hate ios7

    Try a Restart.
    Press and hold the Sleep/Wake button for a few seconds until the red "slide to power off" slider appears, and then slide the slider. Press and hold the Sleep/Wake button until the Apple logo appears.
    Resetting your settings
    You can also try resetting all settings. Settings>General>Reset>Reset All Settings. You will have to enter all of your device settings again.... All of the settings in the settings app will have to be re-entered. You won't lose any data, but it takes time to enter all of the settings again.
    Resetting your device
    Press and hold the Sleep/Wake button and the Home button together for at least ten seconds, until the Apple logo appears. Apple recommends this only if you are unable to restart it.
    Or if this doesn't work and nobody else on the blog doesn't have a better idea you can contact Apple.
    Here is a link to their contacts with most of the information below.
    http://www.apple.com/contact/

  • Bug in iTunes numeric title sort.

    The Bug in the sort-function of the iPod results in mixed up track list.
    An album with more then 9 tracks will be sorted in the wrong way, when only title or filename or the album field is just to give a track a number. The play order is 1, 10, 11, 12, 13, 2, 3 , 4 , 5, 6.... instead of the correct order 1,2,3,4,5,6...10,11, 12...
    (Same issue with album numbers in Compliations. CD1, CD10, CD11, CD12, CD2, CD3....)
    For example: After playing the track named "The Beatles - Yellow Submarine - 1 - Yellow Submarine" the ipod/iTunes will play "The Beatles - Yellow Submarine - 10 - Baby, You´re A Rich Man" instead of "The Beatles - Yellow Submarine - 2 - Hey Bulldog."
    The programmer have to search the string for numbers and join all numeric values to a single number.
    Example: Sample data :abc123. is "a" a number? no. is "b" a number no. is "c" a number no. is "1" a number? yes. store. is "2" a number? yes. join to "1". (now we have "12"). is "3" a number? yes. join to "12". (Now we have "123") -> EOL
    Is "123" larger than "99"? yes! is "123" larger than 124. no!
    Thats it. In perl you need 1 line of sourcecode, in c and c++ this can be done in 10 lines. In java there a objects for this type of work.
    And every user will be happy and nobody has to do the 01, 02, 03 workaround or reimport their audiobooks.
    (I guess its easy and dn´t need much more performance... iTunes uses enough ram to extra cache this operation.)
    Alternativly Apple should thing about storing the original filename in the ID3 tag or itunes database. This would make sorting the files without id3 tags (believe me or not, there are many people using mp3 for 10 years and have no id3 tags in there mp3-library) in itunes possible. (there is a god free tagger for mac os but no for windows.)
    A company like Apple should have the ability to correct the error / bug in the iPod-firmware (have the same issue in classic and iphone) or itunes-softwar.
    This is a wellknown and very common error done by newbie programmers or people who have not read the documentation of the software-libraries.

    Whether you like the idea or not, the appropriate place to to incorporate information about the contents of media files is inside the tag, not the filename. Modern media software is generally designed to extract and use this information. As you have indicated users are free to choose their own filename conventions which often cannot be correctly interpreted by software. iTunes & iPod can provide you with many more ways to organise & select your music with the correct information than will be the case if, as you seem to imply, the only field present is the Name which iTunes will take from the filename if it can't find a tag.
    Assuming you've been consistent with your naming scheme a small investment of time with a tagging program could populate the ID3 tags by parsing the different sections of the name into the appropriate fields. Magic File Renamer, The Rename and similar programs can even be used just to add the leading zeros to the track number section of the filenames if you really want to hold out against adding tags. If you use a 3rd party tagger you need to force iTunes to rescan the information thus: CTRL-A (select all), CTRL-I (get info.), click OK (read the tag & update with any changes - you didn't make any before you clicked OK did you? - and update the iTunes database with the current info.) If you move or rename files outside of iTunes you can either manually remove & reimport files or use one of the tools I suggest below.
    A year ago I spent some time preparing a list of over 50 ideas for improving iTunes & iPod all of which I consider would be easy to program and would make the products nicer to use. The reality is that Apple is a large and mostly deaf corporation. I've sent my ideas to iTunes Feedback & iPod Feedback but who knows if anyone who could influnce future development ever got to see them. What is clear is that new features are generally only introduced on new models. Rather than railing that it could be better (granted) it is much more productive to gain an understanding of the way that the software works and try to accomodate for it. See, for example, my postings on Grouping tracks into albums or Find tracks without artwork where I've shared my experience on how to get all my albums organised neatly & consistently. As I mentioned elsewhere I have an iRiver and while trawling a folder structure to locate music works I'm much happier with my instant-on, fully organised & artworked iPod where I can see artwork as I'm selecting music, play videos & games and store so much more.
    tt2
    <hr>
    *Adding new items/removing orphans*
    Try iTunes Folder Watch or iTunes Library Updater. Folder Watch is much faster on the adding files front, can be set to run in the background and includes a useful exclusion feature, however it’s really slow at removing orphans. iTLU is better for this although doing it manually after looking at a list of proposed removals generated by Folder Watch is probably faster still. iTLU can also be set to update iTunes when you've used 3rd party tools to change tag info.

  • Oracle 8.1.5.1 upgrade to 9.2.0.6 sql - Oracle change or bug ?

    The following query is working on Oracle 8.1.5.1 (result 1 record), but not on Oracle 9.2.0.6 (result 0 record).
    We don't have the source to this application, and we then have to solve it on the Oracle side - it looks like an Oracle change/bug ?
    I've turned on Oracle tracing to trace the actual sql and also running explain seeing no difference.
    SELECT UNIQUE change_log.pkey_val1, customer.customer_name, customer.brief_name,
    change_log.user_id, trunc(change_log.created_date, 'DD'), change_log.auth_status,
    trunc(change_log.auth_status_date,'DD'), trunc(change_log.print_date,'DD'),
    change_log.print_status FROM customer, change_log WHERE customer.customer_id=change_log.pkey_val1
    AND auth_status = '0' AND change_log.pkey_val1 like '5334073' ORDER BY 5;
    SELECT STATEMENT_ID, operation, options, object_name, object_type, id, parent_id FROM plan_table
    WHERE STATEMENT_ID = 'QUERY1' ORDER BY id;
    Oracle 8.1.5.1
    QUERY1 SELECT STATEMENT
    QUERY1 SORT UNIQUE
    QUERY1 NESTED LOOPS
    QUERY1 TABLE ACCESS BY INDEX ROWID CHANGE_LOG
    QUERY1 INDEX RANGE SCAN DX_971_01 NO
    QUERY1 TABLE ACCESS BY INDEX ROWID CUSTOMER
    QUERY1 INDEX UNIQUE SCAN U128_13 UN
    Oracle 9.2.0.6
    QUERY1 SELECT STATEMENT
    QUERY1 SORT UNIQUE
    QUERY1 NESTED LOOPS
    QUERY1 TABLE ACCESS BY INDEX ROWID CHANGE_LOG
    QUERY1 INDEX RANGE SCAN DX_971_01 NO
    QUERY1 TABLE ACCESS BY INDEX ROWID CUSTOMER
    QUERY1 INDEX UNIQUE SCAN U128_13 UN

    Please refer [url http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/conditions10a.htm
    ]'Patterns Without % Example' on Oracle9i SQL Reference.
    Here is [url http://download-west.oracle.com/docs/cd/F49540_01/DOC/server.815/a67779/operator.htm#997970]Oracle8i SQL Reference.
    If a pattern does not contain the "%" character, the condition can be TRUE only if both operands have the same length.
    So... there are bugs on 8.1.x, 9.2.0.4...
    SQL> select * from v$version where rownum <= 1;
    BANNER
    Personal Oracle7 Release 7.3.2.3.1 - Production Release
    SQL> create table tab1 (col1 char(6));
    Table created.
    SQL> insert into tab1 values ('xyz');
    1 row created.
    SQL> select * from tab1 where col1 like 'xyz';
    no rows selected
    SQL> select * from v$version where rownum <= 1;
    BANNER
    Oracle8i Enterprise Edition Release 8.1.7.4.1 - Production
    SQL> create table tab1 (col1 char(6));
    Table created.
    SQL> insert into tab1 values ('xyz');
    1 row created.
    SQL> select * from tab1 where col1 like 'xyz';
    COL1
    xyz
    SQL> select * from v$version where rownum <= 1;
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
    SQL> create table tab1 (col1 char(6));
    Table created.
    SQL> insert into tab1 values ('xyz');
    1 row created.
    SQL> select * from tab1 where col1 like 'xyz';
    COL1
    xyz
    SQL> select * from v$version where rownum <= 1;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    SQL> create table tab1 (col1 char(6));
    Table created.
    SQL> insert into tab1 values ('xyz');
    1 row created.
    SQL> select * from tab1 where col1 like 'xyz';
    no rows selected

  • SQL Bug in "Minus" in correlated subquery presence of index (11.2.0.1.0)

    SQL Bug in "Minus" in correlated subquery presence of index
    (Oracle Database 11g Release 11.2.0.1.0)
    Below, there is a small example that shows the bug. Further below,
    there are some more comments.
    drop table Country;
    create table Country
    (code VARCHAR2(4) constraint countrykey PRIMARY KEY,
    name VARCHAR2(35));
    -- if the key constraint is not given, the bug does not occur
    drop table City;
    create table City
    (name VARCHAR2(35),
    country VARCHAR2(4),
    population number);
    drop table Locatedon;
    create table Locatedon
    (city VARCHAR2(35),
    country VARCHAR2(4),
    island VARCHAR2(35));
    insert into country values('E','Spain');
    insert into country values('F','France');
    insert into country values('S','Sweden');
    insert into country values('GB','Sweden');
    insert into city values('Ajaccio','F',53500);
    insert into city values('Paris','F',2152423);
    insert into city values('Palma','E',322008);
    insert into city values('Madrid','E',3041101);
    insert into city values('Stockholm','S',711119);
    insert into city values('London','GB',6967500);
    insert into locatedon values('Ajaccio','F','Corse');
    insert into locatedon values('Palma','E','Mallorca');
    insert into locatedon values('London','GB','Great Britain');
    -- all countries that have a city that is not located on
    -- some island: should be E, F, S.
    Select c.name
    From country c
    Where exists
    ((Select name
    From city
    Where city.country=c.code)
    minus
    (Select city
    From locatedon
    Where locatedon.country=c.code)
    -- wrong answer: only Sweden; Spain and France not in the answer!
    select distinct country from
    ((Select name, country
    From city)
    minus
    (Select city, country
    From locatedon)
    -- correct answer: E, F, S
    Comments:
    The bug has been found by students in our SQL course.
    Using a larger database from that course, the bug can be reproduced
    (same queries as above) at
    http://www.semwebtech.org/sqlfrontend/
    (wrong: 142 answers, correct: 154 answers)
    During reducing it to a simple sample, there were some interesting
    observations: trying with smaller and simpler tables (without the keys)
    and synthetic data, the bug did not occur immediately. When
    restating the query after about one day, the bug occurred. Obviously,
    Oracle creates some index on its own in course of its internal
    optimization that (or more exactly, its usage) exhibits the bug. The
    query plan (showed in SQL Developer) was the same before and after.
    Wolfgang

    There's a typo in the test data - GB should presumably not be in Sweden. However....
    the bug did not occur immediatelyIt's possible. But what would have almost certainly happened is that the execution plan DID change at some point. There are various reasons why it might not be immediate.
    Obviously, Oracle creates some index on its own in course of its internal optimizationFar from obvious, what are you on about?
    The query plan was the same before and afterBet you it wasn't.
    A clear illustration of the issue and indication that it must be a bug is below.
    Simply by hinting a different access method, we can change the result. Therefore, bug.
    See [url http://support.oracle.com]Oracle Support and search for "wrong results".
    Please raise with Oracle Support to get confirmation of bug.
    There have been so many wrong results bugs recently, it's getting ridiculous.
    It's a real issue, IMHO.
    If you can't trust the DB to get your data right....
    Note that the query plan is very much NOT the same and it is the difference in query plan which s that is the root cause of the bug.
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0      Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    SQL> SELECT c.name
      2  FROM   country1 c
      3  WHERE  exists ((SELECT name
      4                  FROM   city1
      5                  WHERE  city1.country=c.code)
      6                  MINUS
      7                 (SELECT city
      8                  FROM   locatedon1
      9                  WHERE  locatedon1.country=c.code));
    NAME
    Sweden
    SQL> SELECT /*+ full(c) */
      2         c.name
      3  FROM   country1 c
      4  WHERE  exists ((SELECT name
      5                  FROM   city1
      6                  WHERE  city1.country=c.code)
      7                  MINUS
      8                 (SELECT city
      9                  FROM   locatedon1
    10                  WHERE  locatedon1.country=c.code));
    NAME
    Spain
    France
    Sweden
    SQL> explain plan for
      2  SELECT c.name
      3  FROM   country1 c
      4  WHERE  exists ((SELECT name
      5                  FROM   city1
      6                  WHERE  city1.country=c.code)
      7                  MINUS
      8                 (SELECT city
      9                  FROM   locatedon1
    10                  WHERE  locatedon1.country=c.code));
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 156929629
    | Id  | Operation                    | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |            |     1 |    27 |    12  (25)| 00:00:01 |
    |   1 |  NESTED LOOPS                |            |       |       |            |          |
    |   2 |   NESTED LOOPS               |            |     1 |    27 |    12  (25)| 00:00:01 |
    |   3 |    VIEW                      | VW_SQ_1    |     6 |    24 |    10  (20)| 00:00:01 |
    |   4 |     MINUS                    |            |       |       |            |          |
    |   5 |      SORT UNIQUE             |            |     6 |   138 |            |          |
    |   6 |       TABLE ACCESS FULL      | CITY1      |     6 |   138 |     4   (0)| 00:00:01 |
    |   7 |      SORT UNIQUE             |            |     3 |    69 |            |          |
    |   8 |       TABLE ACCESS FULL      | LOCATEDON1 |     3 |    69 |     4   (0)| 00:00:01 |
    |*  9 |    INDEX UNIQUE SCAN         | COUNTRYKEY |     1 |       |     0   (0)| 00:00:01 |
    |  10 |   TABLE ACCESS BY INDEX ROWID| COUNTRY1   |     1 |    23 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       9 - access("VW_COL_1"="C"."CODE")
    Note
       - dynamic sampling used for this statement (level=4)
    26 rows selected.
    SQL> explain plan for
      2  SELECT /*+ full(c) */
      3         c.name
      4  FROM   country1 c
      5  WHERE  exists ((SELECT name
      6                  FROM   city1
      7                  WHERE  city1.country=c.code)
      8                  MINUS
      9                 (SELECT city
    10                  FROM   locatedon1
    11                  WHERE  locatedon1.country=c.code));
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 1378726376
    | Id  | Operation            | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |            |     1 |    23 |    14  (15)| 00:00:01 |
    |*  1 |  FILTER              |            |       |       |            |          |
    |   2 |   TABLE ACCESS FULL  | COUNTRY1   |     4 |    92 |     4   (0)| 00:00:01 |
    |   3 |   MINUS              |            |       |       |            |          |
    |   4 |    SORT UNIQUE       |            |     1 |    23 |     5  (20)| 00:00:01 |
    |*  5 |     TABLE ACCESS FULL| CITY1      |     1 |    23 |     4   (0)| 00:00:01 |
    |   6 |    SORT UNIQUE       |            |     1 |    23 |     5  (20)| 00:00:01 |
    |*  7 |     TABLE ACCESS FULL| LOCATEDON1 |     1 |    23 |     4   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter( EXISTS ( (SELECT "NAME" FROM "CITY1" "CITY1" WHERE
                  "CITY1"."COUNTRY"=:B1)MINUS (SELECT "CITY" FROM "LOCATEDON1" "LOCATEDON1"
                  WHERE "LOCATEDON1"."COUNTRY"=:B2)))
       5 - filter("CITY1"."COUNTRY"=:B1)
       7 - filter("LOCATEDON1"."COUNTRY"=:B1)
    Note
       - dynamic sampling used for this statement (level=4)
    27 rows selected.Just to show that it's related to query transformation:
    SQL> SELECT /*+ 
      2             no_query_transformation
      3         */
      4         c.name
      5  FROM   country1 c
      6  WHERE  exists ((SELECT name
      7                  FROM   city1
      8                  WHERE  city1.country=c.code)
      9                  MINUS
    10                 (SELECT city
    11                  FROM   locatedon1
    12                  WHERE  locatedon1.country=c.code));
    NAME
    Spain
    France
    Sweden
    SQL> Edited by: Dom Brooks on Jun 30, 2011 2:50 PM

  • DISTINCT in the query -- RBO vs CBO

    Hi all,
    We are in a process of migrating our applications from RBO to CBO as we moved to 10g and recently I observed a simple query with DISTINCT clause showing different results in CBO. Here is my order of creating a table in 10g environment,
    create table m_test(col1 varchar2(3));
    insert into m_test values('ZYT');
    insert into m_test values('ABC');
    insert into m_test values('RKT');
    select * from m_test
    col1
    ZYT
    ABC
    RKT
    alter session set optimizer_mode = RULE
    select distinct col1 from m_test;
    col1
    ABC
    RKT
    ZYT
    Note: Explain plan shows that it's doing SORT UNIQUE
    alter session set optimizer_mode = FIRST_ROWS_1
    select distinct col1 from m_test;
    col1
    ZYT
    ABC
    RKT
    Note: Explain plan shows that it's doing HASH UNIQUE
    I would appreciate if someone can let me know why this is happening,
    Thank you,
    Madhu

    It happened to be sorted when you were using the RBO because the query plan the RBO generated happened to involve a sort. The CBO knows that sorting isn't strictly necessary, so it may or may not choose to apply the sort.
    The CBO has a lot of options for generating query plans, depending on table, column, index, and system statistics, histograms, etc. and has a lot more plan options than the old RBO did. The CBO is a lot more likely to change a query plan than the RBO was, which is normally a good thing (a plan that works for a 10 row table might need to be changed if the table grows to 1 million rows). Depending on the Oracle version, initialization parameters, table statistics, system statistics, etc. the CBO may happen to sort rows before returning them.
    If you want Oracle to sort the rows, however, there is only one way to guarantee that-- add an ORDER BY clause.
    Justin

  • Optimizer bug in RDBMS versions 9.2.0.7.0 and 9.2.0.8.0

    This listing below demonstrates a bug in the Oracle optimizer that causes incorrect results to be returned after a table is analyzed. Rule based optimizer gives correct results.
    Under cost-based optimization the predicate includes a condition from a check constraint on a nullable field. When the value of this field is NULL the record is excluded from the results even though that record does not violate the check constraint.
    I have verified that this bug exists on both RDBMS versions 9.2.0.7.0 and 9.2.0.8.0.
    ORA92080>
    ORA92080>DROP TABLE test1;
    Table dropped.
    ORA92080>DROP TABLE test2;
    Table dropped.
    ORA92080>
    ORA92080>CREATE TABLE test1
    2 ( id     NUMBER NOT NULL
    3 , date1     DATE NOT NULL
    4 , date2     DATE
    5 );
    Table created.
    ORA92080>
    ORA92080>ALTER TABLE test1
    2 ADD ( CONSTRAINT test1_chk_date1
    3      CHECK ( date1 > TO_DATE( '01-JAN-1960', 'DD-MON-YYYY' ) )
    4      );
    Table altered.
    ORA92080>
    ORA92080>ALTER TABLE test1
    2 ADD ( CONSTRAINT test1_chk_date2
    3      CHECK ( date2 >= date1 )
    4      );
    Table altered.
    ORA92080>
    ORA92080>/* date2 is NULL */
    ORA92080>INSERT INTO test1 VALUES ( 1, TO_DATE('16-JUN-2005 11:30:01', 'DD-MON-YYYY HH24:MI:SS'), NULL );
    1 row created.
    ORA92080>
    ORA92080>/* date2 is filled in */
    ORA92080>INSERT INTO test1 VALUES ( 2
    2                     , TO_DATE('16-JUN-2005 11:30:01', 'DD-MON-YYYY HH24:MI:SS')
    3                     , TO_DATE('16-JUN-2005 11:40:01', 'DD-MON-YYYY HH24:MI:SS')
    4                );
    1 row created.
    ORA92080>
    ORA92080>CREATE TABLE test2 AS
    2 SELECT * FROM test1
    3 WHERE 1=2;
    Table created.
    ORA92080>
    ORA92080>ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
    Session altered.
    ORA92080>
    ORA92080>SELECT * FROM test1;
    ID DATE1 DATE2
    1 16-JUN-2005 11:30:01
    2 16-JUN-2005 11:30:01 16-JUN-2005 11:40:01
    2 rows selected.
    ORA92080>SELECT * FROM test2;
    no rows selected
    ORA92080>
    ORA92080>/*
    DOC>| Since no statistics were gathered, rule-based optimizer will be used.
    DOC>| The correct count of two is returned.
    DOC>*/
    ORA92080>SELECT COUNT(*) FROM test1 t
    2 WHERE EXISTS
    3      ( SELECT 'X'
    4      FROM ( SELECT id, date1
    5                FROM test1
    6           MINUS
    7           SELECT id, date1
    8                FROM test2
    9           ) i
    10      WHERE i.id = t.id
    11           AND i.date1 = t.date1
    12      );
    COUNT(*)
    2
    1 row selected.
    ORA92080>
    ORA92080>EXPLAIN PLAN FOR
    2 SELECT COUNT(*) FROM test1 t
    3 WHERE EXISTS
    4      ( SELECT 'X'
    5      FROM ( SELECT id, date1
    6                FROM test1
    7           MINUS
    8           SELECT id, date1
    9                FROM test2
    10           ) i
    11      WHERE i.id = t.id
    12           AND i.date1 = t.date1
    13      );
    Explained.
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | | | |
    | 1 | SORT AGGREGATE | | | | |
    |* 2 | FILTER | | | | |
    | 3 | TABLE ACCESS FULL | TEST1 | | | |
    | 4 | VIEW | | | | |
    | 5 | MINUS | | | | |
    | 6 | SORT UNIQUE | | | | |
    |* 7 | TABLE ACCESS FULL| TEST1 | | | |
    | 8 | SORT UNIQUE | | | | |
    |* 9 | TABLE ACCESS FULL| TEST2 | | | |
    Predicate Information (identified by operation id):
    2 - filter( EXISTS (SELECT 0 FROM ( (SELECT "TEST1"."ID"
    "ID","TEST1"."DATE1" "DATE1" FROM "TEST1" "TEST1" WHERE
    "TEST1"."DATE1"=:B1 AND "TEST1"."ID"=:B2)MINUS (SELECT "TEST2"."ID"
    "ID","TEST2"."DATE1" "DATE1" FROM "TEST2" "TEST2" WHERE
    "TEST2"."DATE1"=:B3 AND "TEST2"."ID"=:B4)) "I"))
    7 - filter("TEST1"."DATE1"=:B1 AND "TEST1"."ID"=:B2)
    9 - filter("TEST2"."DATE1"=:B1 AND "TEST2"."ID"=:B2)
    Note: rule based optimization
    28 rows selected.
    ORA92080>
    ORA92080>BEGIN
    2 DBMS_STATS.GATHER_TABLE_STATS
    3      ( ownname     => USER,
    4      tabname     => 'TEST2',
    5      estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE,
    6      cascade     => TRUE
    7      );
    8 END;
    9 /
    PL/SQL procedure successfully completed.
    ORA92080>
    ORA92080>/*
    DOC>| This is the identical query as above. With statistics gathered, the
    DOC>| cost-based optimizer is used. An incorrect count of 1 is returned.
    DOC>*/
    ORA92080>SELECT COUNT(*) FROM test1 t
    2 WHERE EXISTS
    3      ( SELECT 'X'
    4      FROM ( SELECT id, date1
    5                FROM test1
    6           MINUS
    7           SELECT id, date1
    8                FROM test2
    9           ) i
    10      WHERE i.id = t.id
    11           AND i.date1 = t.date1
    12      );
    COUNT(*)
    1
    1 row selected.
    ORA92080>
    ORA92080>/* Using rule-based optimizer, the result is correct. */
    ORA92080>SELECT /*+ RULE */ COUNT(*) FROM test1 t
    2 WHERE EXISTS
    3      ( SELECT 'X'
    4      FROM ( SELECT id, date1
    5                FROM test1
    6           MINUS
    7           SELECT id, date1
    8                FROM test2
    9           ) i
    10      WHERE i.id = t.id
    11           AND i.date1 = t.date1
    12      );
    COUNT(*)
    2
    1 row selected.
    ORA92080>
    ORA92080>EXPLAIN PLAN FOR
    2 SELECT COUNT(*) FROM test1 t
    3 WHERE EXISTS
    4      ( SELECT 'X'
    5      FROM ( SELECT id, date1
    6                FROM test1
    7           MINUS
    8           SELECT id, date1
    9                FROM test2
    10           ) i
    11      WHERE i.id = t.id
    12           AND i.date1 = t.date1
    13      );
    Explained.
    ORA92080>
    ORA92080>SET ECHO OFF
    Wrote file reset.sql
    Session altered.
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | 1 | 44 | 11 |
    | 1 | SORT AGGREGATE | | 1 | 44 | |
    |* 2 | HASH JOIN SEMI | | 1 | 44 | 11 |
    | 3 | TABLE ACCESS FULL | TEST1 | 82 | 1804 | 2 |
    | 4 | VIEW | | 1 | 22 | 8 |
    | 5 | MINUS | | | | |
    | 6 | SORT UNIQUE | | 1 | 31 | |
    |* 7 | TABLE ACCESS FULL| TEST1 | 1 | 31 | 2 |
    | 8 | SORT UNIQUE | | 1 | 22 | |
    |* 9 | TABLE ACCESS FULL| TEST2 | 1 | 22 | 2 |
    Predicate Information (identified by operation id):
    2 - access("I"."ID"="T"."ID" AND "I"."DATE1"="T"."DATE1")
    7 - filter("TEST1"."DATE1">TO_DATE(' 1960-01-01 00:00:00',
    'syyyy-mm-dd hh24:mi:ss') AND "TEST1"."DATE2">TO_DATE(' 1960-01-01
    00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
    9 - filter("TEST2"."DATE1">TO_DATE(' 1960-01-01 00:00:00',
    'syyyy-mm-dd hh24:mi:ss'))
    Note: cpu costing is off
    27 rows selected.
    ORA92080>/*
    DOC>| Workaround: change the check constraint on the test1 table that is causing the problem.
    DOC>*/
    ORA92080>ALTER TABLE test1
    2 DROP CONSTRAINT test1_chk_date2;
    Table altered.
    ORA92080>
    ORA92080>ALTER TABLE test1
    2 ADD ( CONSTRAINT test1_chk_date2
    3      CHECK ( date2 >= date1 OR date2 IS NULL )
    4      EXCEPTIONS INTO exceptions
    5      );
    Table altered.
    ORA92080>
    ORA92080>SELECT COUNT(*) FROM test1 t
    2 WHERE EXISTS
    3      ( SELECT 'X'
    4      FROM ( SELECT id, date1
    5                FROM test1
    6           MINUS
    7           SELECT id, date1
    8                FROM test2
    9           ) i
    10      WHERE i.id = t.id
    11           AND i.date1 = t.date1
    12      );
    COUNT(*)
    2
    1 row selected.
    ORA92080>
    ORA92080>EXPLAIN PLAN FOR
    2 SELECT COUNT(*) FROM test1 t
    3 WHERE EXISTS
    4      ( SELECT 'X'
    5      FROM ( SELECT id, date1
    6                FROM test1
    7           MINUS
    8           SELECT id, date1
    9                FROM test2
    10           ) i
    11      WHERE i.id = t.id
    12           AND i.date1 = t.date1
    13      );
    Explained.
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | 1 | 44 | 11 |
    | 1 | SORT AGGREGATE | | 1 | 44 | |
    |* 2 | HASH JOIN SEMI | | 1 | 44 | 11 |
    | 3 | TABLE ACCESS FULL | TEST1 | 409 | 8998 | 2 |
    | 4 | VIEW | | 20 | 440 | 8 |
    | 5 | MINUS | | | | |
    | 6 | SORT UNIQUE | | 20 | 440 | |
    |* 7 | TABLE ACCESS FULL| TEST1 | 20 | 440 | 2 |
    | 8 | SORT UNIQUE | | 1 | 22 | |
    |* 9 | TABLE ACCESS FULL| TEST2 | 1 | 22 | 2 |
    Predicate Information (identified by operation id):
    2 - access("I"."ID"="T"."ID" AND "I"."DATE1"="T"."DATE1")
    7 - filter("TEST1"."DATE1">TO_DATE(' 1960-01-01 00:00:00',
    'syyyy-mm-dd hh24:mi:ss'))
    9 - filter("TEST2"."DATE1">TO_DATE(' 1960-01-01 00:00:00',
    'syyyy-mm-dd hh24:mi:ss'))
    Note: cpu costing is off
    26 rows selected.
    ORA92080>

    Justin,
    Thanks for the reply. I have sent this test case to my DBA who may submit it to Metalink.
    Since I have found and implemented a workaround, I can wait for the next service release. I just thought that this might be of interest to other Oracle users.
    My work-around (buried near the end of my original post) was to modify all check constraints that fit the pattern:
    ( not_nullable_column condition IS TRUE )
    AND ( nullable_column condition IS TRUE )
    To:
    ( not_null_column condition IS TRUE )
    AND ( nullable_column condition IS TRUE OR nullable_column IS NULL )
    Redefining a check constraint in this way prevents it from being used in the optimizer's predicate.
    If someone at Oracle Support wanted to submit code that identifies such potential problem constraints in the data dictionary, that would be great too.
    - Doug

Maybe you are looking for