SA-MP Forums Archive
[HELP] Increasing MySQL efficiency. - 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: [HELP] Increasing MySQL efficiency. (/showthread.php?tid=485901)



[HELP] Increasing MySQL efficiency. - yanir3 - 06.01.2014

I have a shitton of houses on my RP MySQL-based server. This is how I load them when the server is starting up:

PHP код:
      mysql_query("SELECT `ID` FROM `houses`");
       
mysql_store_result();
       new 
id[128], housearray[MAX_HOUSES], bizzarray[MAX_BIZZES], ch=0cb=0;
     while(
mysql_fetch_row_format(id)) {
         
housearray[ch] = strval(id);
         
ch++;
     }
mysql_free_result(); 
Then:
PHP код:
for(new 0c<chc++) LoadHouse(housearray[c]); 
LoadHouse function is basically querying
PHP код:
SELECT FROM `housesWHERE `ID` = '%d' 
For every house.
And then I use
PHP код:
mysql_fetch_field_row(temp"ID"), hInfo[house_num][ID] = strval(temp); 
for every data related to the house storing it in the memory.

Is there anyway to make much less queries so I can load the server MUCH faster? I'm not a MySQL expert so I have no idea how to.


Re: [HELP] Increasing MySQL efficiency. - woot - 06.01.2014

Instead of selecting all house IDs and then sending numerous queries for every single house, you should just send one query that receives all house information at once.

pawn Код:
mysql_query("SELECT * FROM `houses`");