dbTalk Databases Forums  

[Info-Ingres] char() + char() AND NOT IN vs outer join

comp.databases.ingres comp.databases.ingres


Discuss [Info-Ingres] char() + char() AND NOT IN vs outer join in the comp.databases.ingres forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Martin Bowes
 
Posts: n/a

Default [Info-Ingres] char() + char() AND NOT IN vs outer join - 11-05-2009 , 08:16 AM






Hi All,



The following query runs in 7 hours:

insert into lab_result(

sample_id, test_id, result, when_analysed, status, participant_id,
visit_id

)

select sample_id, test_id, result, when_analysed, status,
participant_id, visit_id

from session.temp_lab_result

where char(sample_id) +'-' +char(test_id) not in(select char(sample_id)
+'-' +char(test_id)from lab_result)



And this runs in 7 seconds...



insert into lab_result(

sample_id, test_id, result, when_analysed, status,
participant_id, visit_id

)

select t.sample_id, t.test_id, t.result, t.when_analysed, t.status,
t.participant_id, t.visit_id

from session.temp_lab_result t left outer join lab_result l on
t.sample_id=l.sample_id and t.test_id=l.test_id

where l.sample_id is null and l.test_id is null



I'm sure the resulting rows are the same or have I done something
massively bone headed?



Martin Bowes

Reply With Quote
  #2  
Old   
Karl Schendel
 
Posts: n/a

Default Re: [Info-Ingres] char() + char() AND NOT IN vs outer join - 11-05-2009 , 08:27 AM






On Nov 5, 2009, at 9:16 AM, Martin Bowes wrote:

Quote:
Hi All,

The following query runs in 7 hours:
insert into lab_result(
sample_id, test_id, result, when_analysed, status,
participant_id, visit_id
)
select sample_id, test_id, result, when_analysed, status,
participant_id, visit_id
from session.temp_lab_result
where char(sample_id) +'-' +char(test_id) not in(select char
(sample_id) +'-' +char(test_id)from lab_result)
Are any of these columns nullable? Sounds like you're getting an SE-
join,
and the most likely explanation is a nullable column gumming up the
works.

I don't know if the char+char expression would inhibit the notin to
outer-join
transform, but at least I would expect the old style quel-like
flattening
with ANY. It can't even do that if the inner is nullable, though.

Karl

Reply With Quote
  #3  
Old   
Martin Bowes
 
Posts: n/a

Default Re: [Info-Ingres] char() + char() AND NOT IN vs outer join - 11-05-2009 , 08:54 AM



Hi Karl,

Bingo on nulls and SE join!

The session temporary was created with nullable columns, the main table
uses non-nullable columns.

Once I corrected the session temp table to use non nullable columns the
original query with char() and not in was morpehed into right join/Hash
join and completed in much the same time as the specific ouer join case.

Marty

-----Original Message-----
From: info-ingres-bounces (AT) kettleriver...ting (DOT) com
[mailto:info-ingres-bounces (AT) kettleriverconsulting (DOT) com] On Behalf Of Karl
Schendel
Sent: 05 November 2009 14:28
To: Ingres and related product discussion forum
Subject: Re: [Info-Ingres] char() + char() AND NOT IN vs outer join


On Nov 5, 2009, at 9:16 AM, Martin Bowes wrote:

Quote:
Hi All,

The following query runs in 7 hours:
insert into lab_result(
sample_id, test_id, result, when_analysed, status,
participant_id, visit_id
)
select sample_id, test_id, result, when_analysed, status,
participant_id, visit_id
from session.temp_lab_result
where char(sample_id) +'-' +char(test_id) not in(select char
(sample_id) +'-' +char(test_id)from lab_result)
Are any of these columns nullable? Sounds like you're getting an SE-
join,
and the most likely explanation is a nullable column gumming up the
works.

I don't know if the char+char expression would inhibit the notin to
outer-join
transform, but at least I would expect the old style quel-like
flattening
with ANY. It can't even do that if the inner is nullable, though.

Karl


_______________________________________________
Info-Ingres mailing list
Info-Ingres (AT) kettleriverconsulting (DOT) com
http://ext-cando.kettleriverconsulti...fo/info-ingres

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.