SQLite Reading and Writing Question:
#1

Hello Everyone,

Well i was surfing around and was looking at some threads about 'MYSQL vs SQLite'. So there was this guy who said "SQLite locks the database to be read or written when it is writing something".
  • Q: Does that mean if one players variables are saving , then no other player can save variable at that time?
  • Q: Does that mean No two players can update the database at the same time in any case?
If you can answer the questions please help me. Your help will be appreciated.

Thank you
Ballu Miaa
Reply
#2

The script is runing on a single thread so you probably can't have 2 savings done at the same time.
One action needs to be finished before the other.
Reply
#3

Quote:
Originally Posted by Maxips2
Посмотреть сообщение
The script is runing on a single thread so you probably can't have 2 savings done at the same time.
One action needs to be finished before the other.
That will be a Mess in case i have 50 Players on the server right?
Reply
#4

Shouldn't be because SQLite is very fast (if you use it right of course).
The query shouldn't take too long to exec (I believe just a few miliseconds)

If you are worried, you could use a fast file system or MySQL using cached (or non cached) queries.
Reply
#5

Quote:
Originally Posted by Maxips2
Посмотреть сообщение
Shouldn't be because SQLite is very fast (if you use it right of course).
The query shouldn't take too long to exec (I believe just a few miliseconds)

If you are worried, you could use a fast file system or MySQL using cached (or non cached) queries.
But In case two queries are sent to the database at the same time? Does it put the waiting query in a que? Or we need to send the query again in case one query is in procedure to be completed?


Queries in my server never takes too long to execute.
Reply
#6

You can't send two queries at the same time because its running on a single thread.
If you are interested you can read Slice's tutorial about understanding the sync: https://sampforum.blast.hk/showthread.php?tid=184118

Quote from the thread:
Quote:

The script runs on a single thread
This might sound complicated for some people, allow me to explain: All the actions the server does are always after waiting for the latest action to finish.
For example, if you have code that takes 3 seconds to run in OnPlayerConnect (such as the old GeoIP plugin), then the server will wait for that code to finish before doing anything else.

Reply
#7

Quote:
Originally Posted by Maxips2
Посмотреть сообщение
You can't send two queries at the same time because its running on a single thread.
If you are interested you can read Slice's tutorial about understanding the sync: https://sampforum.blast.hk/showthread.php?tid=184118

Quote from the thread:
For an Example:

Two Players disconnected at the same time in the server. And the callback SavePlayer is called for that playerid to save all the data of the player.
Reply
#8

Well the first player to log out will call the saving function, when the function has finished then the next one will be called.
Reply
#9

Quote:
Originally Posted by Maxips2
Посмотреть сообщение
Well the first player to log out will call the saving function, when the function has finished then the next one will be called.
The client will auto set another query in a que , once the first query is done , then auto executes the other query Or I need to send the query again to the database?
Reply
#10

They will be queued I believe, it won't just disapear it has to be called.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)