Jump to content

speed or resource of a selector


bwakad
 Share

Recommended Posts

I don't know exactly where I read it, but it was saying that find() is less heavy as get().

Then I also notice some people are able to tell what is heavier for server requests.

Now, looking at my selector - which fetch all children of children - I would like to know how you can tell if this is good practise, considering speed and request. And by what program you can tell.

$myparent = $pages->find("parent=/province/");
foreach ($pages->find("parent=$myparent") as $value) {
    echo $value->title;
}
Link to comment
Share on other sites

find will find many (or even all!) things if they exist unless you limit it. This will put a strain on your servers and PHP may even timeout. get, will only get one thing...so, less resource hungry. 
 
The general rule is that when using find, you need to use limit=xx. You can always paginate your results if you need more to be fetched. But, if you are sure that the number of children will not grow, and that you have a set reasonable number of children, then you can avoid the limit

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...