[MySQL]Fast loading
#1

Код:
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 ?
Reply
#2

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

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

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 ?
Reply
#5

Mysql_Fetch_Row
Reply
#6

Can you give me an example how to use ?
Reply
#7

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.
Reply
#8

I preffer to remain at MySQL
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)