mysql table doesn't load/save, or load take very long time
#1

Hey
I have a very big problem with my saving/loading system on mysql R41 :/

When I start the server, it take very long time to load data and some table doesn't load with each others

I have put this in OnGameModeInit :

Quote:

mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_bizz","bizz_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_uniquebizz","uniquebizz_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_houses","house_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_houses_furnitures","house_LoadFurnitur es");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_vehicles","vehicle_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_camera","camera_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_factions_polices","police_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_factions_polices_fines","police_FineLoad");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_factions_governements","governement_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_factions_sannews WHERE id=1","sannews_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_factions_illegals","faction_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_factions_illegals_seeds","seed_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_factions_illegals_tags","tag_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_garages","garage_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_stop","stop_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_atms","atm_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_distribs","distrib_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_trash","trash_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_bins","bin_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_phones","phonecab_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_maps","map_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_gps","gps_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_signs","sign_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_spawn","spawn_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_interiors","interior_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_dealership","dealerShip_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_tree","tree_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_zones","zone_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_gates","gate_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_drops","drop_Load");
mysql_pquery(MYSQL,"SELECT * FROM lvrp_server_ads","ad_Load");

Some tables like "vehicle_Load" don't want to load

This is the vehicle_Load :

Quote:

forward vehicle_Load();
public vehicle_Load()
{
new tmpVehicles=1;
cache_get_row_count(tmpVehicles);
for (new i=0; i<tmpVehicles; i++)
{
/*if(cache_get_value_name_int(i,"Type") == CAR_OWN) // Vйhicules joueurs
{continue;}*/
cache_get_value_name_int(i,"id", vehicle[totalVehicles][SQLID]);
cache_get_value_name_int(i,"Model", vehicle[totalVehicles][cModel]);
cache_get_value_name_float(i,"Pos_x", vehicle[totalVehicles][cLocationx]);
cache_get_value_name_float(i,"Pos_y", vehicle[totalVehicles][cLocationy]);
cache_get_value_name_float(i,"Pos_z", vehicle[totalVehicles][cLocationz]);
cache_get_value_name_float(i,"Angle", vehicle[totalVehicles][cAngle]);
cache_get_value_name_int(i,"Color1", vehicle[totalVehicles][cColorOne]);
cache_get_value_name_int(i,"Color2", vehicle[totalVehicles][cColorTwo]);
cache_get_value_name(i,"Owner",vehicle[totalVehicles][cOwner], 32);
cache_get_value_name_int(i,"SQLID", vehicle[totalVehicles][ownerSQLID]);
cache_get_value_name(i,"Description",vehicle[totalVehicles][cDescription], 12;
cache_get_value_name_int(i,"Price", vehicle[totalVehicles][cValue]);
cache_get_value_name(i,"License",vehicle[totalVehicles][cLicense], 24);
cache_get_value_name_int(i,"Owned", vehicle[totalVehicles][cOwned]);
cache_get_value_name_int(i,"Locked", vehicle[totalVehicles][cLock]);
cache_get_value_name_int(i,"Statut", vehicle[totalVehicles][cStatut]);
cache_get_value_name_int(i,"Type", vehicle[totalVehicles][cType]);
cache_get_value_name_float(i,"Armour", vehicle[totalVehicles][cArmour]);
cache_get_value_name_int(i,"Rob", vehicle[totalVehicles][cRob]);
cache_get_value_name_int(i,"Neon", vehicle[totalVehicles][cNeon]);
cache_get_value_name_int(i,"Gas", vehicle[totalVehicles][cGas]);
cache_get_value_name_int(i,"Mod1", vehicle[totalVehicles][tExhausts]);
cache_get_value_name_int(i,"Mod2", vehicle[totalVehicles][tFrontBumper]);
cache_get_value_name_int(i,"Mod3", vehicle[totalVehicles][tRearBumper]);
cache_get_value_name_int(i,"Mod4", vehicle[totalVehicles][tRoof]);
cache_get_value_name_int(i,"Mod5", vehicle[totalVehicles][tSpoilers]);
cache_get_value_name_int(i,"Mod6", vehicle[totalVehicles][tSideBumper]);
cache_get_value_name_int(i,"Mod7", vehicle[totalVehicles][tWheels]);
cache_get_value_name_int(i,"Mod8", vehicle[totalVehicles][tHydraulics]);
cache_get_value_name_int(i,"Mod9", vehicle[totalVehicles][tNitro]);
cache_get_value_name_int(i,"Mod10", vehicle[totalVehicles][tSideBumper2]);
cache_get_value_name_int(i,"PaintJob", vehicle[totalVehicles][paintjob]);
cache_get_value_name_int(i,"Interior", vehicle[totalVehicles][cInt]);
cache_get_value_name_int(i,"VW", vehicle[totalVehicles][cVW]);
cache_get_value_name_int(i,"Meter", vehicle[totalVehicles][cMeter]);
cache_get_value_name_int(i,"KiloMeter", vehicle[totalVehicles][cKiloMeter]);
cache_get_value_name_int(i,"Cash", vehicle[totalVehicles][cCash]);
cache_get_value_name_int(i,"Rank", vehicle[totalVehicles][cRank]);
cache_get_value_name_int(i,"JobCity", vehicle[totalVehicles][cJobCity]);
cache_get_value_name_int(i,"Brid", vehicle[totalVehicles][cBrid]);
cache_get_value_name_int(i,"Tires", vehicle[totalVehicles][cTires]);
cache_get_value_name_int(i,"Panels", vehicle[totalVehicles][cPanels]);
cache_get_value_name_int(i,"Doors", vehicle[totalVehicles][cDoors]);
cache_get_value_name_int(i,"Lights", vehicle[totalVehicles][cLights]);
cache_get_value_name_float(i,"Health", vehicle[totalVehicles][cHealth]);
cache_get_value_name_int(i,"Wep1", vehicle[totalVehicles][cWep][0]);
cache_get_value_name_int(i,"Ammo1", vehicle[totalVehicles][cAmmo][0]);
cache_get_value_name_int(i,"Wep2", vehicle[totalVehicles][cWep][1]);
cache_get_value_name_int(i,"Ammo2", vehicle[totalVehicles][cAmmo][1]);
cache_get_value_name_int(i,"Wep3", vehicle[totalVehicles][cWep][2]);
cache_get_value_name_int(i,"Ammo3", vehicle[totalVehicles][cAmmo][2]);
cache_get_value_name_int(i,"Wep4", vehicle[totalVehicles][cWep][3]);
cache_get_value_name_int(i,"Ammo4", vehicle[totalVehicles][cAmmo][3]);
cache_get_value_name_int(i,"Wep5", vehicle[totalVehicles][cWep][4]);
cache_get_value_name_int(i,"Ammo5", vehicle[totalVehicles][cAmmo][4]);
cache_get_value_name_int(i,"Wep6", vehicle[totalVehicles][cWep][5]);
cache_get_value_name_int(i,"Ammo6", vehicle[totalVehicles][cAmmo][5]);
cache_get_value_name_int(i,"Wep7", vehicle[totalVehicles][cWep][6]);
cache_get_value_name_int(i,"Ammo7", vehicle[totalVehicles][cAmmo][6]);
cache_get_value_name_int(i,"Wep8", vehicle[totalVehicles][cWep][7]);
cache_get_value_name_int(i,"Ammo8", vehicle[totalVehicles][cAmmo][7]);
cache_get_value_name_int(i,"Wep9", vehicle[totalVehicles][cWep][8]);
cache_get_value_name_int(i,"Ammo9", vehicle[totalVehicles][cAmmo][8]);
cache_get_value_name_int(i,"Wep10", vehicle[totalVehicles][cWep][9]);
cache_get_value_name_int(i,"Ammo10", vehicle[totalVehicles][cAmmo][9]);

cache_get_value_name_int(i,"iM1", vehicle[totalVehicles][cItemM][0]);
cache_get_value_name_int(i,"iQ1", vehicle[totalVehicles][cItemQ][0]);
cache_get_value_name_int(i,"iM2", vehicle[totalVehicles][cItemM][1]);
cache_get_value_name_int(i,"iQ2", vehicle[totalVehicles][cItemQ][1]);
cache_get_value_name_int(i,"iM3", vehicle[totalVehicles][cItemM][2]);
cache_get_value_name_int(i,"iQ3", vehicle[totalVehicles][cItemQ][2]);
cache_get_value_name_int(i,"iM4", vehicle[totalVehicles][cItemM][3]);
cache_get_value_name_int(i,"iQ4", vehicle[totalVehicles][cItemQ][3]);
cache_get_value_name_int(i,"iM5", vehicle[totalVehicles][cItemM][4]);
cache_get_value_name_int(i,"iQ5", vehicle[totalVehicles][cItemQ][4]);
cache_get_value_name_int(i,"iM6", vehicle[totalVehicles][cItemM][5]);
cache_get_value_name_int(i,"iQ6", vehicle[totalVehicles][cItemQ][5]);
cache_get_value_name_int(i,"iM7", vehicle[totalVehicles][cItemM][6]);
cache_get_value_name_int(i,"iQ7", vehicle[totalVehicles][cItemQ][6]);
cache_get_value_name_int(i,"iM8", vehicle[totalVehicles][cItemM][7]);
cache_get_value_name_int(i,"iQ8", vehicle[totalVehicles][cItemQ][7]);
cache_get_value_name_int(i,"iM9", vehicle[totalVehicles][cItemM][8]);
cache_get_value_name_int(i,"iQ9", vehicle[totalVehicles][cItemQ][8]);
cache_get_value_name_int(i,"iM10", vehicle[totalVehicles][cItemM][9]);
cache_get_value_name_int(i,"iQ10", vehicle[totalVehicles][cItemQ][9]);
cache_get_value_name_int(i,"iM11", vehicle[totalVehicles][cItemM][10]);
cache_get_value_name_int(i,"iQ11", vehicle[totalVehicles][cItemQ][10]);
cache_get_value_name_int(i,"iM12", vehicle[totalVehicles][cItemM][11]);
cache_get_value_name_int(i,"iQ12", vehicle[totalVehicles][cItemQ][11]);
cache_get_value_name_int(i,"iM13", vehicle[totalVehicles][cItemM][12]);
cache_get_value_name_int(i,"iQ13", vehicle[totalVehicles][cItemQ][12]);
cache_get_value_name_int(i,"iM14", vehicle[totalVehicles][cItemM][13]);
cache_get_value_name_int(i,"iQ14", vehicle[totalVehicles][cItemQ][13]);
cache_get_value_name_int(i,"iM15", vehicle[totalVehicles][cItemM][14]);
cache_get_value_name_int(i,"iQ15", vehicle[totalVehicles][cItemQ][14]);
vehicle[totalVehicles][cBody]=-1;
vehicle[totalVehicles][used] = 1;
vehicle[totalVehicles][cWindows][0]=false;
vehicle[totalVehicles][cWindows][1]=false;
vehicle[totalVehicles][cWindows][2]=false;
vehicle[totalVehicles][cWindows][3]=false;

if(vehicle[totalVehicles][cHealth] < 350)
{vehicle[totalVehicles][cHealth]=1000;}

if(vehicle[totalVehicles][cType] == CAR_OWN)
{
SafeSetVehicleHealth(totalVehicles,vehicle[totalVehicles][cHealth]);
UpdateVehicleDamageStatus(totalVehicles,vehicle[totalVehicles][cPanels],vehicle[totalVehicles][cDoors],vehicle[totalVehicles][cLights],vehicle[totalVehicles][cTires]);
}
else
{vehicle[totalVehicles][cGas] = 100;}

if(vehicle[totalVehicles][cVW] == CAR_INT_DEATH)
{vehicle[totalVehicles][cVW]=0;}
format(vehicle[totalVehicles][stream],256,"Aucun");
if(vehicle[totalVehicles][cType] > 0 && vehicle[totalVehicles][cType] < 10 ) // Siren sur le vйhicule
{AddStaticVehicleEx(vehicle[totalVehicles][cModel],vehicle[totalVehicles][cLocationx],vehicle[totalVehicles][cLocationy],vehicle[totalVehicles][cLocationz]+1.0,vehicle[totalVehicles][cAngle],vehicle[totalVehicles][cColorOne],vehicle[totalVehicles][cColorTwo],-1,1);}
else
{AddStaticVehicleEx(vehicle[totalVehicles][cModel],vehicle[totalVehicles][cLocationx],vehicle[totalVehicles][cLocationy],vehicle[totalVehicles][cLocationz]+1.0,vehicle[totalVehicles][cAngle],vehicle[totalVehicles][cColorOne],vehicle[totalVehicles][cColorTwo],-1);}
if(IsABike(totalVehicles) || IsAMoto(totalVehicles))
{vehicle[totalVehicles][cLock]=0;}
tuning_Load(totalVehicles);
totalVehicles++;
}
return 1;
}

how ?
Reply
#2

How long is "very long"? And is it really necessary to store all this stuff in memory?

The data structure isn't very well thought out either but fixing that will take a lot of planning and work.
Reply
#3

it took like 3 min to load a table

their is the server_log https://pastebin.com/mek3fFhJ

I don't know what's wrong, table like Vehicle don't load
Reply
#4

Why you are using threaded queries on server start?
I see bad database structure too. It may cause slow loading. Use new tables for things like weapon1, weapon2 [...] instead of creating huge number of fields.
Also, cache_get_value_name is slower than cache_get_value_index.
Reply
#5

How I can remake the code ?
Reply
#6

The problem is solve thanks guys

The REAL problem is this https://sampforum.blast.hk/showthread.php?tid=639756
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)