×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Query regarding wildcards and indicies

Query regarding wildcards and indicies

Query regarding wildcards and indicies

(OP)
I've been requested to modify a program that reads from our database - the purpose of the modification is to permit the usage of wildcard searches.  (Ex: find fog, foolish, and ford when searching on 'fo*')

I know I need to use the '%' character for my searches.  I know I need to use LIKE.  But the searches are having to parse a fairly large database, and it's taking longer than my boss would like for the search to run.  Is there any way of indexing a table so as to make wildcard searches run faster, or some other way of doing this, or am I simply chasing a pipe dream?

RE: Query regarding wildcards and indicies

Hi

Quote (CHeighlund):

I know I need to use the '%' character for my searches.  I know I need to use LIKE.
Not exactly. Beside like, PostgreSQL can handle similar to and POSIX matching too. And of course, through a Perl stored procedure you have access to PCRE too.

Read the Pattern Matching chapter of the PostgreSQL documentation for details.

No idea about the speed problem. I would try the mentioned alternatives, maybe one performs better.

Also I would try to rewrite the query, maybe some unwanted values could be eliminated before performing the matching.

Quote (CHeighlund):

Ex: find fog, foolish, and ford when searching on 'fo*'
Maybe would help to improve the application too, so instead of field like 'fo%' to perform strpos(field,'fo')=1 or substr(name,1,2)='fo'.

Again, I am not sure about their speed, so try them first.
 

Feherke.
http://rootshell.be/~feherke/

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close