Fintech News | Fintech Zoom
  • Banking
    • Banks
      • Chase Online
      • Bank of America
    • Rates
      • 6% cd rates – It Exists ?
    • Payment Systems
    • Send Money
      • Send Money Online
      • Transfer Money Online
      • Best App To Send Money Online
    • Mobile Banking
    • Top Fintech Companies
      • Mastercard News
      • Monzo News
      • Stripe News
    • Best Of
      • Best Online Banks of 2020
      • Digital Bank
      • Best Bank for Home Loans 2020
      • Best Bank Interest Rates March 2020
      • Best Online Savings Accounts of February 2020
      • Best Online Savings Accounts of February 2020
      • Best Money Market Accounts of 2020
      • Best Online Checking Accounts of 2020
      • Best Bank Promotions and Bonuses 2020
      • Best CD Rates of 2020
      • Best Money Market Accounts of 2020
      • Best Bank for FHA Loan of 2020
    • KYC
      • Best KYC Solutions 2020
      • KYC Verification: How it is Done?
  • Betting
    • Gambling
    • Online Casinos
    • Sporting Odds
      • How to Read Odds: NBA Odds
  • Credit Cards
    • Cards
      • American Express
      • Lowe’s Credit Card
    • Best Of
      • Best Credit Cards
      • The Best Credit Card for Balance Transfers 2020
      • Best Buy Credit Card 2020
      • Best hotel credit cards for 2020
      • Best Gas Rewards Credit Cards of 2020
      • Best Rewards Credit Card 2020
      • Best Credit Cards for Students 2020
      • Best Airline Credit Card 2020
      • Best Business Credit Cards 2020
      • Best Cash Back Credit Cards 2020
      • Capital One Credit Card – Best Cards of 2020
      • Best hotel credit cards for 2020
      • Best Gas Rewards Credit Cards of 2020
      • Best Rewards Credit Card 2020
      • Best Secured Credit Cards 2020
      • Best No Annual Fee Credit Cards 2020
      • Best Credit Cards for Bad Credit 2020
      • Best Secured Credit Cards 2020
      • Best 0% APR Credit Cards of February 2020
      • Best Travel Credit Card 2020
    • Reviews
      • Home Depot Credit Card
      • Apple Credit Card Review
      • Walmart Money Card – Review
      • Wells Fargo Propel – Review
      • Travel credit card reviews 2020
      • Petal Credit Card Review
      • Amazon Credit Card Review
      • Credit One Credit Card Review
      • First Premier Credit Card Review
      • Fortiva Credit Card Review
      • Indigo Credit Card Review
      • Discover it® Cash Back – Review
    • Guides
      • Caliber Home Loans
      • Is Discover Visa or Mastercard?
  • Crypto
    • Reviews – Trading Platforms
      • Prime XBT
    • Bitcoin
      • Bitcoin Hoje
      • Mercado Bitcoin
      • Bitcoin Price
        • Bitcoin Price
        • Price of Bitcoin
        • Bitcoin Price Live
        • BTC to USD
        • Bitcoin Price Prediction
        • Bitcoin Price USD
        • Bitcoin Price Live Ticker
      • Buy Bitcoin
        • Without ID Verification
          • Buy Bitcoin Anonymously
          • Buy Bitcoin Without ID
        • by Paypal
          • Buy Bitcoin Through Paypal
          • Buy Bitcoin with Paypal
        • ATM
          • Buy Bitcoin ATM
          • Buy Bitcoin Near Me
        • with Credit Card
          • Buy Bitcoin with credit card
          • Buy Bitcoin with Credit Card
          • Buy Bitcoin with Prepaid Card
        • Buy Bitcoin at Walmart
        • Buy Bitcoin Cash
        • Buy and Sell Bitcoin
        • Buy Bitcoin With Gift Card
      • Best Of
        • 23 Best Place to Buy Bitcoin Online 2020
        • Buy Bitcoin: Best Ways to Buy BTC Instantly
        • Best Bitcoin Sports Betting Sites 2020
        • Bitcoin Betting
      • Guides
        • Bitcoin ATM near me
        • Bitcoin Price
          • Bitcoin Price Guide
          • Bitcoin BTC Price
          • Bitcoin Price Prediction
        • How to Buy Bitcoin
        • How to Mine Bitcoin on PC
        • What can you Buy with Bitcoin?
        • Where to buy Bitcoin?
        • Bitcoin
        • What can you Buy with Bitcoin?
        • Easiest Way to Buy Bitcoin
        • Bitcoin Halving
        • Where to buy Bitcoin?
        • How Long does it Take to Mine 1 Bitcoin?
      • Calculator
        • BTC to USD Converter
        • Bitcoin Preev
      • Latest News
        • Bitcoin News
        • Latest News
        • Current Bitcoin News
    • Ethereum
      • Ethereum
      • Ethereum Worth
      • Ethereum News
    • Ripple
      • Ripple Chart Live
        • Ripple
      • Ripple News
      • Ripple Price
    • Litecoin
      • Litecoin Price
    • Dogecoin
      • Dogecoin Price
    • Best Of
      • Crypto Exchanges
        • Best Cryptocurrency Exchanges | April 2020
        • Best Cryptocurrency Exchange
      • Wallets
        • Best Crypto Wallets
        • Best Crypto Wallets 2020
        • Best Crypto Hardware Wallets
        • Best Crypto Hardware Wallets of 2020
      • Best Crypto to Invest in
      • Best Crypto Trading Bot
      • Greatest Cryptocurrency Tax Software program 2020
    • ICO
      • Prime ICO Advertising and marketing Companies
      • Best ICO listing sites
    • Market
      • Binance
      • Coinbase
    • Latest News
      • Crypto Exchange News
      • Cryptocurrency News
      • Facebook Libra
  • Investing
    • Netflix Stock
    • Roku Stock
    • AT&T
    • American Airlines
    • Stocks
      • Marijuana Stocks
      • Dow Jones
      • Large-Cap
        • Boeing Stock
        • Tesla
          • Tesla Stock
          • Tesla Stock Price
        • Apple Stock
        • Disney
          • Royal Caribbean
          • United Airlines
          • Southwest Airlines
          • Spotify
        • NIO Stock
        • Amazon
          • Amazon Pay
          • Amazon
        • PayPal Stock Price
        • General Electric Stock Price
        • Square Stock
        • Facebook Stock – FB Stock
        • Frontier Airlines
          • Frontier Airlines
        • Bank of America Stock
      • Best Of
        • Best Fintech Stocks 2020
        • Best Dividend Stocks
        • Best Stock Trading Apps of 2020
        • Best Forex Brokers 2020
        • Best Online Brokers for Beginners 2020
        • Best Brokers for ETFs Investing
        • Best Online Brokers for Stock Trading 2020
      • Guides
        • Stocks in Market: Consider Investing These 2 Stocks
        • How to buy stocks?
    • Money
      • How to Create a Budget
      • How to Invest Money
      • How to Make Money Online
      • How to Make Money with Bitcoin
      • How To Save Money
      • How to Track Expenses
    • Gold
      • Best Place to Buy Gold
      • Gold Price Chart
      • Buy Gold
      • Price of Gold
    • Oil
      • Oil Price – WTI Crude Oil
  • Insurance
    • Best Of
      • The Best Renters Insurance Companies 2020
      • Best Life Insurance of 2020
      • Best Pet Insurance Providers of 2020
      • Best Homeowners Insurance Companies of 2020
      • Best Car Insurance Quotes Online
      • Best Home Insurance Companies for 2020
    • Insurtech
  • LifeStyle
    • Real Estate
      • Aston Martin Residences
    • Luxury Apartments
      • The Best Miami Luxury Homes
    • Luxury Cars
      • Best Luxury Sports Car
      • Best Luxury SUVs for 2020
      • Best Electric Cars
      • Best Luxury Cars
      • Best Time to Buy a Car
      • Porsche
    • Luxury Watches
      • Most Expensive Watches
    • Luxury Retreats
      • Best Luxury Yoga Retreats
    • Luxury Brands
      • Best Luxury Clothing Brands
  • Loans
    • Quicken Loans
    • Tesco Loans
    • Rocket Loans
    • Sunny Loans
    • Discover Student Loans
    • Merrill Lynch Benefits
    • Guides
      • Loans
      • Online Loans
      • Payday Loans
      • Bad Credit Loans Guaranteed Approval
      • Personal loans
      • Bad Credit Loans
      • Students
        • Great Lakes Students Loans
        • Wells Fargo Student Loans
        • AES Student Loans
        • Fafsa deadline
    • Best Of
      • Best Student Loan Refinance of 2020
      • Bad Credit Loans Guaranteed Approval
      • Best Loan for Students
      • Best Online Loans for Bad Credit 2020
      • Best Personal Loans of 2020
      • Best payday loans 2020
      • Best Business Loan Lenders of 2020
      • Best Auto Loan Rates for 2020
    • Calculators
      • Loan Calculator
      • FHA loan calculator
      • VA Loan Calculator
      • Student Loan Calculator
      • Personal Loan Calculator
      • Auto Loan Calculator
      • Boat Loan Calculator
  • Mortgages
    • Roundpoint Mortgage
    • Calculators
      • Mortgage Calculator
      • Simple Mortgage Calculator
    • Best Of
      • Best Mortgage Rates
      • Greatest On-line Mortgage Lenders
      • Best Mortgage for Low Down Payment 2020
      • The Best Mortgage Lenders for First Time Home Buyers
      • Best VA Mortgage Lenders of 2020
  • Promotions & Bonus
    • Get Avios Points Free
    • P2P Crowdlending – Average Interest Rate 18%
    • Get Revolut Card + £50
    • Coupons – Best websites
  • Politics
    • Joe Biden
    • Donald Trump
  • About Us
    • Contact
    • Fintech Zoom
    • Ask for Proposal
    • Who Reads Fintech Zoom?
    • Opinion
    • Press Release – Submit
    • Why Fintech Zoom?
    • Crypto Advisory
    • Best Fintech Companies to Work for 2020
No Result
View All Result
  • Banking
    • Banks
      • Chase Online
      • Bank of America
    • Rates
      • 6% cd rates – It Exists ?
    • Payment Systems
    • Send Money
      • Send Money Online
      • Transfer Money Online
      • Best App To Send Money Online
    • Mobile Banking
    • Top Fintech Companies
      • Mastercard News
      • Monzo News
      • Stripe News
    • Best Of
      • Best Online Banks of 2020
      • Digital Bank
      • Best Bank for Home Loans 2020
      • Best Bank Interest Rates March 2020
      • Best Online Savings Accounts of February 2020
      • Best Online Savings Accounts of February 2020
      • Best Money Market Accounts of 2020
      • Best Online Checking Accounts of 2020
      • Best Bank Promotions and Bonuses 2020
      • Best CD Rates of 2020
      • Best Money Market Accounts of 2020
      • Best Bank for FHA Loan of 2020
    • KYC
      • Best KYC Solutions 2020
      • KYC Verification: How it is Done?
  • Betting
    • Gambling
    • Online Casinos
    • Sporting Odds
      • How to Read Odds: NBA Odds
  • Credit Cards
    • Cards
      • American Express
      • Lowe’s Credit Card
    • Best Of
      • Best Credit Cards
      • The Best Credit Card for Balance Transfers 2020
      • Best Buy Credit Card 2020
      • Best hotel credit cards for 2020
      • Best Gas Rewards Credit Cards of 2020
      • Best Rewards Credit Card 2020
      • Best Credit Cards for Students 2020
      • Best Airline Credit Card 2020
      • Best Business Credit Cards 2020
      • Best Cash Back Credit Cards 2020
      • Capital One Credit Card – Best Cards of 2020
      • Best hotel credit cards for 2020
      • Best Gas Rewards Credit Cards of 2020
      • Best Rewards Credit Card 2020
      • Best Secured Credit Cards 2020
      • Best No Annual Fee Credit Cards 2020
      • Best Credit Cards for Bad Credit 2020
      • Best Secured Credit Cards 2020
      • Best 0% APR Credit Cards of February 2020
      • Best Travel Credit Card 2020
    • Reviews
      • Home Depot Credit Card
      • Apple Credit Card Review
      • Walmart Money Card – Review
      • Wells Fargo Propel – Review
      • Travel credit card reviews 2020
      • Petal Credit Card Review
      • Amazon Credit Card Review
      • Credit One Credit Card Review
      • First Premier Credit Card Review
      • Fortiva Credit Card Review
      • Indigo Credit Card Review
      • Discover it® Cash Back – Review
    • Guides
      • Caliber Home Loans
      • Is Discover Visa or Mastercard?
  • Crypto
    • Reviews – Trading Platforms
      • Prime XBT
    • Bitcoin
      • Bitcoin Hoje
      • Mercado Bitcoin
      • Bitcoin Price
        • Bitcoin Price
        • Price of Bitcoin
        • Bitcoin Price Live
        • BTC to USD
        • Bitcoin Price Prediction
        • Bitcoin Price USD
        • Bitcoin Price Live Ticker
      • Buy Bitcoin
        • Without ID Verification
          • Buy Bitcoin Anonymously
          • Buy Bitcoin Without ID
        • by Paypal
          • Buy Bitcoin Through Paypal
          • Buy Bitcoin with Paypal
        • ATM
          • Buy Bitcoin ATM
          • Buy Bitcoin Near Me
        • with Credit Card
          • Buy Bitcoin with credit card
          • Buy Bitcoin with Credit Card
          • Buy Bitcoin with Prepaid Card
        • Buy Bitcoin at Walmart
        • Buy Bitcoin Cash
        • Buy and Sell Bitcoin
        • Buy Bitcoin With Gift Card
      • Best Of
        • 23 Best Place to Buy Bitcoin Online 2020
        • Buy Bitcoin: Best Ways to Buy BTC Instantly
        • Best Bitcoin Sports Betting Sites 2020
        • Bitcoin Betting
      • Guides
        • Bitcoin ATM near me
        • Bitcoin Price
          • Bitcoin Price Guide
          • Bitcoin BTC Price
          • Bitcoin Price Prediction
        • How to Buy Bitcoin
        • How to Mine Bitcoin on PC
        • What can you Buy with Bitcoin?
        • Where to buy Bitcoin?
        • Bitcoin
        • What can you Buy with Bitcoin?
        • Easiest Way to Buy Bitcoin
        • Bitcoin Halving
        • Where to buy Bitcoin?
        • How Long does it Take to Mine 1 Bitcoin?
      • Calculator
        • BTC to USD Converter
        • Bitcoin Preev
      • Latest News
        • Bitcoin News
        • Latest News
        • Current Bitcoin News
    • Ethereum
      • Ethereum
      • Ethereum Worth
      • Ethereum News
    • Ripple
      • Ripple Chart Live
        • Ripple
      • Ripple News
      • Ripple Price
    • Litecoin
      • Litecoin Price
    • Dogecoin
      • Dogecoin Price
    • Best Of
      • Crypto Exchanges
        • Best Cryptocurrency Exchanges | April 2020
        • Best Cryptocurrency Exchange
      • Wallets
        • Best Crypto Wallets
        • Best Crypto Wallets 2020
        • Best Crypto Hardware Wallets
        • Best Crypto Hardware Wallets of 2020
      • Best Crypto to Invest in
      • Best Crypto Trading Bot
      • Greatest Cryptocurrency Tax Software program 2020
    • ICO
      • Prime ICO Advertising and marketing Companies
      • Best ICO listing sites
    • Market
      • Binance
      • Coinbase
    • Latest News
      • Crypto Exchange News
      • Cryptocurrency News
      • Facebook Libra
  • Investing
    • Netflix Stock
    • Roku Stock
    • AT&T
    • American Airlines
    • Stocks
      • Marijuana Stocks
      • Dow Jones
      • Large-Cap
        • Boeing Stock
        • Tesla
          • Tesla Stock
          • Tesla Stock Price
        • Apple Stock
        • Disney
          • Royal Caribbean
          • United Airlines
          • Southwest Airlines
          • Spotify
        • NIO Stock
        • Amazon
          • Amazon Pay
          • Amazon
        • PayPal Stock Price
        • General Electric Stock Price
        • Square Stock
        • Facebook Stock – FB Stock
        • Frontier Airlines
          • Frontier Airlines
        • Bank of America Stock
      • Best Of
        • Best Fintech Stocks 2020
        • Best Dividend Stocks
        • Best Stock Trading Apps of 2020
        • Best Forex Brokers 2020
        • Best Online Brokers for Beginners 2020
        • Best Brokers for ETFs Investing
        • Best Online Brokers for Stock Trading 2020
      • Guides
        • Stocks in Market: Consider Investing These 2 Stocks
        • How to buy stocks?
    • Money
      • How to Create a Budget
      • How to Invest Money
      • How to Make Money Online
      • How to Make Money with Bitcoin
      • How To Save Money
      • How to Track Expenses
    • Gold
      • Best Place to Buy Gold
      • Gold Price Chart
      • Buy Gold
      • Price of Gold
    • Oil
      • Oil Price – WTI Crude Oil
  • Insurance
    • Best Of
      • The Best Renters Insurance Companies 2020
      • Best Life Insurance of 2020
      • Best Pet Insurance Providers of 2020
      • Best Homeowners Insurance Companies of 2020
      • Best Car Insurance Quotes Online
      • Best Home Insurance Companies for 2020
    • Insurtech
  • LifeStyle
    • Real Estate
      • Aston Martin Residences
    • Luxury Apartments
      • The Best Miami Luxury Homes
    • Luxury Cars
      • Best Luxury Sports Car
      • Best Luxury SUVs for 2020
      • Best Electric Cars
      • Best Luxury Cars
      • Best Time to Buy a Car
      • Porsche
    • Luxury Watches
      • Most Expensive Watches
    • Luxury Retreats
      • Best Luxury Yoga Retreats
    • Luxury Brands
      • Best Luxury Clothing Brands
  • Loans
    • Quicken Loans
    • Tesco Loans
    • Rocket Loans
    • Sunny Loans
    • Discover Student Loans
    • Merrill Lynch Benefits
    • Guides
      • Loans
      • Online Loans
      • Payday Loans
      • Bad Credit Loans Guaranteed Approval
      • Personal loans
      • Bad Credit Loans
      • Students
        • Great Lakes Students Loans
        • Wells Fargo Student Loans
        • AES Student Loans
        • Fafsa deadline
    • Best Of
      • Best Student Loan Refinance of 2020
      • Bad Credit Loans Guaranteed Approval
      • Best Loan for Students
      • Best Online Loans for Bad Credit 2020
      • Best Personal Loans of 2020
      • Best payday loans 2020
      • Best Business Loan Lenders of 2020
      • Best Auto Loan Rates for 2020
    • Calculators
      • Loan Calculator
      • FHA loan calculator
      • VA Loan Calculator
      • Student Loan Calculator
      • Personal Loan Calculator
      • Auto Loan Calculator
      • Boat Loan Calculator
  • Mortgages
    • Roundpoint Mortgage
    • Calculators
      • Mortgage Calculator
      • Simple Mortgage Calculator
    • Best Of
      • Best Mortgage Rates
      • Greatest On-line Mortgage Lenders
      • Best Mortgage for Low Down Payment 2020
      • The Best Mortgage Lenders for First Time Home Buyers
      • Best VA Mortgage Lenders of 2020
  • Promotions & Bonus
    • Get Avios Points Free
    • P2P Crowdlending – Average Interest Rate 18%
    • Get Revolut Card + £50
    • Coupons – Best websites
  • Politics
    • Joe Biden
    • Donald Trump
  • About Us
    • Contact
    • Fintech Zoom
    • Ask for Proposal
    • Who Reads Fintech Zoom?
    • Opinion
    • Press Release – Submit
    • Why Fintech Zoom?
    • Crypto Advisory
    • Best Fintech Companies to Work for 2020
No Result
View All Result
Fintech News | Fintech Zoom
No Result
View All Result

IBM – Guru: SQL and QTEMP – IT Jungle

Mia Turner by Mia Turner
January 4, 2021
in IBM
0

Home » IBM – Guru: SQL and QTEMP – IT Jungle

IBM – Guru: SQL and QTEMP – IT Jungle

January 4, 2021

Ted Holt

Hey, Ted.

For many years IBM i developers, operators, and others have taken advantage of an operating system feature called the QTEMP library. Through the years you have referenced it various times in IT Jungle as a useful feature of IBM i. I recently read an article in which a respected IBM expert from the Rochester lab services team told people not to use the QTEMP library when working in SQL. It would be very interesting if you could dive into this topic and explain when/if there is still a time and place for QTEMP. I think a lot of people would read this.

— Bill

I know these lab services guys, having attended conferences at which they spoke. I have the highest respect for them. I listen to them speak every opportunity I get and I read everything they write. I take everything they say seriously. I have learned so much from them. I can’t say enough good things about them.

An important part of their work is helping IBM customers with performance problems. This is the context in which they are speaking about QTEMP. They’ve seen performance problems that were directly caused by the use of QTEMP. To be more specific, it is the use of scratch tables in QTEMP that they are warning us against. Among the reasons they give are that (1) creating a table and loading it with data are slow operations, and (2) tables in QTEMP are not usually indexed. Instead, we should use other techniques, in particular the use of views, common table expressions, and nested table expressions (also called derived tables), all three of which are different ways to implement a SELECT statement.

Here’s an example. Let’s say that someone I serve wants to know who owes us money, how much money each customer owes us, the percentage a customer’s debt is of the combined debt of the customers in the same state, and the percentage a customer’s debt is of the total debt. To get the percentages requires summing up all debts. In days of yore, I might have used a non-SQL equivalent of the following SQL code to create two scratch tables in QTEMP.

declare global temporary table StateTotals as
   (select state, sum(baldue) as StateBalDue
      from qiws.qcustcdt
     group by state)
 with data;

declare global temporary table GrandTotal as
   (select sum(StateBalDue) as GrandBalDue
      from session.StateTotals)
 with data;

select d.state, d.cusnum, d.lstnam, d.city, d.baldue,
       case when s.StateBalDue is null 
              or s.StateBalDue =  0
         then 0
         else dec(round(d.baldue / s.StateBalDue,4) * 100,5,2)
       end as PercentOfState, 
       dec(round(d.baldue / g.GrandBalDue,4) * 100,5,2)
           as PercentOfTotal
  from qiws.qcustcdt as d
  join session.StateTotals as s
    on d.state = s.state
 cross join session.GrandTotal as g
 order by d.State, PercentOfTotal desc ;

Do I get the correct answers? Certainly. But that doesn’t mean that I should continue to use this tried-and-true technique. Modern computers are faster, memory is more abundant and cheaper, and SQL has gotten more and more powerful.

The two scratch tables are easily replaced with common table expressions of the same names.

with StateTotals as
   (select state, sum(baldue) as StateBalDue
      from qiws.qcustcdt
     group by state),
GrandTotal as
   (select sum(StateBalDue) as GrandBalDue
      from StateTotals)
      
select d.cusnum, d.lstnam, d.city, d.state, d.baldue,
       case when s.StateBalDue is null 
              or s.StateBalDue =  0
         then 0
         else dec(round(d.baldue / s.StateBalDue,4) * 100,5,2)
       end as PercentOfState, 
       dec(round(d.baldue / g.GrandBalDue,4) * 100,5,2)
           as PercentOfTotal
  from qiws.qcustcdt as d
  join StateTotals as s
    on d.state = s.state
 cross join GrandTotal as g
 order by d.State, PercentOfTotal desc;

Performance is not a concern for this small example, as file QCUSTCDT only has a dozen records, but if the file were much larger, the second version would run noticeably faster than the first one.

One very common use of scratch tables is in chains of queries. That is, one or more queries builds one or more scratch tables, often in QTEMP, but not necessarily there, before producing the final output. This problem is easily avoided by ceasing to use Query for IBM i, but Query is the software that refuses to die. I’ve already written about this topic, so if you want to know how to replace query chains with common table expressions, see my article Common Table Expressions Can Replace Query Chains.

I’m not going to presume to give my approval to what the lab services guys have said. That would be like Jack Benny approving the violin playing of Itzhak Perlman. Instead, I can only add to the discussion by addressing the question from a different perspective.

Let’s back up a step. What is the purpose of QTEMP? Just this: to allow two or more jobs to run the same program at the same time without interfering with one another. This is not a new problem. I faced it in my S/34 and S/36 days, as files were global to the system. This will look familiar to old-timers.

// LOAD #GSORT 
// FILE NAME-INPUT,LABEL-HISTORY
// FILE NAME-OUTPUT,LABEL-SORT?WS?,RECORDS-?F'A,HISTORY'?
// RUN

The ?WS? expression retrieves the workstation ID. Two users could run in parallel because the scratch files had different names. Imagine my joy when I started programming the S/38 and had the QTEMP library for such tasks.

When IBM says that you shouldn’t use SQL with QTEMP, they are talking from the perspective of performance. They are not addressing concurrent program execution. They don’t need to. If you use a view, common table expression, or nested table expression instead of scratch files, no two jobs can possibly interfere with one another! Magnificent!

The question, then, boils down to this: Are there times when SQL queries won’t serve the purpose, and scratch tables are unavoidable? I think so. I can’t give an exhaustive list, but here are a few situations that come to mind:

  • Reading an outfile produced by a CL command. I’m most grateful for the IBM i Services and DB2 for i Services that IBM provides. They give us SQL interfaces to the operating system. Sometimes there is no service that retrieves the information I want, so I use an outfile, which I typically place into QTEMP.
  • Joining to a one-row table for row selection. I’ve been using this technique since my S/36 days. A more modern technique would be to use global variables. I haven’t tried to compare performance of the two techniques.
  • Subsetting data for use by several queries in a job stream. Suppose a batch job stream runs several queries, all of which need a certain subset of data. Depending on the situation, I might put that data into a scratch table to avoid selecting the same data time and time again.
  • Dealing with bad database design. The problem with the examples I and other writers use in articles and presentations is that our examples reflect a perfect world, not the reality many of us have to deal with day after day. Many of us are forced to work with what I call a “doo-doo base”, a set of tables and/or physical files in which data is improperly stored. Over the years I have seen some bizarre ways to shoehorn data into files. I’ve seen numerous violations of first, second, and third normal forms. As I wrote a few months ago, I’ve seen many repurposed fields in the applications I’ve worked on. If you regularly work with a doo-doo base, you may have no choice but to run one or two or three or more RPG programs and/or SQL queries to build a scratch table, which you can then query using SQL. If you don’t need concurrent execution, you can build the scratch table, along with needed indexes, in a permanent library. If you do need to support the possibility of concurrent execution, QTEMP is a good place to store such a table.

Those are some things to come to mind. I don’t have any hard rules about when to use QTEMP and when not to use it. I can say that thanks to techniques such as views, common table expressions, and nested table expressions, I use QTEMP in SQL queries much less than I used to.

Keep in mind, too, that performance is relative. Is five seconds too long for a query to run? It depends on the context. If it’s in the overnight batch process, it’s almost certainly acceptable. If it’s on the server end of a request from a Web browser, it’s probably much too slow. Not every query has to run optimally. Good enough is good enough. The IBM guys kindly brought this matter of QTEMP to our attention because the use of QTEMP was the cause of performance problems. That doesn’t mean that every query that uses QTEMP is a problem and needs to be accelerated.

In short, QTEMP is a wonderful tool. It would be foolish not to use it at all. I subscribe to the idea that a master of his craft knows his tools, the capabilities, strengths, weaknesses, advantages and disadvantages of each one, and is able to make an informed decision when doing a task. In other words, use some common sense.

I welcome your comments below or in email. It would be especially helpful to all of us if the database masters from IBM would add their comments.

RELATED STORIES

Using Table Expressions (IBM Knowledge Center)

Guru: Common Table Expressions Can Replace Query Chains

Jack Benny – Violin Duet with 12 Year Old Toni

IBM i Services

Db2 for i Services

Guru: SQL Can Read Program-described Data

Previous Post

Loans – Retail loan demand recovers in Oct-Dec

Next Post

Ethereum – Ethereum, Litecoin, and Ripple’s XRP – Daily Tech Analysis – January 4th, 2021

Mia Turner

Mia Turner

+10 years of experience in analyzing and covering the currencies markets with vast experience in fundamental, political and technical analysis, educational content, and copywriting. Contact: mia.turner@fintechzoom.com

Related Posts

IBM – Software As A Service (SaaS) Market 2020-2026 Industry Players Like

January 4, 2021

IBM – Software As A Service (SaaS) Market 2020-2026 Industry Players Like

January 4, 2021

IBM – Software As A Service (SaaS) Market 2020-2026 Industry Players Like

January 4, 2021

IBM – Software As A Service (SaaS) Market 2020-2026 Industry Players Like

January 4, 2021

IBM – Software As A Service (SaaS) Market 2020-2026 Industry Players Like

January 4, 2021

IBM – Top Machine Learning Certifications (2021)

January 3, 2021

IBM – Top Machine Learning Certifications (2021)

January 3, 2021

IBM – Top Machine Learning Certifications (2021)

January 3, 2021

IBM – Global Cloud Storage Market Capital Analysis by Amazon Web Services, EMC Corporation, IBM Corporation, Oracle Corporation – Factory Gate

January 3, 2021
Next Post

Ethereum - Ethereum, Litecoin, and Ripple’s XRP – Daily Tech Analysis – January 4th, 2021

Netflix - Stock futures slip as Wall Street kicks off the new year

Honeywell - Global Contact Sensors Market 2020 Industry Analysis – OMEGA, TE Connectivity, Panasonic, Honeywell, Rockwell Automation, MITSUBISHI ELECTRIC, Phoenix Sensors

Leave a Reply Cancel reply

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

  • About
  • Advertise
  • Careers
  • Contact
  • Loans
Call us: + 1 917 9939840

© 2020 FINTECH ZOOM - WORLD FINANCE

No Result
View All Result
  • Banking
    • Banks
      • Chase Online
      • Bank of America
    • Rates
      • 6% cd rates – It Exists ?
    • Payment Systems
    • Send Money
      • Send Money Online
      • Transfer Money Online
      • Best App To Send Money Online
    • Mobile Banking
    • Top Fintech Companies
      • Mastercard News
      • Monzo News
      • Stripe News
    • Best Of
      • Best Online Banks of 2020
      • Digital Bank
      • Best Bank for Home Loans 2020
      • Best Bank Interest Rates March 2020
      • Best Online Savings Accounts of February 2020
      • Best Online Savings Accounts of February 2020
      • Best Money Market Accounts of 2020
      • Best Online Checking Accounts of 2020
      • Best Bank Promotions and Bonuses 2020
      • Best CD Rates of 2020
      • Best Money Market Accounts of 2020
      • Best Bank for FHA Loan of 2020
    • KYC
      • Best KYC Solutions 2020
      • KYC Verification: How it is Done?
  • Betting
    • Gambling
    • Online Casinos
    • Sporting Odds
      • How to Read Odds: NBA Odds
  • Credit Cards
    • Cards
      • American Express
      • Lowe’s Credit Card
    • Best Of
      • Best Credit Cards
      • The Best Credit Card for Balance Transfers 2020
      • Best Buy Credit Card 2020
      • Best hotel credit cards for 2020
      • Best Gas Rewards Credit Cards of 2020
      • Best Rewards Credit Card 2020
      • Best Credit Cards for Students 2020
      • Best Airline Credit Card 2020
      • Best Business Credit Cards 2020
      • Best Cash Back Credit Cards 2020
      • Capital One Credit Card – Best Cards of 2020
      • Best hotel credit cards for 2020
      • Best Gas Rewards Credit Cards of 2020
      • Best Rewards Credit Card 2020
      • Best Secured Credit Cards 2020
      • Best No Annual Fee Credit Cards 2020
      • Best Credit Cards for Bad Credit 2020
      • Best Secured Credit Cards 2020
      • Best 0% APR Credit Cards of February 2020
      • Best Travel Credit Card 2020
    • Reviews
      • Home Depot Credit Card
      • Apple Credit Card Review
      • Walmart Money Card – Review
      • Wells Fargo Propel – Review
      • Travel credit card reviews 2020
      • Petal Credit Card Review
      • Amazon Credit Card Review
      • Credit One Credit Card Review
      • First Premier Credit Card Review
      • Fortiva Credit Card Review
      • Indigo Credit Card Review
      • Discover it® Cash Back – Review
    • Guides
      • Caliber Home Loans
      • Is Discover Visa or Mastercard?
  • Crypto
    • Reviews – Trading Platforms
      • Prime XBT
    • Bitcoin
      • Bitcoin Hoje
      • Mercado Bitcoin
      • Bitcoin Price
      • Buy Bitcoin
      • Best Of
      • Guides
      • Calculator
      • Latest News
    • Ethereum
      • Ethereum
      • Ethereum Worth
      • Ethereum News
    • Ripple
      • Ripple Chart Live
      • Ripple News
      • Ripple Price
    • Litecoin
      • Litecoin Price
    • Dogecoin
      • Dogecoin Price
    • Best Of
      • Crypto Exchanges
      • Wallets
      • Best Crypto to Invest in
      • Best Crypto Trading Bot
      • Greatest Cryptocurrency Tax Software program 2020
    • ICO
      • Prime ICO Advertising and marketing Companies
      • Best ICO listing sites
    • Market
      • Binance
      • Coinbase
    • Latest News
      • Crypto Exchange News
      • Cryptocurrency News
      • Facebook Libra
  • Investing
    • Netflix Stock
    • Roku Stock
    • AT&T
    • American Airlines
    • Stocks
      • Marijuana Stocks
      • Dow Jones
      • Large-Cap
      • Best Of
      • Guides
    • Money
      • How to Create a Budget
      • How to Invest Money
      • How to Make Money Online
      • How to Make Money with Bitcoin
      • How To Save Money
      • How to Track Expenses
    • Gold
      • Best Place to Buy Gold
      • Gold Price Chart
      • Buy Gold
      • Price of Gold
    • Oil
      • Oil Price – WTI Crude Oil
  • Insurance
    • Best Of
      • The Best Renters Insurance Companies 2020
      • Best Life Insurance of 2020
      • Best Pet Insurance Providers of 2020
      • Best Homeowners Insurance Companies of 2020
      • Best Car Insurance Quotes Online
      • Best Home Insurance Companies for 2020
    • Insurtech
  • LifeStyle
    • Real Estate
      • Aston Martin Residences
    • Luxury Apartments
      • The Best Miami Luxury Homes
    • Luxury Cars
      • Best Luxury Sports Car
      • Best Luxury SUVs for 2020
      • Best Electric Cars
      • Best Luxury Cars
      • Best Time to Buy a Car
      • Porsche
    • Luxury Watches
      • Most Expensive Watches
    • Luxury Retreats
      • Best Luxury Yoga Retreats
    • Luxury Brands
      • Best Luxury Clothing Brands
  • Loans
    • Quicken Loans
    • Tesco Loans
    • Rocket Loans
    • Sunny Loans
    • Discover Student Loans
    • Merrill Lynch Benefits
    • Guides
      • Loans
      • Online Loans
      • Payday Loans
      • Bad Credit Loans Guaranteed Approval
      • Personal loans
      • Bad Credit Loans
      • Students
    • Best Of
      • Best Student Loan Refinance of 2020
      • Bad Credit Loans Guaranteed Approval
      • Best Loan for Students
      • Best Online Loans for Bad Credit 2020
      • Best Personal Loans of 2020
      • Best payday loans 2020
      • Best Business Loan Lenders of 2020
      • Best Auto Loan Rates for 2020
    • Calculators
      • Loan Calculator
      • FHA loan calculator
      • VA Loan Calculator
      • Student Loan Calculator
      • Personal Loan Calculator
      • Auto Loan Calculator
      • Boat Loan Calculator
  • Mortgages
    • Roundpoint Mortgage
    • Calculators
      • Mortgage Calculator
      • Simple Mortgage Calculator
    • Best Of
      • Best Mortgage Rates
      • Greatest On-line Mortgage Lenders
      • Best Mortgage for Low Down Payment 2020
      • The Best Mortgage Lenders for First Time Home Buyers
      • Best VA Mortgage Lenders of 2020
  • Promotions & Bonus
    • Get Avios Points Free
    • P2P Crowdlending – Average Interest Rate 18%
    • Get Revolut Card + £50
    • Coupons – Best websites
  • Politics
    • Joe Biden
    • Donald Trump
  • About Us
    • Contact
    • Fintech Zoom
    • Ask for Proposal
    • Who Reads Fintech Zoom?
    • Opinion
    • Press Release – Submit
    • Why Fintech Zoom?
    • Crypto Advisory
    • Best Fintech Companies to Work for 2020

© 2020 FINTECH ZOOM - WORLD FINANCE