IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

LIKE vs EQUAL


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Nileshkul

New User


Joined: 09 May 2016
Posts: 43
Location: India

PostPosted: Sat Jul 16, 2016 7:50 am
Reply with quote

Dear all,

I have a query which uses LIKE in WHERE clause for 4 character comparision.
Some thing like:
Where column1 LIKE :HOST1
Here character 2 to 4 are populated with _ underscore as wild char based on user input.
But many times - all 4 character are populated propely and nit wild so will use of EQUAL instead LIKE give better result.
Thanks.
Back to top
View user's profile Send private message
Nileshkul

New User


Joined: 09 May 2016
Posts: 43
Location: India

PostPosted: Sat Jul 16, 2016 2:46 pm
Reply with quote

Just to be clear - I want to know if equal to perform better than Like given that there is no wild card in Like host variable.
By performance, I mean whether Equal to will take less CPU than Like without wild card characters
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sat Jul 16, 2016 5:13 pm
Reply with quote

What happened when you tried a simple test?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Mon Jul 18, 2016 11:09 am
Reply with quote

First find the length of the field , if it 4 then execute with equal operator else with like.They both works differently so though like is good to avoid but you are out of choice.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon Jul 18, 2016 11:57 am
Reply with quote

If the column is indexed and you have the full key then do not use LIKE.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Mon Jul 18, 2016 1:27 pm
Reply with quote

I reiterate what Nic has said you might need to validate if the HOST1 is going to be filled with the key or with wild card based on which you might need to execute the query accordingly
Back to top
View user's profile Send private message
Nileshkul

New User


Joined: 09 May 2016
Posts: 43
Location: India

PostPosted: Tue Jul 19, 2016 4:01 am
Reply with quote

Thanks all for replies.
The column is not key & I tried simple test, CPU uti
lization is almost same.
Thanks again, very helpful
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Tue Jul 19, 2016 8:17 am
Reply with quote

It must have to be indexed.you will have to try against the actual production data and not with the test data.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts check if two PD values are equal, no ... DFSORT/ICETOOL 4
No new posts Comparing Comp-3 fields with greater ... DFSORT/ICETOOL 11
No new posts Difference bw EQUAL and EQUAL TO in C... COBOL Programming 3
No new posts Spli the records into equal number SYNCSORT 1
No new posts Can DFSORT output equal number of row... DFSORT/ICETOOL 3
Search our Forums:

Back to Top