Blog
iDevelop

« A Letter to Larry | Main | Susan's Adventures in Mac-land »

July 06, 2011

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83545a5d153ef01543383ee8e970c

Listed below are links to weblogs that reference Jon and Susan Get Educated:

Comments

Re CHAIN vs SELECT:
That's great news, although I doubt SQL could beat a CHAIN, a tie would be good enough for me. Did he mention if that applied to specific releases? I'm one of those (many) on the trailing edge when it comes to OS version.

Two comments.
1) We've used the date table approach for years and I love it. We need a table for fiscal periods anyway and we have several variations of the date form (verbose, short & long julian, etc) in there too.
2) Laughed out loud at the comment on "SQL is the answer.....". Had a programmer a few years ago who was a "Jim Jones" type of believer in that philosophy. Ugh....

I ran my own little CHAIN vs SELECT test, and the results were not good for SELECT.

I used the same uniquely-keyed, DDS-described PF in SQLRPGLE under v5r4. I measured the elapsed time with RPGLE TIMESTAMP fields. A CHAIN using all the key fields registered 0.000000s. A SELECT INTO using all the key fields in the WHERE clause took 0.500000s (yes, 1/2 second).

I'll be sticking with CHAIN for now.

Just finished reading the article in EXTRA and found the performance test in 'Existence Testing via SQL' well covered. Since our shop is moving away from native I/O, I am always looking for SQL alternatives to boost performance. Thank you for providing several options.

Here is yet another approach:
Exec SQL
With ROWS as
(Select Count(*) as RowCount
from OrderNum where Order_Num = :charKey)
Select '1' into :ValidRow
from ROWS where RowCount=1;

One tip for performance, use "FETCH FIRST ROW ONLY" at the end of your statement. This prevents the SQL processor from looking for additional records, when you're really only looking for one.

Also, for performance reasons, I think you should avoid use the SELECT INTO command in a loop where it will be hit so many times. Its better to build it into whatever data set you're reading through to compare. A subselect with a FETCH FIRST ROW ONLY is pretty powerful.

Jon and Susan - a good series of articles.

As a Manufacturing firm that's used the calendar table concept since the System/38, I'd be tempted to say we invented it but I'm sure others would challenge that assertion. We used our calender due to the 4-4-5 accounting year the company adopted. Each quarter had 13-weeks with all months ending on a Saturday and the last month of the quarter having 5-weeks. That extra week helped our monthly shipping plan! We were able to lookup accounting Year, Quarter, Month for any date as well as working and non-working days and day names. We'd publish the calendar, first on green screen or IPDS printers and later as a web page. A revision to the very same calendar also contained the date in native date format, when that became available in OS/400, helping us to remediate the "Y2K problem" very effectively.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.