Raised This Month: $ Target: $400
 0% 

sql optimization


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-04-2011 , 15:52   Re: sql optimization
Reply With Quote #2

The thing about your code is that:
You use variable i incorrectly. It's used as the index of a player, where it alone just represents an index in the Players[] array. So using for instance; name[i] would be incorrect, whereas using name[players[i]] would be correct. Even better:
Code:
new player = players[i]; name[player] = ...
That would use less resources.

You could also try using threaded queries (note that they are based on a FIFO (first-in-first-out) basis; meaning that they stack up and wait for execution):
Code:
new const Host[ ] = ""; new const User[ ] = ""; new const Pass[ ] = ""; new const DB[ ] = ""; new Handle:SQLTuple; SQLTuple = SQL_MakeDbTuple( Host, User, Pass, DB ); new Query[ 128 ]; formatex( Query, charsmax( Query ), "QUERY GOES HERE" ); SQL_ThreadQuery( SQLTuple, "QueryHandler", Query /*, ... data, datasize */); public QueryHandler( Failstate, Handle:Query, Error[], ErrorCode, Data[], Size, Float:QueueTime ) {     if( Failstate == TQUERY_CONNECT_FAILED     || Failstate == TQUERY_QUERY_FAILED )     {         log_amx( "SQL Error: %s (%i)", Error, ErrorCode );         return;     } }
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath 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 19:34.


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