Raised This Month: $ Target: $400
 0% 

SQL Calculating takes too much time


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 01-05-2011 , 07:42   SQL Calculating takes too much time
Reply With Quote #1

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
reinert is offline
 



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

Forum Jump


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


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