Database Tuning (MOSC)

MOSC Banner

How to obtain the best peformance from Count Query?

edited Mar 27, 2009 3:56AM in Database Tuning (MOSC) 4 commentsAnswered ✓
I need a list count of customers that have been sent to salesforce.com (sf_id is not null),

have an address,

but do not have an address in salesforce (sf_id_customer is not null)

 

 

The query generated by the user is:

SELECT COUNT (1)

  FROM (SELECT *

          FROM address

         WHERE customer_id_fk NOT IN (SELECT customer_id_fk

                                        FROM address

                                       WHERE sf_id_customer IS NOT NULL)) sub1

 

This query maxes peformance on the server. 

address table row count = 175,342

sub1 sub query row count = 52,372

 

Execution Plan:

 

Plan
SELECT STATEMENT ALL_ROWS Cost : 549,252,690 Bytes : 13 Cardinality : 1 Cost : 549,252,690 Bytes : 13 Cardinality : 1
  6 SORT AGGREGATE

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center