3

Should I use FullMutex or NoMutex in SQLite Flags? What is their purpose? And if yes, which should I use?

For now: I'm using these flags:

public static class SQLiteConstants
{
    public const SQLiteOpenFlags Flags =
        SQLiteOpenFlags.ReadWrite |
        SQLiteOpenFlags.SharedCache |
        SQLiteOpenFlags.Create |
        SQLiteOpenFlags.FullMutex;

    public static string GetDatabasePath
    {
        get => Path.Combine(FileSystem.AppDataDirectory, "UserScores.db3");
    }
}

1 Answer 1

3
  1. What NoMutex mean is that the new database connection will use the "multi-thread" threading mode. This means that separate threads are allowed to use SQLite at the same time, as long as each thread is using a different database connection.

  2. What FullMutext mean is that new database connection will use the "serialized" threading mode. This means the multiple threads can safely attempt to use the same database connection at the same time. (Mutexes will block any actual concurrency, but in this mode there is no harm in trying.) So, you can choose the flag depend on your situation

Sign up to request clarification or add additional context in comments.

2 Comments

sorry for the late reply, so the FullMutex is much better in terms of performance? because as you know, mobile devices has limited resources
If you have no mutex and two threads use the same connection to update the same table, then either both will work or your application would fail, memory would be corrupted. If you use the default serialized (full mutex) then both will work and there will be no consequence as described above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.