Raised This Month: $ Target: $400
 0% 

SQL 30 querys per minute :S


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
webbhelp
Member
Join Date: Jan 2010
Old 05-09-2010 , 07:08   SQL 30 querys per minute :S
Reply With Quote #1

Hi!

Now I am doing my onw real project. In this project I can choose to save 2 ID and a weapon name in a database everytime someone dies.
Or I can choose to put all this querys together and only have like 20 when the map ends.

so 30 per minute or 20 in the end? I think 20 in the end is the best but how do I handle so many querys almost in the same time?
AND if I want to have 30 qureys på minute how can I handle that?

I mean... it is a lot of querys and I need to do it in a nice way to avoid lagging and disturbing things for the players.

I read the most of this: http://wiki.alliedmods.net/SQL_%28So...%29#Connecting
But I don't really understand it all that's why I need to filter what I need to read about and I hope you can help me to find a solution
webbhelp is offline
dordnung
Veteran Member
Join Date: Apr 2010
Old 05-09-2010 , 07:28   Re: SQL 30 querys per minute :S
Reply With Quote #2

Make an Array

PHP Code:
new Kills[MAXPLAYERS 1
Then, when someone connect, do this:

PHP Code:
Kills[client] = TheFetchtedKills 
when the Player kill someone:

PHP Code:
Kills[client]++ 
And when he leaves transfer it to the SQL Database
__________________
dordnung is offline
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 05-09-2010 , 07:38   Re: SQL 30 querys per minute :S
Reply With Quote #3

to be honest, if you want to do this, you should try to understand the whole page =D it is very well written and the examples are a good starting point. If you don't know what CREATE, DROP, UPDATE, INSERT, and DELETE are, you'll better start reading this first.
But especially you'll need to understand what threaded SQL querying is, because you'll want to use it if you decide to query the db every kill.
If you decide to query the db at the end of a map, you'll need to find a -preferably- efficient way to save the information. Popoklopsi's suggestion is only counting the kills, not the weapon nor the victim.
Thrawn2 is offline
webbhelp
Member
Join Date: Jan 2010
Old 05-09-2010 , 07:42   Re: SQL 30 querys per minute :S
Reply With Quote #4

I can PHP - MySQL good.

I can all this SQL commands so the problem is more sourcepawn code.

Why I don't understand everything... Don't know...
Popoklopsi that was what I thought to do but the problem is to save everything in a database to the end how I shall save it in the best way?
webbhelp is offline
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 05-09-2010 , 07:56   Re: SQL 30 querys per minute :S
Reply With Quote #5

Copy+paste from the tutorial. This is basically the way to store some data at the end of the map.
PHP Code:
public OnMapEnd() {
    new 
String:error[255];
    new 
Handle:db SQL_DefConnect(errorsizeof(error));

    if (
db == INVALID_HANDLE)
    {
        
PrintToServer("Could not connect: %s"error);
    } else {
        
CloseHandle(db);
    }

    if (!
SQL_FastQuery(db"UPDATE stats SET players = players + 1"))
    {
        new 
String:error[255];
        
SQL_GetError(dberrorsizeof(error));
        
PrintToServer("Failed to query (error: %s)"error);
    }

    
CloseHandle(db);

But i like the threaded way a loooot more. Your code would become cleaner, because you wouldnt need to save every kill in some array, instead you'd be writing them to the db instantly. Without lagging your server...
Thrawn2 is offline
webbhelp
Member
Join Date: Jan 2010
Old 05-09-2010 , 11:07   Re: SQL 30 querys per minute :S
Reply With Quote #6

I have successed to select and insert, update to a db that is not the problem.

But i don't know how to do it in the threaded way; I want a solution that not crasches or make the server lagging or things like that if I update, insert, select much in same time
webbhelp is offline
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 05-09-2010 , 12:19   Re: SQL 30 querys per minute :S
Reply With Quote #7

have you read the tutorial again? its pretty straight forward and explains everything you need. its much easier to help you if you have a specific question. guiding you through the whole process, thats what the tutorial is for. please read it again.
Thrawn2 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 00:14.


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