Welcome Guest, Not a member yet? Register   Sign In
Tips for faster CI Applications
#11

[eluser]Andreas Bergström[/eluser]
[quote author="ggoforth" date="1248055892"][quote author="Andreas Bergström" date="1248055629"][quote author="slowgary" date="1248054750"]Yorick...

Why is the second if() faster?[/quote]

No, he says the second one is slower. The reason is in the first one num_rows get executed only once and stored in a variable. In the second one num_rows is executed every single loop, which obviously is less effective (since the number of rows in the returned sql query is static).[/quote]

In his example I don't see any loop involved. I know when I use this kind of coding it's to check and see if a database resource exists (anything was selected) before running the result through a loop. In that case (where there is no loop involved) is the first if() still faster? It's more code, and more evaluations to complete, so it seems like it would be slower. I'm certainly not an expert on this kind of thing, so this is mostly just what it looks like on the surface to me. Smile

Greg[/quote]

Opsie, you're right, sorry. My sleepy eyes saw a while-loop.

Now I'm also wondering. Smile
#12

[eluser]Derek Allard[/eluser]
We posted our performance guidelines if you're interested.
#13

[eluser]Mareshal[/eluser]
thanks a lot guys




Theme © iAndrew 2016 - Forum software by © MyBB