SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 22/01/2019, 10:45 PM   #1
SkyFlare
Huge Clucker
 
SkyFlare's Avatar
 
Join Date: Apr 2015
Location: NZ
Posts: 221
Reputation: 43
Default MySQL Long Unloading

So recently, I made some MySQL saving/loading and more to the point added features
if I comment out a few of these ongamemodeinit, it unloads fine, fast as hell
but when ive got all these 5 mysql systems running, im waiting infinitely, last unload tested, was over 13 mins so i canceled it, exited out the server window

MySQL just seems to be taking a very long time to unload this stuff, which is really bothering me,
all MAX_JOBPICKUPS , MAX_MISCPICKUPS etc are only set to 99, to try attempt to see if its the larger numbers, but im seeing no result..., I was thinking maybe my computer just cant handle it
Heres my PC Specs
Code:
CPU:
AMD A8-7410 APU with AMD Radeon R5 Graphics (4 CPUs), ~2.2GHz

GPU(Integrated into AMD CPU):
Display Memory: 4574 MB
Dedicated Memory: 1006 MB
Shared Memory: 3567 MB
Current Mode: 1366 x 768 (32 bit) (60Hz)

RAM:
8192MB RAM single slot

HDD:
Drive: C:
Free Space: 84.2 GB
Total Space: 121.5 GB
File System: NTFS
Model: TS128GSSD230S (SSD)
And here is the codes im trying to run
pawn Code:
public OnGameModeInit()
{
    LoadJobPickups();
    LoadMiscPickups();
    LoadJobVehicles();
    LoadDynamicDoors();
    LoadDynamicWeed();
    return 1;
}

LoadJobPickups()
{
    printf("===================================================================");
    printf("|+|+|+|+|+| Loading Job Pickups From the MySQL Database |+|+|+|+|+|");
    printf("===================================================================");
    new rows;
    new Cache:result;
    result = mysql_query(g_SQL, "SELECT * FROM `jobpickups` ORDER BY `id` ASC");
    if(cache_get_row_count(rows))
    {
        for(new r = 0; r < rows && r < MAX_JOBPICKUPS; r++)
        {
            cache_get_value_name_int(r, "id", JobPickupInfo[r][ID]);
            //cache_get_value_name(r, "jobtext", JobPickupInfo[r][NameText]);
            cache_get_value_name(r, "jobtext", JobPickupInfo[r][NameText], 28);
            cache_get_value_name_int(r, "modelid", JobPickupInfo[r][ModelID]);
            cache_get_value_name_float(r, "x", JobPickupInfo[r][PosX]);
            cache_get_value_name_float(r, "y", JobPickupInfo[r][PosY]);
            cache_get_value_name_float(r, "z", JobPickupInfo[r][PosZ]);
            cache_get_value_name_int(r, "worldid", JobPickupInfo[r][WorldID]);
            cache_get_value_name_int(r, "interiorid", JobPickupInfo[r][InteriorID]);
            cache_get_value_name_int(r, "vehicleid", JobPickupInfo[r][VehicleID]);

            cache_get_value_name_float(r, "streamdistance", JobPickupInfo[r][StreamDistance]);

            JobPickupInfo[r][NameTextLabel] = Text3D:INVALID_3DTEXT_ID;
            JobPickupInfo[r][Pickup] = -1;
            JobPickupInfo[r][Exists] = 1;
            printf("Job Pickup [%i] - %s: ModelID: %i | WorldID: %i | InteriorID: %i | Coordinate X: %0.f | Coordinate Y: %0.f | Coordinate Z: %0.f", JobPickupInfo[r][ID], JobPickupInfo[r][NameText], JobPickupInfo[r][ModelID], JobPickupInfo[r][WorldID], JobPickupInfo[r][InteriorID], JobPickupInfo[r][PosX], JobPickupInfo[r][PosY], JobPickupInfo[r][PosZ]);
            SyncJobPickup(r);
        }
    }
    printf("%i Job Pickup(s) loaded from the Database!", rows);
    cache_delete(result);
    return 1;
}

LoadMiscPickups()
{
    printf("====================================================================");
    printf("|+|+|+|+|+| Loading Misc Pickups From the MySQL Database |+|+|+|+|+|");
    printf("====================================================================");
    new rows;
    new Cache:result;
    result = mysql_query(g_SQL, "SELECT * FROM `miscpickups` ORDER BY `id` ASC");
    if(cache_get_row_count(rows))
    {
        for(new r = 0; r < rows && r < MAX_MISCPICKUPS; r++)
        {
            cache_get_value_name_int(r, "id", MiscPickupInfo[r][ID]);
            cache_get_value_name(r, "misctext", MiscPickupInfo[r][NameText], 28);
            cache_get_value_name_int(r, "modelid", MiscPickupInfo[r][ModelID]);
            cache_get_value_name_float(r, "x", MiscPickupInfo[r][PosX]);
            cache_get_value_name_float(r, "y", MiscPickupInfo[r][PosY]);
            cache_get_value_name_float(r, "z", MiscPickupInfo[r][PosZ]);
            cache_get_value_name_int(r, "worldid", MiscPickupInfo[r][WorldID]);
            cache_get_value_name_int(r, "interiorid", MiscPickupInfo[r][InteriorID]);

            cache_get_value_name_float(r, "streamdistance", MiscPickupInfo[r][StreamDistance]);

            MiscPickupInfo[r][NameTextLabel] = Text3D:INVALID_3DTEXT_ID;
            MiscPickupInfo[r][Pickup] = -1;
            MiscPickupInfo[r][Exists] = 1;
            printf("Misc Pickup [%i] - %s: ModelID: %i | WorldID: %i | InteriorID: %i | Coordinate X: %0.f | Coordinate Y: %0.f | Coordinate Z: %0.f", MiscPickupInfo[r][ID], MiscPickupInfo[r][NameText], MiscPickupInfo[r][ModelID], MiscPickupInfo[r][WorldID], MiscPickupInfo[r][InteriorID], MiscPickupInfo[r][PosX], MiscPickupInfo[r][PosY], MiscPickupInfo[r][PosZ]);
            SyncMiscPickup(r);
        }
    }
    printf("%i Misc Pickup(s) loaded from the Database!", rows);
    cache_delete(result);
    return 1;
}

LoadJobVehicles()
{
    printf("====================================================================");
    printf("|+|+|+|+|+| Loading Job Vehicles From the MySQL Database |+|+|+|+|+|");
    printf("====================================================================");
    new rows;
    new Cache:result;
    new jobnametext[24];
    new jobsettospawn[24];
    result = mysql_query(g_SQL, "SELECT * FROM `jobvehicles` ORDER BY `id` ASC");
    if(cache_get_row_count(rows))
    {
        for(new r = 0; r < rows && r < MAX_JOBVEHICLES; r++)
        {
            cache_get_value_name_int(r, "id", JobVehicleInfo[r][ID]);
            cache_get_value_name_int(r, "jobid", JobVehicleInfo[r][JobID]);
            cache_get_value_name_int(r, "vehmodelid", JobVehicleInfo[r][VehModelID]);
            cache_get_value_name_float(r, "vehx", JobVehicleInfo[r][VehPosX]);
            cache_get_value_name_float(r, "vehy", JobVehicleInfo[r][VehPosY]);
            cache_get_value_name_float(r, "vehz", JobVehicleInfo[r][VehPosZ]);
            cache_get_value_name_float(r, "veha", JobVehicleInfo[r][VehPosA]);
            cache_get_value_name_int(r, "vehcolor1", JobVehicleInfo[r][VehColor1]);
            cache_get_value_name_int(r, "vehcolor2", JobVehicleInfo[r][VehColor2]);
            cache_get_value_name_int(r, "vehrespawndelay", JobVehicleInfo[r][VehRespawnDelay]);
            cache_get_value_name_int(r, "vehaddsiren", JobVehicleInfo[r][VehAddSiren]);
            cache_get_value_name_int(r, "vehsettospawn", JobVehicleInfo[r][VehSetToSpawn]);
            cache_get_value_name_int(r, "vehspawned", JobVehicleInfo[r][VehSpawned]);
            JobVehicleInfo[r][VehSpawned] = 1;
            switch(JobVehicleInfo[r][JobID])
            {
                case 1:
                {
                    jobnametext = "Drug Dealer";
                }
                case 2:
                {
                    jobnametext = "Street Cleaner";
                }
            }
            switch(JobVehicleInfo[r][VehSetToSpawn])
            {
                case 0:
                {
                    jobsettospawn = "False";
                }
                case 1:
                {
                    jobsettospawn = "True";
                }
            }
            DestroyVehicle(JobVehicleInfo[r][VehData]);
            printf("Job Vehicle [%i] - %s: VehModelID: %i | Set To Spawn: %s | Coordinate X: %0.f | Coordinate Y: %0.f | Coordinate Z: %0.f", JobVehicleInfo[r][ID], jobnametext, JobVehicleInfo[r][VehModelID], jobsettospawn, JobVehicleInfo[r][VehPosX], JobVehicleInfo[r][VehPosY], JobVehicleInfo[r][VehPosZ]);
            SyncJobVehicle(r);
        }
    }
    printf("%i Total Job Vehicle(s) Loaded from the Database!",rows);
    cache_delete(result);
    return 1;
}

LoadDynamicDoors()
{
    printf("=====================================================================");
    printf("|+|+|+|+|+| Loading Dynamic Doors From the MySQL Database |+|+|+|+|+|");
    printf("=====================================================================");
    new rows;
    new Cache:result;
    new doorlocked[24];
    result = mysql_query(g_SQL, "SELECT * FROM `dynamicdoors` ORDER BY `id` ASC");
    if(cache_get_row_count(rows))
    {
        for(new r = 0; r < rows && r < MAX_DYNAMICDOORS; r++)
        {
            cache_get_value_name_int(r, "id", DynamicDoors[r][ID]);
            cache_get_value_name(r, "outsidedoortitle", DynamicDoors[r][OutsideDoorTitle], 28);
            cache_get_value_name(r, "insidedoortitle", DynamicDoors[r][InsideDoorTitle], 28);
            cache_get_value_name_int(r, "locked", DynamicDoors[r][Locked]);

            cache_get_value_name_float(r, "pos_x", DynamicDoors[r][PosX]);
            cache_get_value_name_float(r, "pos_y", DynamicDoors[r][PosY]);
            cache_get_value_name_float(r, "pos_z", DynamicDoors[r][PosZ]);
            cache_get_value_name_float(r, "pos_a", DynamicDoors[r][PosA]);

            cache_get_value_name_float(r, "int_x", DynamicDoors[r][IntX]);
            cache_get_value_name_float(r, "int_y", DynamicDoors[r][IntY]);
            cache_get_value_name_float(r, "int_z", DynamicDoors[r][IntZ]);
            cache_get_value_name_float(r, "int_a", DynamicDoors[r][IntA]);

            cache_get_value_name_int(r, "insideinteriorid", DynamicDoors[r][InsideInteriorID]);
            cache_get_value_name_int(r, "insidevwid", DynamicDoors[r][InsideVWID]);
            cache_get_value_name_int(r, "outsideinteriorid", DynamicDoors[r][OutsideInteriorID]);
            cache_get_value_name_int(r, "outsidevwid", DynamicDoors[r][OutsideVWID]);

            DynamicDoors[r][Exists] = 1;
            DynamicDoors[r][DoorInsideObject] = -1;
            DynamicDoors[r][DoorOutsideObject] = -1;
            DynamicDoors[r][DoorInsideTitleText] = Text3D:INVALID_3DTEXT_ID;
            DynamicDoors[r][DoorOutsideTitleText] = Text3D:INVALID_3DTEXT_ID;
            switch(DynamicDoors[r][Locked])
            {
                case 0:
                {
                    doorlocked = "False";
                }
                case 1:
                {
                    doorlocked = "True";
                }
            }
            printf("Dynamic Door [%i] - %s: Locked: %s | WorldID: %i | InteriorID: %i | Coordinate X: %0.f | Coordinate Y: %0.f | Coordinate Z: %0.f", DynamicDoors[r][ID], DynamicDoors[r][OutsideDoorTitle], doorlocked, DynamicDoors[r][OutsideVWID], DynamicDoors[r][OutsideInteriorID], DynamicDoors[r][PosX], DynamicDoors[r][PosY], DynamicDoors[r][PosZ]);
            SyncDynamicDoors(r);
        }
    }
    printf("%i Dynamic Door(s) loaded from the Database!", rows);
    cache_delete(result);
    return 1;
}

LoadDynamicWeed()
{
    printf("========================================================================");
    printf("|+|+|+|+|+| Loading Marijuana Plants From the MySQL Database |+|+|+|+|+|");
    printf("========================================================================");
    new string[128];
    new rows;
    new Cache:result;
    result = mysql_query(g_SQL, "SELECT * FROM `dynamicweed` ORDER BY `id` ASC");
    if(cache_get_row_count(rows))
    {
        for(new r = 0; r < rows && r < MAX_WEEDPLANTS; r++)
        {
            cache_get_value_name(r, "Planter", WeedInfo[r][grName]);
            cache_get_value_name_int(r, "Grams", WeedInfo[r][grGrams]);
            cache_get_value_name_int(r, "Time", WeedInfo[r][grTime]);
            cache_get_value_name_int(r, "Time2", WeedInfo[r][grTime2]);
            cache_get_value_name_float(r, "X", WeedInfo[r][grX]);
            cache_get_value_name_float(r, "Y", WeedInfo[r][grY]);
            cache_get_value_name_float(r, "Z", WeedInfo[r][grZ]);
            WeedInfo[r][grExist] = true;
            WeedInfo[r][grObj] = CreateDynamicObject(3409, WeedInfo[r][grX], WeedInfo[r][grY], WeedInfo[r][grZ]-1, 0.0, 0.0, 0.0);
            format(string, sizeof(string), "[%d] {33CCFF}Marijuana Plant | %d Buds | Planter: %s{FFFFFF}", r, WeedInfo[r][grGrams], WeedInfo[r][grName]);
            WeedInfo[r][grLabel] = Create3DTextLabel(string, 0xFFFFFFFF, WeedInfo[r][grX], WeedInfo[r][grY], WeedInfo[r][grZ], 15, 0, 1);
            printf("Marijuana Plant [%i] - Planter: %s | Grams: %i | Exists: True | Coordinate X: %0.f | Coordinate Y: %0.f | Coordinate Z: %0.f", r, WeedInfo[r][grName], WeedInfo[r][grGrams], WeedInfo[r][grX], WeedInfo[r][grY], WeedInfo[r][grZ]);
        }
    }
    format(string, sizeof(string), "[%d] {33CCFF}Marijuana Plant | %d Buds | Planter: %s{FFFFFF}", 0, WeedInfo[0][grGrams], WeedInfo[0][grName]);
    WeedInfo[0][grLabel] = Create3DTextLabel(string, 0xFFFFFFFF, WeedInfo[0][grX], WeedInfo[0][grY], WeedInfo[0][grZ], 15, 0, 1);
    printf("%i Marijuana Plant(s) loaded from the Database!", rows);
    SetTimer("Minus1Second", 905, true);
    cache_delete(result);
    return 1;
}
__________________
Purchasable Scripting Services Available, Inbox me with your Requests.
My Project Progress Tracker
My Work
Link
Information
S-Store System V2 LinkIngame Store in Dialogs
SkyFlare is offline   Reply With Quote
Old 23/01/2019, 06:01 AM   #2
rockys
Big Clucker
 
Join Date: Oct 2018
Location: pawn
Posts: 67
Reputation: 0
Default Re: MySQL Long Unloading

For(new r = 0;r < rows; r++)
rockys is offline   Reply With Quote
Old 23/01/2019, 08:24 AM   #3
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,228
Reputation: 205
Default Re: MySQL Long Unloading

`id` from all tables must be PRIMARY KEY otherwise sorting with a non-indexed will be slow.

If log level is set to DEBUG will be slower, change it to ERROR | WARNING | INFO so you can be able to see how much time it takes to execute these queries and track down the slow queries.

Change to threaded queries so the main thread will not have to wait for these to load.
Calisthenics is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Truck Unloading Help Genmetal Scripting Help 5 17/04/2015 11:58 AM
Server crashing when unloading MySQL. BigGroter Scripting Help 10 24/07/2013 12:54 PM
Unloading problem! lQs Scripting Help 10 13/05/2013 01:13 PM
Unloading filterscripts _rAped Help Archive 4 30/12/2010 12:01 PM


All times are GMT. The time now is 08:29 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.