Making INSERT SQL on Remote Database
Now, on 2017/02/04, I am making INSERT SQL statement works on distributed database. Now making the framework of executing distributed queries.
The execution of INSERT SQL statement is done by following order.
At first, SQL Engine Starts Transaction. Then it access Trx Monitor to get current node clusters and scheme version. This versions make it possible to detect the change of schema and clusters.
The INSERT SQL Statement is handled without accessing other distributed nodes, the ACID logs in the Transaction Engine are changed before commit it.
When COMMIT Statement is done, it selects proper region which has the table to insert data, and send INSERT data command to the Storage Region Manager.
The Storage Region Manager get the command from SQL Engine. Then create a new session to access the nodes on shard map.
Table Level Locks are handled on Storage Region, therefore it have to do Share Lock for the table.
After Locking, do following operations.
- Check Schema & Cluster Version to detect changes. If changed, synchronize them.
- Get Shard Map Data to create commands data for each shard storage node.
- Send commands to shard storage nodes
When the operation finished, the Shared Lock is released.
Each Shard Storage Node inserts data on receiving a command. This operation is almost same with local storage, which is used when this database engine is launched as Local Mode.
The difference is that, the storage engine checks the metadata of current storage, and one included in the command, to chekc schema. If the schema is not compatible, it raise exception and fail.
After making all of the base functions of Alinous Elastic DB, I'm going to add a new feature, which is Sub Shard Map. Sub Shard Map will be used to divide Current Hot Data and Old Cold Data into separated network storage nodes.
This function will be effective in tuning performance of distributed database on the cloud.
So, I have to add Shard Key & Sub Shard Key in schema of tables. Default shard key is Primary Key of the table, Sub Shard Key is null.