SQL is a great data accessing tool – in most cases

SQL is a very powerful tool, and probably at present the preferred method for accessing data. SQL has been continuously improved over the years, and many tests show that SQL – when selecting the optimal access method – often offers unparalleled efficiency. However, if SQL is used for all types of I/Os, the resulting performance will in some cases be worse. This article highlights the result of several tests that clearly indicate a common situation where SQL is not the optimal method and other options should be employed.

Commercial applications use on average 80 % of all resources on I/Os, and because QDBGETKY seems to be the most often found active program in the call stacks, I decided to test alternative ways of accessing one record by key. The only difference between the variations is the data access method. I ended up with 16 solutions where the programs using SQL topped the chart for least efficient. Each test run reads a customer data base ten million times using a generated “random” customer number as key.

The test environment used was a model 720 8202 E4D running under version 7.3, where the only other active application was our own automatic performance analysis software product GiAPA that assisted in documenting the results.

Since the data accessed remained in main memory during the tests there was no I/O wait time caused by physical reads from disks.

The SQL alternatives were tested both using a traditional DDS-defined file, an SQL defined table as input, and after creating an index allowing SQL to select the “Index only access method”. These additional changes resulted in less than two percent performance difference and are therefore not documented here.

When SQL performance is unsatisfactory, the typical comment from SQL gurus is that the application probably is designed incorrectly – and in most cases they are right. The exception is when records must be read one by one in a random sequence where the keys used for accessing do not origin from another file. The typical example is customers calling a support center, where it is unknown which customer is the next to call.

 Test Results: Keyed access of records one by one

The traditional – or old fashioned – way of accessing customer data in these cases is CHAIN operation code in #RPGLE or COBOL’s READ of a file defined with “Organization Indexed”. They perform equally well. The result from using RPG CHAIN is demonstrated in Test 1 in the below table.

Test 2 showed that a simple FETCH provides the best SQL performance, using 3.6 times more CPU and run time than RPG’s Chain. Test 3 was slightly slower despite selecting only the four wanted fields. Adding a PREPARE caused Test 4 to consume over five times the amount of resources used by RPG.

SQL’s poor performance in this case should not come as a surprise, since SQL was never intended for accessing records one by one. Each time SQL is called it will try to find the best access method to be used. This results in superior performance when a lot of data is accessed, but adds an overhead when fetching just one record.

Being interested in application performance I also want to highlight alternatives that are significantly more efficient than the standard read-by-key. Tests 5 and 6 used untraditional “access methods”, which appeared to be 4 to 6 times faster than RPG’s CHAIN, i.e. they outcompeted SQL by a factor between 14 and 22.

For test 5 the data needed – customer number being the key plus the wanted four rows – was loaded into a user index that is accessed instead of the standard Customer data base. This provides two significant advantages:

1.      CPU usage and run time is very much reduced.

2.      The data occupies less space in main memory.

The user index performance was four times better than the traditional read, and the solution makes a significant amount of main memory available for other jobs. Power i’s advanced storage management system keeps frequently used data in memory. However, if we access the Customer data base, the entire records/rows including all columns/fields not required for this operation must be kept in memory to avoid disk I/Os.

A user index is a permanent object that can be saved and restored. It can be accessed using IBM APIs however, the operation codes available through the C function library are more efficient. It is easy to use and we are happy to demonstrate how this powerful option is used: download https://www.giapa.com/usridxcode.zip containing a save file with a RPGLE source code demonstrating how to create, load, access and delete a user index.  

The user index must contain updated data and could be loaded before each use. If the table/file is accessed from many jobs, a better solution is to use a trigger program to update the user index whenever the data base is updated. In many cases updates to files/tables read hundreds of millions of times are very rare. E.g., a product data base is typically accessed by many applications, but prices, etc. are not adjusted every day.

One argument for using SQL for all I/Os is the fact that SQL allows the layout of a data base to be modified without the need for recompiling the programs using it. This is a true and valid argument, but not a show stopper, if we use SQL to access the data base when the user index is loaded.

Test 6 used a standard binary table lookup, where the fields/rows needed were loaded into a User Space. Compared with memory allocated within the program this has the advantage that it can be used simultaneously by many applications. It performed 38 % better compared to the user index. A drawback is that it is not easy to update while in use.

Test 7 was the absolute winner using a method which unfortunately cannot be applied very often. It requires that the program based on the key field(s) can compute a value that may be used to address each individual entry in the array containing the data needed. Here it worked wonders given the keys of our “customer data” were generated customer numbers increasing from 1 i.e., they could be used directly as index for the access. The resulting performance is incredibly fast – slightly more than three seconds elapsed to fetch 10.000.000 “records”.

Although the hash table cannot be used very often, its efficiency makes it worthwhile mentioning. We use it heavily in our software product analyzing application performance, and it is the main reason why our GiAPA software can collect performance data for all jobs and tasks running on a server – and still only use less than 0.1 percent CPU.

Is Optimization Worth the Effort?

Optimizing application performance is often thought to be a complex and time-consuming task requiring assistance from expensive external experts. It may be a challenge to pinpoint what to modify, but in most cases the required change is in fact minimal, because only one or a few statements need modification. This is also the case here, where only the keyed access is replaced whereas the main and possibly complex logic of the application remains untouched. The take-home message is to avoid using SQL when accessing a large number of records one-by-one. Instead, we recommend that you employ one of these suggestions – and if in doubt, please reach out for us to solve your current performance issue.

Power i performance hints by Kaare

iPerformance ApS, Denmark

[email protected]

#ibm #AS400 #iseries #ibmi #ibmpower #sql #giapa 

Brian, asked about my recent post on how easy it is to convert EBCDIC to ASCII using RPG IV. His question is: What about the other way around. If I get data into a field that is in ASCII CCSID how do I convert that to EBCDIC? Basically the premise is tha…

Brian, asked about my recent post on how easy it is to convert EBCDIC to ASCII using RPG IV. His question is: What about the other way around. If I get data into a field that is in ASCII CCSID how do I convert that to EBCDIC?
Basically the premise is tha…lnkd.in/gvHvpnj5

– SQL iQuery for #IBMi (aka Q38) (@sqliquery)05:51 – Feb 10, 2023

Great reasons to attend #ibmi #commonug #powerup2023 as well. Be there!

Great reasons to attend #ibmi #commonug #powerup2023 as well. Be there! twitter.com/tappehl/status…

– Dawn May (@DawnMayiCan)01:27 – Feb 10, 2023Quoted Tweet:

Let’s ask #ChatGPT why my boss should let me go to an IT conference, could be @CommonEurope congress in June for example. #ibmi #ibmpower #ibmaix #linuxonpower #ibmstorage #comeur2023 pic.twitter.com/5Jx6xEDbBO

– Torbjörn Appehl (@tappehl)23:12 – Feb 09, 2023

Let’s get it! Invite your friends #ibmi

Let’s get it! Invite your friends #ibmi twitter.com/code/status/16…

– Liam barry (@notesofbarry)11:33 – Feb 12, 2023Quoted Tweet:

📢 @notesofbarry is back on the #vscode livestream to demo the latest enhancements that make #IBMi access and education more accessible for everyone! Mark your 📅 and join us
🎬 aka.ms/code-livestrea… 8 am Seattle / 11 am New York / 4 pm London #COBOL #RPGLE pic.twitter.com/OE38EyiX3H

– Visual Studio Code (@code)11:31 – Feb 12, 2023

Thoroughly Modern: Flexible And Fractional Staffing Models That … – IT Jungle

Thoroughly Modern: Flexible And Fractional Staffing Models That Deliver

February 13, 2023

Christine McDowell

If you run an organization that relies on IBM i (AS/400, iSeries) systems, then you know how important it is to have the right skills and expertise accessible when you need them. The reality facing IT leaders is that having the right staff can be both a challenge and costly, but it doesn’t need to be.

By augmenting your teams with the right skills, you can get the help you need when you need it without needing to hire full-time staff. Let’s explore the benefits of augmenting your teams with IBM i (AS/400, iSeries) and other skills.

Integration Services

Integrating multiple systems isn’t something that happens overnight. It can be time consuming and difficult for teams who don’t have an understanding of the different systems or a specialty in integration services. By augmenting your team with experienced integration specialists, you can take advantage of their experience and knowledge to make sure your system is integrated quickly and correctly. This will save time and money in the long run by avoiding costly mistakes that could happen if inexperienced hands were in charge.

Web And Mobile Development Services

Having a website or mobile application that runs smoothly and looks great is essential for any business these days, but creating these applications from scratch requires skill, knowledge, and experience. By bringing in experts in web and mobile development services, you can ensure that your applications are built properly from the ground up so you don’t have to worry about them failing or looking unprofessional after launch.

In a recent webinar, attendees communicated with us that skills, time, and people were their most significant barriers to developing digital solutions. Attendees were able to select multiple options, and 41 percent said stakeholder/management buy-in, 67 percent said skill gaps, 59 percent said time, 46 percent said lack of strategy/roadmap, and 4 percent said they had other barriers.

Database And Application Modernization Services

Your database needs to be up-to-date if it’s going to remain secure and efficient. Not only do outdated databases put customer data at risk but they can also lead to slowdowns or even complete failures if they aren’t maintained regularly. With database and application modernization services, you can ensure that your databases are always running at peak efficiency so there are no unexpected problems down the line.

By augmenting your teams with IBM i skills, such as Integration Services, Web and Mobile Development Services, Database and Application Modernization Services, among other flexible fragmented engagements like developing new modern open source applications. You can ensure that any project requiring expert knowledge will go smoothly without having to invest too much into hiring full-time staff members who may not have all the necessary skillset required for certain projects. Additionally, using this approach gives organizations more flexibility when tackling projects by being able to access specific skills sets at specific times without committing long term resources or over spending on salaries for permanent employees.

Augmenting your teams with various IT and IBM i skills and experts can be an invaluable resource when it comes to application support services, help desk and other mundane tasks that are well suited for flexible and fragmented service engagements. With several different engagement models that exist, how do you determine which model is right for you or your project? Let’s take a look at the options.

Onshore Model

The onshore model is ideal for companies who prefer face-to-face contact with their IBM i (AS/400, iSeries) team members. This model tends to see better communication between all stakeholders in the project, which helps to ensure that everyone is on the same page throughout the entire process. Additionally, this model often makes for simpler integration of existing systems and processes into any new solutions being developed by the team.

Nearshore Model

The nearshore model typically involves working with offsite teams located in nearby countries or regions. This option offers competitive rates as well as access to a larger pool of skilled professionals than would be available through an onsite team. Additionally, since these teams are close by geographically, they may have more familiarity with local culture and customs – allowing them to better understand client requirements. Furthermore, communication is usually much easier with a nearshore team due to their geographical proximity.

Offshore Model

The offshore model offers cost-savings due to lower labor costs associated with overseas locations. Additionally, these teams offer access to a global talent pool that may not be available through other models – giving businesses access to some specialized skill sets not typically found locally or regionally. However, this model can come with certain challenges such as language barriers and cultural differences which make communication more difficult at times – so it’s important to plan accordingly when considering an offshore option.

Choosing the sourcing model that best suits you often comes down to preference. All three models (onshore, nearshore, and offshore) offer distinct advantages depending on the specific needs of your project; however all require planning and consideration before committing to any long-term engagements or partnerships. Ultimately though, if done correctly engaging IT and IBM i experts can help ensure that your application development projects run smoothly from start to finish!

We recently hosted an informative series about how IT executives are approaching IBM i in 2023. We discussed staffing and digital services, as well as IT strategy, cloud, and security. View all of the recordings here: https://hubs.ly/Q01B-V7K0.

Christine McDowell is vice president of corporate marketing and business development at Fresche Solutions. She started her career administering IBM midrange machines and is now a driving force in the world of IT. With over three decades of experience in the industry, Christine has a wealth of knowledge and insight that she brings to her role at Fresche. She is a strong leader with a proven track record of growth and is known for her ability to develop successful industry relationships. Above all, Christine is dedicated to ensuring customer success in everything she does at Fresche Solutions.

This content is sponsored by Fresche Solutions.

RELATED STORIES

Thoroughly Modern: How To Optimize IT In 2023

Thoroughly Modern: A Swiss Army Knife For IBM i Developers

Thoroughly Modern: Digital Solutions For IBM i And Beyond

Thoroughly Modern: Simplify IBM i Application Management and Extract Key Insights

Thoroughly Modern: Four Ways Staff Augmentation Is Helping IT Get Things Done

Thoroughly Modern: Bring Security, Speed, And Consistency To IT With Automation

Thoroughly Modern: Good Security Is Just As Important As Good Code

Thoroughly Modern: The Real Top 5 Challenges For IBM i Shops Today

Thoroughly Modern: Improving The Digital Experience With APIs

Thoroughly Modern: IBM i Security Is No Longer Set It And Forget It

Thoroughly Modern: Taking Charge of Your Hardware Refresh in 2022

Thoroughly Modern: Building Organizational Resilience in the Digital Age

Thoroughly Modern: Time To Develop Your IBM i HA/DR Plan For 2022

Thoroughly Modern: Infrastructure Challenges And Easing Into The Cloud

Thoroughly Modern: Talking IBM i System Management With Abacus

Fresche Buys Abacus To Integrate From IBM i To Cloud To Code

What IBM i Shops Want From Cloud, And How To Do It Right

A Chat With Steve Woodard, The New CEO At Fresche Solutions

Thoroughly Modern: Making The Case For Code And Database Transformation

Thoroughly Modern: Making Quick Wins Part Of Your Modernization Strategy

Thoroughly Modern: Augmenting Your Programming Today, Solving Staffing Issues Tomorrow

Thoroughly Modern: Clearing Up Some Cloud And IBM i Computing Myths

Thoroughly Modern: IBM i Web Development Trends To Watch In the Second Half

Thoroughly Modern: Innovative And Realistic Approaches To IBM i Modernization

Thoroughly Modern: Running CA 2E Applications? It’s Time To Modernize The UI

Thoroughly Modern: Understanding Your IBM i Web Application Needs With Application Discovery

Thoroughly Modern: What’s New With PHP On IBM i?

Thoroughly Modern: A Wealth Of Funding Options Makes It Easier To Take On Modernization

Thoroughly Modern: Speed Up Application Development With Automated Testing

Thoroughly Modern: The Smart Approach to Modernization – Know Before You Go!

Thoroughly Modern: Strategic Things to Consider With APIs and IBM i

Thoroughly Modern: Why You Need An IT Strategy And Roadmap

Thoroughly Modern: Top Five Reasons To Go Paperless With IBM i Forms

Thoroughly Modern: Quick Digital Transformation Wins With Web And Mobile IBM i Apps

Thoroughly Modern: Digital Modernization, But Not At Any Cost

Thoroughly Modern: Digital Transformation Is More Important Than Ever

Thoroughly Modern: Giving IBM i Developers A Helping Hand

Thoroughly Modern: Resizing Application Fields Presents Big Challenges

Thoroughly Modern: Taking The Pulse Of IBM i Developers

Thoroughly Modern: More Than Just A Pretty Face

Thoroughly Modern: Driving Your Synon Applications Forward

Thoroughly Modern: What To Pack For The Digital Transformation Journey

Talking Digital Transformation With The New And Prior CEO

Verified by MonsterInsights