Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6588709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:04:54+00:00 2026-05-25T17:04:54+00:00

I am working on a join condition between 2 tables where one of the

  • 0

I am working on a join condition between 2 tables where one of the columns to match on is a concatentation of values. I need to join columnA from tableA to the first 2 characters of columnB from tableB.

I have developed 2 different statements to handle this and I have tried to analyze the performance of each method.

Method 1:

ON tB.columnB   like  tA.columnA || '%'

Method 2:

ON substr(tB.columnB,1,2) = tA.columnA

The query execution plan has a lot less steps using Method 1 compared to Method 2, however, it looks like Method 2 executes much faster. Also, the execution plan shows a recommended index for Method 2 that could improve its performance.

I am running this on an IBM iSeries, though would be interested in answers in a general sense to learn more about sql query optimization.

Does it make sense that Method 2 would execute faster?

This SO question is similar, but it looks like no one provided any concrete answers to the performance difference of these approaches: T-SQL speed comparison between LEFT() vs. LIKE operator.

PS: The table design that requires this type of join is not something that I can get changed at this time. I realize having the fields separated which hold different types of data would be preferrable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:04:55+00:00Added an answer on May 25, 2026 at 5:04 pm

    I found this reference in an IBM redbook related to SQL performance. It sounds like the SUBSTR scalar function can be handled in an optimized manner by an iSeries.

    If you search for the first character and want to use the SQE instead
    of the CQE, you can use the scalar function substring on the left sign
    of the equal sign. If you have to search for additional characters in
    the string, you can additionally use the scalar function POSSTR. By
    splitting the LIKE predicate into several scalar function, you can
    affect the query optimizer to use the SQE.

    http://publib-b.boulder.ibm.com/abstracts/sg246654.html?Open

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on SQL Server 2008-R2 and I need to use multiple tables join.
If I use a join, the Include() method is no longer working, eg: from
I have this working query: $q = $this->db->query('SELECT u.name FROM users u JOIN user_group
I have 2 queries which display 2 different values but the results from one
I'm trying to connect the values of two join tables that I have and
I am working on a database join and I want to do the following:
I am using blow code for join in nhibernate, which is working fine. But
I an tryin to join 4 tables within a query as per requirement. where
I have written the follwing code to demonstrate race condition between 2 threads of
I need some help with a MySQL query I'm working on. I have data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.