posted time Created time: 2017-02-04 Last updated time:

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.

How INSERT SQL works on Distributed DB using shard map

The execution of INSERT SQL statement is done by following order.

Execute INSERT SQL Statement on Distributed Nodes

Execute SQL Statement on Transaction Engine

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.

Receive commands & send new commands to execute INSERT data for nodes on Shard Map

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.

  1. Check Schema & Cluster Version to detect changes. If changed, synchronize them.
  2. Get Shard Map Data to create commands data for each shard storage node.
  3. Send commands to shard storage nodes

When the operation finished, the Shared Lock is released.

Actually Insert Data

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.

What I have to consider to extend Distributed Database

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.



Go to Top