How to obtain the best peformance from Count Query?
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 |