dbTalk Databases Forums  

help tuning query

comp.databases.informix comp.databases.informix


Discuss help tuning query in the comp.databases.informix forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Floyd Wellershaus
 
Posts: n/a

Default help tuning query - 05-21-2010 , 05:02 AM






I've tried and can't get it any significantly faster.
I've tried with a composite index on first_name,last_name,street1 and birth_dt, which prevents a scan of the first subquery, and I've tried without it. Either way it's about the same.
I've tried using hash joins and without. About the same. Maybe a little quicker with hash.
Looks like they are searching for duplicates in the table, joining on itself.
Is there any ideas from those really good at sql ? Any obvious flaws ?
The query used to work ok when they first made it, but some of these semi-permanent submission tables get big, and the query takes 3-4 minutes.

Any help would be appreciated.

Thank you !
Floyd

Here is the explain plan.

QUERY:
------
SELECT {+USE_HASH (s701362/build)} t1.token AS __token,
t1.first_name AS firstName,
t1.initial as middleInitial,
t1.last_name as lastName,
substr(t1.street1,1,8) as streetAddress,
t1.birth_dt as dateOfBirth
FROM s701362 AS t1
WHERE 1 = (SELECT {+USE_HASH (s701362/build)} Count(*) FROM s701362 AS t2 WHERE NVL(UPPER(t1.first_name),'') =
NVL(UPPER(t2.first_name),'')

AND NVL(UPPER(t1.last_name),'') = NVL(UPPER(t2.last_name),'')
AND NVL(UPPER(t1.initial),'')= NVL(UPPER(t1.initial),'')
AND NVL(UPPER(substr(t1.street1,1,8)),'')=NVL(UPPER(su bstr(t2.street1,1,8)),'')
AND NVL(t1.birth_dt,'')=NVL(t2.birth_dt,''))
AND t1.token in (select __token token from s701362_er t1 where t1.warn_id='86')
--AND t1.token in (select __token token from s701362_er where warn_id='86')


DIRECTIVES FOLLOWED:
USE_HASH ( s701362/BUILD )
DIRECTIVES NOT FOLLOWED:

Estimated Cost: 2147483647
Estimated # of Rows Returned: 5856

1) root.t1: INDEX PATH

Filters: >;subquery;subquery

Reply With Quote
  #2  
Old   
thebp
 
Posts: n/a

Default Re: help tuning query - 05-21-2010 , 05:58 AM






On 21/05/2010 11:02, Floyd Wellershaus wrote:
Quote:
I've tried and can't get it any significantly faster.
I've tried with a composite index on first_name,last_name,street1 and
birth_dt, which prevents a scan of the first subquery, and I've tried
without it. Either way it's about the same.
I've tried using hash joins and without. About the same. Maybe a little
quicker with hash.
Looks like they are searching for duplicates in the table, joining on
itself.
Is there any ideas from those really good at sql ? Any obvious flaws ?
The query used to work ok when they first made it, but some of these
semi-permanent submission tables get big, and the query takes 3-4 minutes.

Any help would be appreciated.

Thank you !
Floyd

Here is the explain plan.

QUERY:
------
SELECT {+USE_HASH (s701362/build)} t1.token AS __token,
t1.first_name AS firstName,
t1.initial as middleInitial,
t1.last_name as lastName,
substr(t1.street1,1,8) as streetAddress,
t1.birth_dt as dateOfBirth
FROM s701362 AS t1
WHERE 1 = (SELECT {+USE_HASH (s701362/build)} Count(*) FROM s701362 AS
t2 WHERE NVL(UPPER(t1.first_name),'') =
NVL(UPPER(t2.first_name),'')

AND NVL(UPPER(t1.last_name),'') = NVL(UPPER(t2.last_name),'')
AND NVL(UPPER(t1.initial),'')= NVL(UPPER(t1.initial),'')
AND
NVL(UPPER(substr(t1.street1,1,8)),'')=NVL(UPPER(su bstr(t2.street1,1,8)),'')
AND NVL(t1.birth_dt,'')=NVL(t2.birth_dt,''))
AND t1.token in (select __token token from s701362_er t1 where
t1.warn_id='86')
--AND t1.token in (select __token token from s701362_er where warn_id='86')


DIRECTIVES FOLLOWED:
USE_HASH ( s701362/BUILD )
DIRECTIVES NOT FOLLOWED:

Estimated Cost: 2147483647
Estimated # of Rows Returned: 5856

1) root.t1: INDEX PATH

Filters: <subquery> = 1

(1) Index Keys: token (Serial, fragments: ALL)
Lower Index Filter: root.t1.token = ANY <subquery

Subquery:
---------
DIRECTIVES FOLLOWED:
USE_HASH ( s701362/BUILD )
DIRECTIVES NOT FOLLOWED:

Estimated Cost: 110480
Estimated # of Rows Returned: 1

1) root.t2: SEQUENTIAL SCAN

Filters: ((((NVL (root.t2.birth_dt , '' ) = NVL (root.t1.birth_dt , '' )
AND NVL (UPPER(SUBSTR (root.t2
.street1 , 1 , 8 ) ) , '' ) = NVL (UPPER(SUBSTR (root.t1.street1 , 1 , 8
) ) , '' ) ) AND NVL (UPPER(root.t2.last_n
ame ) , '' ) = NVL (UPPER(root.t1.last_name ) , '' ) ) AND NVL
(UPPER(root.t2.first_name ) , '' ) = NVL (UPPER(root
.t1.first_name ) , '' ) ) AND NVL (UPPER(root.t1.initial ) , '' ) = NVL
(UPPER(root.t1.initial ) , '' ) )


Subquery:
---------
Estimated Cost: 187994
Estimated # of Rows Returned: 556267



1) root.t1: INDEX PATH

(1) Index Keys: __token warn_id (Key-Only) (Serial, fragments: ALL)
Index Key Filters: (root.t1.warn_id = 86 )
Hi,

Check out the cost :

2147483647 = 0x7FFFFFFF => Sign of an optimizer overflow :/

Version and O/S?

What statistics on the table(s)?

Reply With Quote
  #3  
Old   
Floyd Wellershaus
 
Posts: n/a

Default Re: help tuning query - 05-21-2010 , 07:16 AM



Never heard of an optimizer overflow. This is IDS10.0FC5 on Aix 5.3.
an update stats high on the table was just done.

Thanks,
floyd




----- Original Message -----
From: bigpotato (AT) usenet-news (DOT) net
Sent: Fri, May 21, 2010, 7:00 AM
Subject: Re: help tuning query

On 21/05/2010 11:02, Floyd Wellershaus wrote:

Reply With Quote
  #4  
Old   
Floyd Wellershaus
 
Posts: n/a

Default Re: help tuning query - 05-21-2010 , 08:05 AM



Excellent point Obnoxio.
I did this. It runs much qucker ( like only 28 seconds as opposed to 7 minutes ) because it's doing a dynamic hash join
It seems to provide the same info, however in a different order. Not sure if it's really the same query anymore.

SELECT
t1.token as __token,
t1.first_name AS firstName,
t1.initial as middleInitial,
t1.last_name as lastName,
substr(t1.street1,1,8) as streetAddress,
t1.birth_dt as dateOfBirth

FROM s701362 t1,s701362 t2 WHERE NVL(UPPER(t1.first_name),'') = NVL(UPPER(t2.first_name),'')

AND NVL(UPPER(t1.last_name),'') = NVL(UPPER(t2.last_name),'')
AND NVL(UPPER(t1.initial),'')= NVL(UPPER(t1.initial),'')
AND NVL(UPPER(substr(t1.street1,1,8)),'')=NVL(UPPER(su bstr(t2.street1,1,8)),'')
AND NVL(t1.birth_dt,'')=NVL(t2.birth_dt,'')
AND t1.token in (select __token token from s701362_er t1 where t1.warn_id='86')





----- Original Message -----
From: obnoxio (AT) serendipita (DOT) com
Sent: Fri, May 21, 2010, 7:00 AM
Subject: Re: help tuning query

Floyd Wellershaus wrote:

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.