|
Hi,
I wanted to initialize a boolean to indicate the presence of at least one line in my table.
I compared these 2 statements in Visual Explain, as I was unsure which to use in my RPG program.
select '1' from sysibm.sysdummy1
where exists (select * from mytable where field1 = 'A' and
field2='000002')
select '1' from mytable where field1 = 'A' and field2='000002' fetch
first row only;
The second statement gives a much simpler graphic, but I suspect that all the records that satisfy the test are copied into a temporary table. I don't understand the image produced for the first example.
Also, in my example, as I have an LF with a key field1, field2 and with OMIT on another field. I'm getting the message from VE that indexes exist but can't be used. The statement is however, very rapidly executed. Could this be that VE isn't working properly?
I prefer the second statement purely for the reason that I don't like having to make references to sysdummy1. Although, obviously, that's not a very good reason!
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.