Advertisement:

Author Topic: Limiting days in search  (Read 23140 times)

Offline Fizzy

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,676
  • Gender: Male
  • SMF World Domination
Limiting days in search
« on: September 16, 2004, 07:50:26 AM »
Please excuse the laymans terms here.

I am just about to upgrade over to SMF but thanks to a complaint and threat of being expelled by my server host about CPU usage I need to make sure that I reduce the amount of pressure the forum places on the server.
Now knowing SMF I am confident that the software itself would not cripple a server but one thing I am worried about is if I have picked up an enemy or two who are manually trying to give me a hard time by abusing the forum in a way that I cannot detect.
One area I thought might be responsible for my sudden high CPU peaks might be bad searching by guests or members (ie searching for * or the letter 'e' for the last 10,000 days)

What I need to do is to limit the CPU usage (something that I cannot measure or gauge) so I wondered if it's possible to do something with the search facility to stop dumb searches. In the DB we have fields "search_cache_size" and "search_max_cached_results" and was wondering if I change those figures would that help?

I don't know how the search facility operates- whether it gets all the data then reviews it or whether it reads concurrently and then stops once a certain search limit is reached.

Any suggestions gratefully received. I'm stressed and hacked off with my server host for not providing me with any data or solutions on this problem so I am literally on my own with only the help of you guys to get me through this. :)

[edit] changed topic title [/edit]
« Last Edit: September 29, 2004, 02:25:15 AM by A.M.A »
"Reality is merely an illusion, albeit a very persistent one." - A.E.


Offline A.M.A

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,133
  • Gender: Male
  • ..
Really sorry .. real life is demanding my full attention .. will be back soon hopefully :)

Offline Fizzy

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,676
  • Gender: Male
  • SMF World Domination
Re: Limiting 'Search' performance
« Reply #2 on: September 16, 2004, 06:59:12 PM »
Hi AMA,

Thanks for the links, but what I am really looking for is something to stop a dumb searcher from scrolling the whole database with every search.

Basically I would like search to start looking at the most recent posts and then when it hits a given number of posts it returns a "Sorry, your request cannot be continued"

Any ideas anyone?
"Reality is merely an illusion, albeit a very persistent one." - A.E.


Offline Fizzy

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,676
  • Gender: Male
  • SMF World Domination
Re: Limiting 'Search' performance
« Reply #3 on: September 16, 2004, 07:07:42 PM »
Oh, not to worry.

I found this in search.php

Code: [Select]
// Maximum age of messages. Default to infinite (9999 days: param not set).
if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999))
$search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];

and in search.template.php I found

Code: [Select]
<td>
', $txt['search_between'], '&nbsp;<input type="text" name="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="5" />&nbsp;', $txt['search_and'], '&nbsp;<input type="text" name="maxage" value="', empty($context['search_params']['maxage']) ? '9999' : $context['search_params']['maxage'], '" size="5" maxlength="5" /> ', $txt[579], '.

I just changed the "9999" to "60"
"Reality is merely an illusion, albeit a very persistent one." - A.E.


Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Limiting 'Search' performance
« Reply #4 on: September 16, 2004, 08:25:02 PM »
Oh, not to worry.

I found this in search.php

Code: [Select]
// Maximum age of messages. Default to infinite (9999 days: param not set).
if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999))
$search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];

and in search.template.php I found

Code: [Select]
<td>
', $txt['search_between'], '&nbsp;<input type="text" name="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="5" />&nbsp;', $txt['search_and'], '&nbsp;<input type="text" name="maxage" value="', empty($context['search_params']['maxage']) ? '9999' : $context['search_params']['maxage'], '" size="5" maxlength="5" /> ', $txt[579], '.

I just changed the "9999" to "60"

Actually, if you change them both to 60, it won't change anything... you probably want:

Code: [Select]
// Maximum age of messages, no more than 60.
$search_params['maxage'] = min(!empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'], 60);

And:

Code: [Select]
<td>
', $txt['search_between'], '&nbsp;<input type="text" name="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="2" />&nbsp;', $txt['search_and'], '&nbsp;<input type="text" name="maxage" value="', empty($context['search_params']['maxage']) ? '60' : $context['search_params']['maxage'], '" size="5" maxlength="2" /> ', $txt[579], '.

This will make the max days 60.

-[Unknown]

Offline Fizzy

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,676
  • Gender: Male
  • SMF World Domination
Re: Limiting 'Search' performance
« Reply #5 on: September 17, 2004, 07:38:42 PM »
Ahh, let me guess ....

The changes I proposed might of changed the figure that automaticly appeared in the search screen but woudln't of made a blind bit of differnce to how the search was carried out?

* Fizzy smacks himself with a herring  >:(


[Unknown] Thanks for taking the time to help me out. You are one smart cookie  8)
"Reality is merely an illusion, albeit a very persistent one." - A.E.


Offline Ben_S

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,702
  • xxx
Re: Limiting 'Search' performance
« Reply #6 on: September 17, 2004, 07:43:04 PM »
Hmm, I thought he was a session :p
Liverpool FC Forum with 14 million+ posts.

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Limiting 'Search' performance
« Reply #7 on: September 17, 2004, 07:43:57 PM »
The changes I proposed might of changed the figure that automaticly appeared in the search screen but woudln't of made a blind bit of differnce to how the search was carried out?

Well... uuhh, yeah basically.  Or, if they typed 9999 it would actually limit it to that many days....

And I'm not a session or a cookie, I'm a cache!

-[Unknown]

Offline Fizzy

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,676
  • Gender: Male
  • SMF World Domination
Re: Limiting 'Search' performance
« Reply #8 on: September 18, 2004, 03:59:21 AM »
LOL !
"Reality is merely an illusion, albeit a very persistent one." - A.E.