PowerWire.eu

Independent IBM i, AIX and Linux news and tech tips for Europe and beyond

  • Home
  • News
  • Technical Articles
    • IBM i
    • AIX
    • Linux
    • VIOS
  • Subscribe
  • About Us
  • Contact Us
  • Advertise with PowerWire.eu

Should we strive to improve our code?

February 16, 2021 by Terry Bartlett 2 Comments

Last week, I was looking for “CPF2234 Invalid Password” messages, for a program I am writing. I assumed that I would find them in QSYSOPR, but there weren’t any.

So, I tried DSPLOG and there they were. “Oh no”, I hear you say, “Why are you using 5250 Green Screen?”. I will admit that I do, but less and less these days. I use SQL Services, now called “IBM i Services (SQL)”, and ACS “Run SQL Scripts” whenever I can. There is a good article by Andy Youens DB2 for i – Services.

Using QHST or sys2.history_log_info

As most people know there is a wonderful “Examples” section, in the “Edit” menu of ACS. I use that frequently as well. I entered “history” to search for relevant examples. I found one called “Message Handling – Abnormal IPL Predictor” and changed it to find CPF2234.

This seemed to take a long time, well 7 seconds seemed a long time seeing as the partition was IPLed 9 days before. The ACS messages tab showed that it took over 3 seconds to run.

I also like to create my programs to have the minimum performance impact that I can. I know nowadays that probably doesn’t matter as much as it used to, but I still believe it is like the dripping tap, each drop adds to a bucket full, over time.

Using QAUDJRN or qsys2.display_journal

As it happens there is a reference to the DISPLAY_JOURNAL table function in the HISTORY_LOG_INFO table function page. As you can guess, I decided to have a look. I changed the SQL example “Communications – Network Statistics Job Info (NETSTAT)”.

Comparison

Believe it or not this took 300 milliseconds to run. In order to prove this with some numbers, I ran the above statements with count(*) in the place of * and removed the WHERE clause / journal_entry_types => ‘PW’, to get the number of records SQL was looking through. Then I ran the original statements 6 times in a row. Here are the results.

                         Records           Min Time secs            Max Time secs

QHST             35,243                      3.208                           3.408

QAUD            148,571                       0.291                           0.391  

In case you are wondering whether the extra WITH clause adds to the execution time, I tried with and without and it seems to be about 100 Milliseconds fast with the extra clause, which surprised me.

I also changed the QHST statement to go back before the IPL.  It took over 10,000 Milliseconds to find 11 results, out of over 113,000 records.

My conclusions are:

  • Sometimes it is worth looking at alternatives, use ACS and SQL.
    As a little extra tinkering can make things a whole lot faster.
  • If you’re not using the Audit Journal then you should be.
    As it’s a valuable source of additional information.

i-UG goes Hybrid

We are returning to the Mount Hotel in Wolverhampton for another Hybrid event on the 18th March, we hope to see you there.
For more details check out  www.i-ug.co.uk

Filed Under: IBM i, Technical Articles Tagged With: IBM i, IBM Power System, Performance, SQL

Comments

  1. Steve Bradshaw says

    February 16, 2021 at 4:57 pm

    Great first article Tez, please write more.

    Reply
  2. Sam Dix says

    March 3, 2021 at 10:22 am

    Good Article Terry, thanks for sharing

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Free monthly newsletter signup

News

A screen a story – Not our problem anymore

Last week I ran into an issue, which did teach me something new about the command WRKPRB. After checking a … [Read More...]

Raspberry Pi and Machine Learning

In my last article, I demonstrated how I used Machine Learning on the Raspberry Pi to determine if a … [Read More...]

Shield Advanced Solutions – new Messaging and Monitoring solutions

September 2022 – Toronto As Shield Advanced Solutions celebrates the significant milestone, 25 years of … [Read More...]

More articles from this section

Quick Links

  • Advertise
  • Subscribe

Follow Us…

  • Email
  • LinkedIn
  • Twitter

Search This Website

Copyright © 2023 · Cue Communications · All Rights Reserved

Log in