Re: [GENERAL] efficiency of wildcards at both ends

2012-06-23 Thread Jasen Betts
On 2012-06-20, Sam Z J wrote: > --0016e6d999db24c4c704c2ea7a97 > Content-Type: text/plain; charset=ISO-8859-1 > > Hi all > > I'm curious how is wildcards at both ends implemented, e.g. LIKE '%str%' > How efficient is it if that's the only search criteria against a large > table? how much does inde

Re: [GENERAL] efficiency of wildcards at both ends

2012-06-20 Thread Thomas Kellerer
Alan Hodgson wrote on 20.06.2012 19:39: I'm curious how is wildcards at both ends implemented, e.g. LIKE '%str%' How efficient is it if that's the only search criteria against a large table? how much does indexing the column help and roughly how much more space is needed for the index? Indexin

Re: [GENERAL] efficiency of wildcards at both ends

2012-06-20 Thread Edson Richter
Em 20/06/2012 15:03, John R Pierce escreveu: On 06/20/12 10:37 AM, Edson Richter wrote: select * from tb1 where nome like 'CARLOS%' or reverse(nome) like reverse('%CARLOS') Should return same results as select * from tb1 where nome like '%CARLOS%' no, that won't match 'abcCARLOSxyx'

Re: [GENERAL] efficiency of wildcards at both ends

2012-06-20 Thread John R Pierce
On 06/20/12 10:37 AM, Edson Richter wrote: select * from tb1 where nome like 'CARLOS%' or reverse(nome) like reverse('%CARLOS') Should return same results as select * from tb1 where nome like '%CARLOS%' no, that won't match 'abcCARLOSxyx' -- john r pierceN 3

Re: [GENERAL] efficiency of wildcards at both ends

2012-06-20 Thread Thomas Kellerer
Sam Z J wrote on 20.06.2012 19:10: Hi all I'm curious how is wildcards at both ends implemented, e.g. LIKE '%str%' How efficient is it if that's the only search criteria against a large table? how much does indexing the column help and roughly how much more space is needed for the index? if t

Re: [GENERAL] efficiency of wildcards at both ends

2012-06-20 Thread Sam Z J
thank you all for the useful information =D On Wed, Jun 20, 2012 at 1:39 PM, Alan Hodgson wrote: > On Wednesday, June 20, 2012 01:10:03 PM Sam Z J wrote: > > Hi all > > > > I'm curious how is wildcards at both ends implemented, e.g. LIKE '%str%' > > How efficient is it if that's the only search

Re: [GENERAL] efficiency of wildcards at both ends

2012-06-20 Thread Alan Hodgson
On Wednesday, June 20, 2012 01:10:03 PM Sam Z J wrote: > Hi all > > I'm curious how is wildcards at both ends implemented, e.g. LIKE '%str%' > How efficient is it if that's the only search criteria against a large > table? how much does indexing the column help and roughly how much more > space is

Re: [GENERAL] efficiency of wildcards at both ends

2012-06-20 Thread Edson Richter
Just ocurred to me that would be possible to create some sort of "hybrid" solution... create index idx1 on tb1 (nome); create index idx2 on tb1 (reverse(nome)); select * from tb1 where nome like 'CARLOS%' or reverse(nome) like reverse('%CARLOS') Should return same results as select * from tb

Re: [GENERAL] efficiency of wildcards at both ends

2012-06-20 Thread Edson Richter
AFAIK, wildcards at both ends are not optimized at all, unless you use some sort of specialized index (may be Gist or FullText). Until 9.1 there is no such "Index Scan" feature, that would help (very little). Other databases (like MS SQL Server) solve this kind of query by executing an Index Sca

Re: [GENERAL] efficiency of wildcards at both ends

2012-06-20 Thread Andy Colson
On 6/20/2012 12:10 PM, Sam Z J wrote: Hi all I'm curious how is wildcards at both ends implemented, e.g. LIKE '%str%' How efficient is it if that's the only search criteria against a large table? how much does indexing the column help and roughly how much more space is needed for the index? if

Re: [GENERAL] efficiency of wildcards at both ends

2012-06-20 Thread Lonni J Friedman
On Wed, Jun 20, 2012 at 10:10 AM, Sam Z J wrote: > Hi all > > I'm curious how is wildcards at both ends implemented, e.g. LIKE '%str%' > How efficient is it if that's the only search criteria against a large > table? how much does indexing the column help and roughly how much more > space is neede

[GENERAL] efficiency of wildcards at both ends

2012-06-20 Thread Sam Z J
Hi all I'm curious how is wildcards at both ends implemented, e.g. LIKE '%str%' How efficient is it if that's the only search criteria against a large table? how much does indexing the column help and roughly how much more space is needed for the index? if the answers are too long, please point m