AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQL Calculating takes too much time (https://forums.alliedmods.net/showthread.php?t=147080)

reinert 01-05-2011 07:42

SQL Calculating takes too much time
 
Why this code takes 2-3seconds to calculate what is the player's ranking...

PHP Code:

public BankTop(id)
{
    for(new 
i33i++)
    {
        if(
is_user_connected(i))
           
Save_MySql(i)
    }
        
    new 
Data[1]
    
Data[0] = id
    
    
new szTemp[512]
    
format(szTemp,charsmax(szTemp),"SELECT COUNT(*) FROM `bank` WHERE `money` >= %d"iMoney[id])
    
SQL_ThreadQuery(g_SqlTuple,"Sql_Rank",szTemp,Data,1)
        
    return 
PLUGIN_CONTINUE
}

public 
Sql_Rank(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
            
log_amx("Load - Could not connect to SQL database.  [%d] %s"ErrcodeError)
    else if(
FailState == TQUERY_QUERY_FAILED)
            
log_amx("Load Query failed. [%d] %s"ErrcodeError)
  
    new 
count 0
    count 
SQL_ReadResult(Query,0)
    if(
count == 0)
    
count 1
    
    
new id
    id 
Data[0]

    
client_printc(id"\g[ BANK ]\n Your rank is %i with %i$ money in bank"countiMoney[id]);
    
    return 
PLUGIN_HANDLED


Is it possible to make it faster ? Because when I wrote /rankbank, I've to wait some seconds to get answer ;D

Arkshine 01-05-2011 08:33

Re: SQL Calculating takes too much time
 
Don't use thread query.

grimvh2 01-05-2011 09:32

Re: SQL Calculating takes too much time
 
Whats the other option? I tought it was because of the external connection from my server to the mysql db.

Arkshine 01-05-2011 11:32

Re: SQL Calculating takes too much time
 
Should not he use instead SQL_Execute() if he don't want to get some delay ?


All times are GMT -4. The time now is 02:14.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.