SA-MP Forums Archive
[MySQL]Fast loading - 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: [MySQL]Fast loading (/showthread.php?tid=422729)



[MySQL]Fast loading - cotyzor - 15.03.2013

Код:
function LoadHouses()
{
	new casee=0;
    new idx,string[256];
	mysql_query("SELECT * FROM `houses`");
	mysql_store_result();
	while(mysql_retrieve_row())
	{
	    idx++;
	    mysql_fetch_field_row(string, "ID"); HouseInfo[idx][hID] = strval(string);
	    mysql_fetch_field_row(string, "Entrancex"); HouseInfo[idx][hEntrancex] = floatstr(string);
	    mysql_fetch_field_row(string, "Entrancey"); HouseInfo[idx][hEntrancey] = floatstr(string);
	    mysql_fetch_field_row(string, "Entrancez"); HouseInfo[idx][hEntrancez] = floatstr(string);
		mysql_fetch_field_row(string, "Exitx"); HouseInfo[idx][hExitx] = floatstr(string);
		mysql_fetch_field_row(string, "Exity"); HouseInfo[idx][hExity] = floatstr(string);
		mysql_fetch_field_row(string, "Exitz"); HouseInfo[idx][hExitz] = floatstr(string);
		mysql_fetch_field_row(string, "Healthx"); HouseInfo[idx][hHealthx] = strval(string);
		mysql_fetch_field_row(string, "Healthy"); HouseInfo[idx][hHealthy] = strval(string);
		mysql_fetch_field_row(string, "Healthz"); HouseInfo[idx][hHealthz] = strval(string);
		mysql_fetch_field_row(string, "Armourx"); HouseInfo[idx][hArmourx] = strval(string);
		mysql_fetch_field_row(string, "Armoury"); HouseInfo[idx][hArmoury] = strval(string);
		mysql_fetch_field_row(string, "Armourz"); HouseInfo[idx][hArmourz] = strval(string);
		mysql_fetch_field_row(string, "Owner"); strmid(HouseInfo[idx][hOwner], string, 0, strlen(string), 255);
		mysql_fetch_field_row(string, "Discription"); strmid(HouseInfo[idx][hDiscription], string, 0, strlen(string), 255);
		mysql_fetch_field_row(string, "Value"); HouseInfo[idx][hValue] = strval(string);
		mysql_fetch_field_row(string, "Hel"); HouseInfo[idx][hHel] = strval(string);
		mysql_fetch_field_row(string, "Arm"); HouseInfo[idx][hArm] = strval(string);
		mysql_fetch_field_row(string, "Int"); HouseInfo[idx][hInt] = strval(string);
		mysql_fetch_field_row(string, "Lock"); HouseInfo[idx][hLock] = strval(string);
		mysql_fetch_field_row(string, "Owned"); HouseInfo[idx][hOwned] = strval(string);
		mysql_fetch_field_row(string, "Rooms"); HouseInfo[idx][hRooms] = strval(string);
		mysql_fetch_field_row(string, "Rent"); HouseInfo[idx][hRent] = strval(string);
		mysql_fetch_field_row(string, "Rentabil"); HouseInfo[idx][hRentabil] = strval(string);
		mysql_fetch_field_row(string, "Takings"); HouseInfo[idx][hTakings] = strval(string);
		mysql_fetch_field_row(string, "Vec"); HouseInfo[idx][hVec] = strval(string);
  		if(HouseInfo[idx][hVec] == 457)
		{
			HouseInfo[idx][hVec] = 411;
		}
		mysql_fetch_field_row(string, "Vcol1"); HouseInfo[idx][hVcol1] = strval(string);
		mysql_fetch_field_row(string, "Vcol2"); HouseInfo[idx][hVcol2] = strval(string);
		mysql_fetch_field_row(string, "Date"); HouseInfo[idx][hDate] = strval(string);
		mysql_fetch_field_row(string, "Level"); HouseInfo[idx][hLevel] = strval(string);
		mysql_fetch_field_row(string, "World"); HouseInfo[idx][hWorld] = strval(string);
		mysql_fetch_field_row(string, "Drugs"); HouseInfo[idx][hDrugs] = strval(string);
		mysql_fetch_field_row(string, "Materials"); HouseInfo[idx][hMaterials] = strval(string);
		casee++;
	}
	mysql_free_result();
	printf("-Houses: %d", casee);
	return 1;
}
I'm waiting 1 to 2 minutes to load 170 houses ... What can I do to load more quickly ?


Re: [MySQL]Fast loading - Glad2BeHere - 15.03.2013

use BLUEg MySQL the fastest in the biz otherwise create variable when only already made houses are created


Re: [MySQL]Fast loading - Vince - 15.03.2013

Use threads and caching. Don't use fetch_field_row. String searches are always (a lot?) slower than integer searches.


Re: [MySQL]Fast loading - cotyzor - 15.03.2013

Quote:
Originally Posted by Glad2BeHere
Посмотреть сообщение
use BLUEg MySQL the fastest in the biz otherwise create variable when only already made houses are created
I use BlueG's plugin ...

Quote:
Originally Posted by Vince
Посмотреть сообщение
Use threads and caching. Don't use fetch_field_row. String searches are always (a lot?) slower than integer searches.
When how I can do this ? ... Can you give me an example please ?


Re: [MySQL]Fast loading - Cameltoe - 15.03.2013

Mysql_Fetch_Row


Re: [MySQL]Fast loading - cotyzor - 15.03.2013

Can you give me an example how to use ?


Re: [MySQL]Fast loading - [FSaF]Jarno - 15.03.2013

or just use files. Much faster and MySQL is a bit overkill on SA:MP anyways, because unless you have multiple servers, you don't need the house information to be on MySQL. MySQL is in my opinion only good for communicating between the server and a website, and i don't think that you have to have house information on a website.


Re: [MySQL]Fast loading - cotyzor - 15.03.2013

I preffer to remain at MySQL


Re: [MySQL]Fast loading - Cameltoe - 15.03.2013

Quote:
Originally Posted by cotyzor
Посмотреть сообщение
Can you give me an example how to use ?
Check my threads, iv'e wrote a tutorial about Car script with MySQL.

Quote:
Originally Posted by [FSaF]Jarno
Посмотреть сообщение
or just use files. Much faster and MySQL is a bit overkill on SA:MP anyways, because unless you have multiple servers, you don't need the house information to be on MySQL. MySQL is in my opinion only good for communicating between the server and a website, and i don't think that you have to have house information on a website.
You, Mr. need to read about the efficiency of mysql.