SA-MP Forums

Go Back   SA-MP Forums > SA-MP Server > Server Support

Reply
 
Thread Tools Display Modes
Old 21/09/2017, 11:14 PM   #1
Mister0
Huge Clucker
 
Mister0's Avatar
 
Join Date: Aug 2015
Posts: 220
Reputation: 19
Default Mysql work slow

So why mysql load tables very slow on windows 10?
When I open the console it say mysql database conected instantly but the mysql_pquery who load the tables from data base it load after some seconds and load one by one each on an interval of 2-7 seconds random.
What can I do I try many methods optimized the apache change the mysql version re write the query but still very slow
Mister0 is offline   Reply With Quote
Old 21/09/2017, 11:24 PM   #2
Logic_
Banned
 
Join Date: Jun 2015
Posts: 1,506
Reputation: 305
Default Re: Mysql work slow

What do you mean? We don't get you.
Logic_ is offline   Reply With Quote
Old 21/09/2017, 11:32 PM   #3
Mister0
Huge Clucker
 
Mister0's Avatar
 
Join Date: Aug 2015
Posts: 220
Reputation: 19
Default Re: Mysql work slow

I can open any samp server but if the server is connected to the mysql database then my tables load very slow
like this

mysql_pquery(handle, "SELECT * FROM `business`", "LoadBusiness");
mysql_pquery(handle, "SELECT * FROM `jobsname` ORDER BY `ID` ASC", "LoadJobs");

my gamemode is loaded with vehicles model and all what he need but after some seconds or minutes it show the tables are loaded
Mister0 is offline   Reply With Quote
Old 22/09/2017, 02:33 AM   #4
AlphaPac
Little Clucker
 
Join Date: Nov 2011
Posts: 32
Reputation: 5
Default Re: Mysql work slow

Show me where you fetch all the data.
AlphaPac is offline   Reply With Quote
Old 22/09/2017, 05:14 AM   #5
raydx
Huge Clucker
 
raydx's Avatar
 
Join Date: Feb 2017
Posts: 203
Reputation: 73
Default Re: Mysql work slow

Because these queries are threaded. Use mysql_query instead of mysql_pquery for server loading queries.
Off course you can't do it without rewriting a lot of loading code.
raydx is offline   Reply With Quote
Old 22/09/2017, 10:51 AM   #6
Mister0
Huge Clucker
 
Mister0's Avatar
 
Join Date: Aug 2015
Posts: 220
Reputation: 19
Default Re: Mysql work slow

I use mysql r-41>

Quote:
Originally Posted by AlphaPac View Post
Show me where you fetch all the data.
You mean the publics
Code:
 pc LoadBusiness()
{
	Toatal_Business_Created = cache_num_rows();
	new i,x;
	for(i=0;i<Toatal_Business_Created;i++)
    {
        x++;
   		//LOADING=========================================================================/
		cache_get_value(i, "ID", temp); 		BusinessInfo[x][bID] = strval(temp);
		cache_get_value(i, "Owner", temp); 		format(BusinessInfo[x][bOwner],52,temp);
		cache_get_value(i, "ExtX", temp); 		BusinessInfo[x][bExtX] = floatstr(temp);
		cache_get_value(i, "ExtY", temp); 		BusinessInfo[x][bExtY] = floatstr(temp);
		cache_get_value(i, "ExtZ", temp); 		BusinessInfo[x][bExtZ] = floatstr(temp);
	}
	printf("[GAMEMODE]:         Business Loaded %i bizz's. %dQ", Toatal_Business_Created,NumQuery),NumQuery++;
	return 1;
}
Because these queries are threaded. Use mysql_query instead of mysql_pquery for server loading queries.
Off course you can't do it without rewriting a lot of loading code.
And how you want to use mysql_query on this?


mysql_pquery(handle, "SELECT * FROM `business`", "LoadBusiness");
Mister0 is offline   Reply With Quote
Old 22/09/2017, 01:27 PM   #7
Banditul18
Huge Clucker
 
Join Date: Nov 2014
Location: Brasov,Romania
Posts: 408
Reputation: 32
Default Re: Mysql work slow

Well ,in first place why don't u use native function from mysql? With format, strval and floatstr of course its a little bit hard to process
PHP Code:
public LoadBusiness()
{
    
Toatal_Business_Created cache_num_rows();
    new 
i,x;
    for(
i=0;i<Toatal_Business_Created;i++)
    {
        
x++;
           
//LOADING=========================================================================/
           
cache_get_value_name_int(i"ID"BusinessInfo[x][bID]);
           
cache_get_value_name(i"Owner"BusinessInfo[x][bOwner], MAX_PLAYER_NAME);
        
cache_get_value_name_float(i"ExtX"BusinessInfo[x][bExtX]);
        
cache_get_value_name_float(i"ExtY"BusinessInfo[x][bExtY]);
        
cache_get_value_name_float(i"ExtZ"BusinessInfo[x][bExtZ]);
    }
    
printf("[GAMEMODE]: Business Loaded %i bizz's. %dQ"Toatal_Business_Created,NumQuery),NumQuery++;
    return 
1;

And to be honest, use mysql_tquery. I know its not paralel query, but will work 100/100
Banditul18 is offline   Reply With Quote
Old 22/09/2017, 01:49 PM   #8
Mister0
Huge Clucker
 
Mister0's Avatar
 
Join Date: Aug 2015
Posts: 220
Reputation: 19
Default Re: Mysql work slow

Ok let's say I modified every line but why onwindows 7 I didn t have this problem?
I edited and replaced and still same
Mister0 is offline   Reply With Quote
Old 22/09/2017, 02:47 PM   #9
Mister0
Huge Clucker
 
Mister0's Avatar
 
Join Date: Aug 2015
Posts: 220
Reputation: 19
Default Re: Mysql work slow

The problem is if I delete every

for(i=0;i<Toatal_Business_Created;i++)
{
cache_delete etc
}

the table load ok slow but at least they are loading every in the same minute, but How else could I load every line from tables?
Mister0 is offline   Reply With Quote
Old 22/09/2017, 06:51 PM   #10
Logic_
Banned
 
Join Date: Jun 2015
Posts: 1,506
Reputation: 305
Default Re: Mysql work slow

You're creating the loops the wrong way. Why are you having two variables which do the same?

PHP Code:
for(new iSOME_VALUEi++)
{
    
fetch data
    assign data

I don't see the need of a different variable at all.
Logic_ 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 too slow NikolaSRB Scripting Help 9 02/09/2017 12:59 PM
Mysql loading slow Dusan01 Scripting Help 2 14/02/2016 10:14 AM
MySQL running slow Luis- Scripting Help 1 12/05/2015 08:53 PM
MySQL slow? PowerPC603 Scripting Help 20 27/01/2014 08:40 PM
MySQL Query is to slow. Momo5000 Help Archive 8 27/03/2011 04:44 PM


All times are GMT. The time now is 12:11 PM.


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