Sharphsql is a lightweight database engine that supports the sql92 standard for pure C # writing. When we use a single DLL database engine for ease of release, sharphsql is favored for its 100% managed code. Everyone cheered: We found a substitute for access!
But in fact, I think sharphsql should be used in the actual production environment with caution. Let's first take a look at its storage principles.
Unlike other pure-memory databases or file-type databases, sharphsql is quite clever in data storage. the cfg file stores some database information and the location of other files. log stores all ddl SQL statements. the binary serialized stream in which data files are stored in the cache. backup storage. data with the same data is equivalent to storing one more layer of insurance.
Check the sharphsql source code. The processing is relatively simple:
Each insert Delete (update will be divided into Delete first and then insert, but check will be placed after insert) each has a transaction corresponding
This transaction is used for rollback during transaction rollback. When rollback is used, delete is used for insert and insert is used for Delete.
Table stores rows through cache, that is, the actual data is stored in the cache class.
The index class is an AVL tree used for data retrieval. When a row is updated, if an index exists, it needs to be updated.
Channel uses the distinction between transaction and permission check. In fact, only one process can access the same database through multiple channels, but other processes cannot access the same database.
This is because the database class uses exclusive files to open the database, because if it is not exclusive, writing the cache will cause problems.
Steps for opening a database:
1. Retrieve the cfg file and obtain the information.
2. deserialize. data to obtain the cache.
3. Execute. log to get the database structure
Therefore, we can see that sharphsql is exclusively accessed and fully loaded to the memory.
In my opinion, this structure should still be regarded as a memory database engine. It should be used with caution in the actual production environment where the data size will gradually increase. In the multi-concurrency environment, it should not be used.
Therefore, sharphsql requires a pocket version and uses the Compact framework. It seems that its location is also very accurate.
If you use sharphsql's SQL parser and execute engine and dataset to replace its index and cache, you can easily write an in memory database. However, this plagiarism is of little significance, but it is feasible.