SA-MP Forums Archive
Looping on Data vs Fetching from a database - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Looping on Data vs Fetching from a database (/showthread.php?tid=542263)



Looping on Data vs Fetching from a database - Neil. - 18.10.2014

You see, I was making a /stats command. In this command, the player would be able to see the houses that he bought. Now, would it be better looping through thousands of houses just to find his house, or fetching the house data from a table right there?

I'm basically weighing down the different scenarios to (possibly) avoid the worst execution time in the command.


Re: Looping on Data vs Fetching from a database - Eth - 18.10.2014

fetching the house data from a table right there for sure, a loop that is almost infinite has a big chance to crash your server and you don't want that , right?


Re: Looping on Data vs Fetching from a database - Neil. - 18.10.2014

Quote:
Originally Posted by Eth
Посмотреть сообщение
fetching the house data from a table right there for sure, a loop that is almost infinite has a big chance to crash your server and you don't want that , right?
That was my first impression too (I don't know how I came up that looping is more efficient than constantly fetching). Given your input, I'll be applying the latter.
Thanks!