Raised This Month: $ Target: $400
 0% 

SQL Calculating takes too much time


Post New Thread Reply   
 
Thread Tools Display Modes
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
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-05-2011 , 08:33   Re: SQL Calculating takes too much time
Reply With Quote #2

Don't use thread query.
__________________
Arkshine is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 01-05-2011 , 09:32   Re: SQL Calculating takes too much time
Reply With Quote #3

Whats the other option? I tought it was because of the external connection from my server to the mysql db.
__________________
I am out of order!
grimvh2 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-05-2011 , 11:32   Re: SQL Calculating takes too much time
Reply With Quote #4

Should not he use instead SQL_Execute() if he don't want to get some delay ?
__________________
Arkshine is offline
Reply



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