SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 31/01/2019, 04:15 AM   #1
SkyFlare
Huge Clucker
 
SkyFlare's Avatar
 
Join Date: Apr 2015
Location: NZ
Posts: 221
Reputation: 43
Default MySQL Optimization for Server

So i am getting a "hang" when i exit the server in the server.exe
heres what kind of functions I have ongamemodeinit, that i believe are slowing me down
I aim to ask for some points in the right direction to enhance my coding, better my mysql knowledge and improve this script method im using

ALSO: is there anyway to replace for( with foreach(? ive been trying for a while now, because ive had problems without foreach with playerids etc in the past and have had to recode to foreach
pawn Code:
LoadMySQLTable()
{
    printf("===================================================================");
    printf("|+|+|+|+|+| Loading mysqltable From the MySQL Database |+|+|+|+|+|");
    printf("===================================================================");
    new rows;
    mysql_query(g_SQL, "SELECT * FROM `mysqltable` ORDER BY `id` ASC");
    if(cache_get_row_count(rows))
    {
        for(new r = 0; r < rows && r < MAX_MYSQLTABLEROWS; r++)
        {
        }
    }
    printf("%i MYSQLTABLE rows loaded from the Database!", rows);
    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 31/01/2019, 05:05 AM   #2
SkyFlare
Huge Clucker
 
SkyFlare's Avatar
 
Join Date: Apr 2015
Location: NZ
Posts: 221
Reputation: 43
Default Re: MySQL Optimization for Server

Quote:
Originally Posted by ****** View Post
Profile it and read "use the index Luke".
thank you, will read through this, found the website and am beginning to read it awesome!
__________________
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 31/01/2019, 07:32 AM   #3
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,228
Reputation: 205
Default Re: MySQL Optimization for Server

Quote:
Originally Posted by SkyFlare View Post
So i am getting a "hang" when i exit the server in the server.exe
https://wiki.sa-mp.com/wiki/MySQL#mysql_close

Quote:
mysql_close will always wait until all queued queries are executed, thus halting the server.
Update data when they change, do not update EVERYTHING when the server closes. Less queries and less data to update at that time will reduce the "hang" time.
Calisthenics is offline   Reply With Quote
Old 31/01/2019, 10:32 AM   #4
SkyFlare
Huge Clucker
 
SkyFlare's Avatar
 
Join Date: Apr 2015
Location: NZ
Posts: 221
Reputation: 43
Default Re: MySQL Optimization for Server

Quote:
Originally Posted by Calisthenics View Post
Update data when they change, do not update EVERYTHING when the server closes. Less queries and less data to update at that time will reduce the "hang" time.
I do this anyway.... :P thanks though....

the "hang" im getting is when the server closes, but when the server closes, there shouldnt be much to append to MySQL as it changes as im updating.

I just read Data from MYSQL to display it currently and create the objects/data associated to the values, it doesnt get changed.

like Loading Default Gang HQ entrances,
faction/family IDS and all the custom rank names, car colors etc.

then i setup pickups for the xyz pos saved in mysql, all that stuff, only data that really changes is the player data.

but the GM ive started off of was pBlueG's recent login_system-cache.pwn

And it was fine closing when i first got the script haha
__________________
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 31/01/2019, 11:04 AM   #5
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,228
Reputation: 205
Default Re: MySQL Optimization for Server

https://wiki.sa-mp.com/wiki/MySQL#my...cessed_queries

Check how many queries are in queque when the server closes. Set log level to ERROR | WARNING | INFO and check how long it takes to execute these queries. Using ALL log level will be slower.
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
MySQL gurus needed! (Optimization) -Prodigy- Scripting Help 4 01/02/2012 12:02 PM
MySQL/Memory optimization Germanator Help Archive 3 18/06/2011 03:33 AM
MYSQL Optimization ombre Help Archive 0 20/02/2011 04:33 AM
MySql (optimization) DRIFT_HUNTER Help Archive 5 18/01/2011 09:05 AM
A Little mysql optimization wups Help Archive 9 15/10/2010 04:43 PM


All times are GMT. The time now is 03:05 AM.


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