SQLite Reading and Writing Question: -
Ballu Miaa - 08.09.2012
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
Re: SQLite Reading and Writing Question: -
Maxips2 - 08.09.2012
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.
Re: SQLite Reading and Writing Question: -
Ballu Miaa - 08.09.2012
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?
Re: SQLite Reading and Writing Question: -
Maxips2 - 08.09.2012
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.
Re: SQLite Reading and Writing Question: -
Ballu Miaa - 08.09.2012
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.
Re: SQLite Reading and Writing Question: -
Maxips2 - 08.09.2012
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.
|
Re: SQLite Reading and Writing Question: -
Ballu Miaa - 08.09.2012
Quote:
Originally Posted by Maxips2
|
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.
Re: SQLite Reading and Writing Question: -
Maxips2 - 08.09.2012
Well the first player to log out will call the saving function, when the function has finished then the next one will be called.
Re: SQLite Reading and Writing Question: -
Ballu Miaa - 08.09.2012
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?
Re: SQLite Reading and Writing Question: -
Maxips2 - 08.09.2012
They will be queued I believe, it won't just disapear it has to be called.