Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the impact coming from wildcard %

Tags:

sql-server

I need to add a new SELECT statement whose search condition include something like leagueCode LIKE 'nba%'.

I would like to know if the index against leagueCode is still exploitable or introduce any overhead after % is included in the target column.

like image 446
Ricky Avatar asked Mar 12 '10 06:03

Ricky


People also ask

What is wild card effect?

In a view of the future, a wild card is a low-probability, high-impact event. This concept may be introduced into anticipatory decision-making activity in order to increase the ability of organizations and governments to adapt to surprises arising in turbulent (business) environments.

What is the advantage of wild card?

Advantage: Wildcards are cheaper than the alternative Before Wildcards, you would need to purchase an individual SSL certificate for every sub-domain. That's expensive! A Wildcard SSL certificate can secure unlimited sub-domains at one set cost. A cost that's much cheaper than the alternative.

What is the risk of using wildcard certificate?

The biggest concern with wildcard certificates is that when one server or sub-domain covered by the wildcard is compromised, all sub-domains may be compromised. In other words, the upfront simplicity of the wildcard can create significant problems should things go wrong.

Does the wildcard change your team permanently?

The Wildcard sets any changes you make to your team from that point onwards. That means it does not go back to normal – in other words the team you had previously – once the gameweek ends. A Free Hit, meanwhile, only changes it for one week. See more in our guide to Free Hits here.


2 Answers

it depends 100% on the position of the wildcard.

  • At the beginning: no index. Some servers have inverse indices (starting at the end of the string) and would use them - SQL Server does not.
  • In the middle: Partial index (beginning part), then seeking within that range.
  • in the end: Index (Acutally an INDEX SEEK will be shown in the query analyzer).

Overhead? Sure - but it is not exactly high (no table scan) and there is not exactly a way to work around it.

like image 57
TomTom Avatar answered Oct 18 '22 15:10

TomTom


Yes, the index can still be used because you have a constant prefix (nba in this case).

like image 41
Gabe Avatar answered Oct 18 '22 17:10

Gabe