Customizing SMF > Tips and Tricks

Limiting days in search

(1/2) > >>

Fizzy:
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]

A.M.A:
hope this will help:
http://www.simplemachines.org/community/index.php?topic=15460.0
http://www.simplemachines.org/community/index.php?topic=15436.0

Fizzy:
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?

Fizzy:
Oh, not to worry.

I found this in search.php


--- Code: --- // 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'];

--- End code ---

and in search.template.php I found


--- Code: --- <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], '.

--- End code ---

I just changed the "9999" to "60"

[Unknown]:

--- Quote from: Fizzy on September 16, 2004, 07:07:42 PM ---Oh, not to worry.

I found this in search.php


--- Code: --- // 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'];

--- End code ---

and in search.template.php I found


--- Code: --- <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], '.

--- End code ---

I just changed the "9999" to "60"

--- End quote ---

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


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

--- End code ---

And:


--- Code: --- <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], '.

--- End code ---

This will make the max days 60.

-[Unknown]

Navigation

[0] Message Index

[#] Next page

Go to full version