Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

LIKE vs EQUAL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Nileshkul

New User


Joined: 09 May 2016
Posts: 9
Location: India

PostPosted: Sat Jul 16, 2016 7:50 am    Post subject: LIKE vs EQUAL
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: 9
Location: India

PostPosted: Sat Jul 16, 2016 2:46 pm    Post subject: Update on query Like vs Equal
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: 1717
Location: UK

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

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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Mon Jul 18, 2016 11:09 am    Post subject:
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: 1717
Location: UK

PostPosted: Mon Jul 18, 2016 11:57 am    Post subject:
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

Moderator


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

PostPosted: Mon Jul 18, 2016 1:27 pm    Post subject:
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: 9
Location: India

PostPosted: Tue Jul 19, 2016 4:01 am    Post subject: Thanks
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Tue Jul 19, 2016 8:17 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Spli the records into equal number alluri12 SYNCSORT 1 Wed Sep 23, 2015 4:55 pm
No new posts Can DFSORT output equal number of row... HammerTime DFSORT/ICETOOL 3 Thu May 01, 2014 3:11 pm
No new posts How to use Not equal to in panel Priyanka Pyne TSO/ISPF 5 Mon Sep 26, 2011 11:06 pm
No new posts Need information about not equal cond... Phrzby Phil DB2 34 Fri Jun 17, 2011 7:23 pm
No new posts Comparing File with greater than equa... bhavya_sha DFSORT/ICETOOL 4 Thu Jan 06, 2011 4:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us