Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

better cardinality for predicate having is null

spur230Nov 2 2015 — edited Nov 5 2015

I  am using Oracle 11.2.0.3.   I  have a query similar to the one given below. It's estimated cardinality is  3 times off from actual.  I tried to create extended statistics but it is not helping. 

Can't extended statistics be used  on columns  handling is null?

Is there any way to improve cardinality for this cases.

I have created random data in tmp.

col1 can have values  1 and 2.

col 2 can have values 1 and 2.

col3 is date and it is null mostly when  col1=1 and col2=1

I want to get good estimate for query (select * from tmp where col1=1 and col2 =1 and col3 is null)

drop table tmp;

create table tmp ( col1 number, col2 number, col3 date);

insert  into tmp

select 1 ,1 ,sysdate from dual

union all

select 1, 2, sysdate  from dual

union all

select 1 ,1 ,NUll  from dual

union all

select 1, 1, NULL  from dual

union all

select 1, 1, sysdate  from dual

union all

select 2, 2, sysdate  from dual

union all

select 1, 1, NULL  from dual

exec DBMS_STATS.GATHER_TABLE_STATS( user, 'TMP' , method_opt => 'FOR ALL COLUMNS ');

select  count(*) from tmp where col1=1 and col2 =1 and col3 is null ;

-- gives 3 estimate is only 1

Plan hash value: 3231217655

----------------------------------------------------------------------------

| Id  | Operation          | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time   |

----------------------------------------------------------------------------

|   0 | SELECT STATEMENT   |      |        |       |     4 (100)|          |

|   1 |  SORT AGGREGATE    |      |      1 |    11 |            |          |

|*  2 |   TABLE ACCESS FULL| TMP  |      1 |    11 |     4   (0)| 00:00:01 |

----------------------------------------------------------------------------

select dbms_stats.CREATE_EXTENDED_STATS ( user, 'TMP','(col1,col2,col3)') from dual;

exec DBMS_STATS.GATHER_TABLE_STATS(user, 'TMP', method_opt => 'for columns (col1,col2,col3) ' , degree=> 16 , estimate_percent => null);

select  count(*) from tmp where col1=1 and col2 =1 and col3 is null;

-- gives 3 estimate is only 1

This post has been answered by Jonathan Lewis on Nov 5 2015
Jump to Answer

Comments

unknown-7404
Answer

It looks like in Java it is preferred to have the connection pool set up on the server (tomcat).

Not quite - the connection pool (and any other Java code) will be 'set up' within the JVM instance. That will be on whatever machine you execute 'java.exe' on.

So my question is if I deployed 5 distinct applications on to a tomcat web server each (referencing their own UCP java and OJDBC jar) when the application's startup, do each application create its own separate connection pool?

See my first comment above.

1. you use 'java.exe' to create a JVM - a JVM is a container - it does NOT interact with anything outside that container unless you write code to do so.

2. you run ONE APPLICATION on that JVM

3. that application can create as many connection pools as it wants in that JVM

4. that application can be multi-threaded so each thread can do whatever it wants/needs to do including creating pools (see #3)

5. multiple applications launch their own JVMs running a single app so for each app just go back and see #2, #3 and #4

Marked as Answer by mlov83 · Sep 27 2020
mlov83

Thanks for the response RP0428, that makes a ton of sense, just to make sure I understand in Tomcat I wouldn't execute a java.exe are you referring to .net in your above reply? follow up question, do you think tomcat would do the same? The reason I ask is because I've been reading a lot about class loaders and how if I have to projects with the same exact class names they will clash. Sorry , If I'm confusing apples and oranges here, I'm just trying to be thorough and make sure I understand.

unknown-7404

Tomcat is launching the JVM and creating multi-threaded 'apps' within it. Each of those 'apps' can have its own connection pool and there won't be any crosstalk/access between the apps.

1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 3 2015
Added on Nov 2 2015
9 comments
3,720 views