× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I'm no SQL guru, but at first blush, the first statement looks more
efficient since it is more like to allow the optimizer to use access paths.

It would use an access path to find WRITE and READ records, another access
path to find SCREEN-REC and SCREEN-FILE records, and use regular set
processing on the subsets to arrive at your result.

The second statement looks like the optimizer would need to join everything
together THEN figure out is WRITE/SCREEN-REC/join true or
WRITE/SCREEN-FILE/join true? It might be trying a cartesian join.

These statements don't really do the same thing. For instance, is it
possible to have a READ and SCREEN-REC record, or a WRITE and SCREEN-FILE
records? It is possible you could see these in the first statement. The
second statement is much more explicit in stating what the join conditions
are; there will never be a WRITE and SCREEN-FILE record, for instance.

HTH,
Loyd

-----Original Message-----
From: Joe Pluta [mailto:joepluta@PlutaBrothers.com]
Sent: Tuesday, October 29, 2002 9:56 AM
To: midrange-l@midrange.com
Subject: RE: Spool file journalling


Here's why I have problems with SQL.  Take a look at the following
statements:

select * from sccc1 a, sccc1 b
 where a.c1flag3 = 'V' and
 a.c1source in ('WRITE', 'READ')
 and a.c1kwid = b.c1prnt
 and b.c1source in ('SCREEN-REC', 'SCREEN-FILE')

select * from sccc1 a, sccc1 b
 where a.c1flag3 = 'V' and
 ((a.c1source = 'WRITE'
   and a.c1kwid = b.c1prnt
   and b.c1source = 'SCREEN-REC') or
 (a.c1source = 'READ'
   and a.c1kwid = b.c1prnt
   and b.c1source = 'SCREEN-FILE'))

Both are trying to do the same thing - use a COBOL cross-reference to
determine READs and WRITEs to a workstation.  READs use the file name,
WRITEs use the record name.  The references to "c1kwid/c1prnt", which are
the same in both queries, are used to make sure the cross-reference lines
are related.

The first one, which is a little more inclusive (it would include READs on
the record and WRITEs to the file) runs in milliseconds.  The second one I
fired off and it chewed up 73% of my machine for over 30 seconds before I
shut it down.  (Eventually CFINT kicks in and grinds the thing to a halt,
even though it's the only job on the machine.)

My observation has several parts:

1. Would any of the SQL gurus like to point out any serious problems in my
syntax?  Are there better ways to do this?

2. I looked at the joblog under debug to determine the access paths, and
while the optimizer recommends I create a logical over C1SOURCE, the two
statements use the exact same paths.

3. Why would what seems like a pretty simple syntax change cause such
drastic difference in response time?


=======UPDATE=========

By adding the logical over C1SOURCE as the optimizer suggested, the second
runtime dropped to milliseconds.  Evidently, the second syntax somehow
causes the index to be rebuilt over and over again.

Joe


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.