sql - Why is like-operator so fast -
you know operator in sql. example:
select * customer email '%goog%'
so question how can database return fast result? when should program function this, loop on customers , on each email. slow. heard indexes. how can database use index when database doesn't know first or last letter is? or other way it?
i don't want program this. want know how works.
i have no idea engine using , what's beneath actual hood here helpful information regarding problem:
- often, sql engines uses free text search inside column able extract queries fast. done creating inverted index, maps each word "documents" (row,column) contains them. 1 used library apache lucene. unfortunately, ir (information retrieval) libraries not support wild card @ beginning of query (but anywhere else), specific example cannot searched in such index.
- you can create index support wild card @ beginning of index, using suffix tree. suffix trees excellent searching substring, example. however, not optimized searching string wild card in middle of it.
Comments
Post a Comment