Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1371

using like vs = in exact match

Newsgroups comp.databases.ms-sqlserver
Date 2012-12-26 10:22 -0800
Message-ID <fc8f89e9-8825-40bd-8eda-523c9b083d69@googlegroups.com> (permalink)
Subject using like vs = in exact match
From migurus <migurus@yahoo.com>

Show all headers | View raw


I came across a situation where application builds a list of names by matching first three letters entered by user. The list of names does not have any duplicates  The query generated by app is
  SELECT LAST_NAME
  FROM NAME_LIST
  WHERE LAST_NAME LIKE 'GRE%'

The result set is coming back as
  GREAGORS
  GREEN
  GREISS

Now user selects one line and application should retrieve that line, The app generate the same query as in the 3 letter case above
  SELECT LAST_NAME
  FROM NAME_LIST
  WHERE LAST_NAME LIKE 'GREEN%'

I don't like the lazy programming, it should have been WHERE LAST_NAME = 'GREEN' in my view,  my guts feeling is that the access plan for LIKE clause might be inefficient comparing to the = clause. 
The example above is simplified. But in essence is LIKE less likely to produce a perfect plan comparing to =, or there is no justification to my rant.

Back to comp.databases.ms-sqlserver | Previous | NextNext in thread | Find similar


Thread

using like vs = in exact match migurus <migurus@yahoo.com> - 2012-12-26 10:22 -0800
  Re: using like vs = in exact match Erland Sommarskog <esquel@sommarskog.se> - 2012-12-26 20:10 +0100

csiph-web