Hi Roy,
With appropriate uniqueness constraints in place, the flattening becomes
safe as the cardinality is then assured.
Agreed about SEjoins, I'm looking at addressing some of that to make
these checks doable on better joins.
Regards,
Ian
-----Original Message-----
From: info-ingres-bounces (AT) kettleriver...ting (DOT) com
[mailto:info-ingres-bounces (AT) kettleriverconsulting (DOT) com] On Behalf Of Roy
Hann
Sent: 23 September 2009 09:38
To: info-ingres (AT) kettleriverconsulting (DOT) com
Subject: Re: [Info-Ingres] Wrong results from query flattening
Ian Kirkham wrote:
Quote:
Hi Roy,
Yes it can. The usual case would be where a sub-select returned more
than 0 or 1 rows - in that case the cardinality of the main join is
violated. In this scenario, setting noflatten would see execution
trigger a cardinality error. Presently, you would only see this with
SEjoins. |
So if you write WHERE partnr = ( SELECT partnr ... ) intending the
subquery to be a scalar subquery, and it turns out it's not, flattening
causes the "=" to be silently treated as "IN"? So the result isn't
wrong exactly, it's just that a database design/declaration error goes
undetected (unless you coded only for the singleton query you were
expecting).
I can't say that is good behaviour, but I don't think I could recommend
always turning off flattening so as to be sure of never encountering
this provblem. SE-joins are hideously expensive. Maybe I could get
behind turning off flattening during testing, to provoke a detectable
error.
Actually, I now see why the person I was talking to was getting so
excited about this. If you routinely use cursors and assume you can
safely do just a single FETCH you will never know you have a problem. I
HATE cursors and will do almost anything to avoid them (until
the last possible moment). So I would never have this problem. Well done
me.
(http://www.rationalcommerce.com/imag...-mug-other.jpg)
--
Roy
UK Ingres User Association Conference 2010 will be on Tuesday June 8
2010
Go to http://www.iua.org.uk/join to get on the mailing list.
_______________________________________________
Info-Ingres mailing list
Info-Ingres (AT) kettleriverconsulting (DOT) com
http://www.kettleriverconsulting.com...fo/info-ingres