How to fast queries
#1

Hi,

I'am using latest mysql BlueG plugin. But i want to make my queries faster. I don't know maybe for others it'is normal speed but for my, i see that there is about 20-30 queries/sec. It'is possible to make queries 2x, with new method or something like this?
Reply
#2

Depends on how your queries are structured. If you have queries like this:
Код:
SELECT * FROM Table1;
foreach($result as $row) {
  SELECT * FROM Table2 WHERE ID = $row->table2_id;
}
Then yes, you can simplify it. If however your queries are just this:

UPDATE Player SET var1, var2, var3

then no, you cannot change the amount unless you make your method collect data on all players and in some way dump all information into your database at once, which can create some faults as some players data may not be saved.
Reply
#3

20-30/sec definitely is too much for a samp server.
What stuff are you stroing in the database? You shouldnt use mysql as a live data storage, but as a persistent storage to initialize your gamemode variable. E.g. dont fetch shop coordinates from mysql every time you check if a player is near it, but rather load the coordinates to global variables on server start, and eventually update mysql if the coordinates change.
Playerdata also dont need to be stored every second. Store it when the player leaves or the server goes down, and once every few minutes to prevent data loss on crashes.
The best thing to consider is, dont update/select stuff from mysql unless youre sure that it changed since the last query.
Reply
#4

I know that already, but other way i can't to find? You understand that if will be 1000 players in game? a lot of connections, disconnections, checking is banned from mysql, top10 from database it'is just a small piece. A lot of other stuff, commands and so on...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)