in reply to Optimizing string searches

Rather vague description but perl may be better than os grep.

if files reside on multiple machines - run search on the seperate machines if possible.

if files reside on a single machine - process them locally.

do not open files across the network.

suggest:
create a list of log files
loop open log files
loop read current file
regex string1 (if match write ouput)
regex string2 (if match ...)
regex string3 (if match ...)
regex string4 (if match ...)
next record
next log file

assumes: will only parse the log files for these 4 strings. there will be no reason to search the same logfiles again for other strings.

Enjoy!
Dageek

Replies are listed 'Best First'.
Re^2: Optimizing string searches
by moritz (Cardinal) on Sep 05, 2008 at 18:58 UTC
    regex string1 (if match write ouput) regex string2 (if match ...) regex string3 (if match ...) regex string4 (if match ...)

    It's usually faster to build one regex with four alternations and match that instead of matching four single regexes against a string.

      Thanks Moritz!

      Enjoy!
      Dageek

Re^2: Optimizing string searches
by cool256 (Initiate) on Sep 05, 2008 at 20:54 UTC
    Thanks for all the suggestions.
    Indeed my question was a bit vague. Since the search strings may change at any given time, hardcoding the regex was not an option.
    Instead I generate a runtime perl file containing the regex on the fly from the search strings.
    This boosted the performance and I'm fairly happy with the results.

    Thanks again :)