bizstation / transactd

The high-speed and advanced NoSQL interface plugin for MySQL / MariaDB.
GNU General Public License v2.0
18 stars 1 forks source link

How do you think, What is the best 1 or 2? #30

Open rush2ko opened 8 years ago

rush2ko commented 8 years ago
  1. Use MariaDB Native API & Insert data use multi sentence. ex) insert into main_weapon_info(UserSN) values(123); insert into sub_weapon_info(UserSN) values(123);.....
  2. Use Transactd client & Insert data
bizstation commented 8 years ago

We can not understand the meaning of "the best", because the requirement is different in each projects. If you think the speed is important, Transactd is a better way than SQL.

Here is inserting example with Transactd:

short insertUser(table* tb, const char* id_field_name, int id)
{
    tb->clearBuffer(); // Init all fields with default value.
    tb->setFVN(id_field_name, id);
    tb->insert();
    return tb->stat();
}

// Open table.
table* tb = db->opneTable("main_weapon_info");
table* tb2 = db->opneTable("sub_weapon_info");

insertUser(tb, "UserSN", 123);
insertUser(tb2, "UserSN", 123);
// ... snip ...

tb->release();
tb2->release();

Note that: Opening table is high cost operation. If you use the cache of the table objects, you can insert rows in very high speed.

Please try to compare between SQL and Transactd in your environment.

rush2ko commented 8 years ago

Thank you for your answer. ^^

And one more please... If the match record count is only 1 Is the same performance? Use table object & use activeTable object( reject(1) )

bizstation commented 8 years ago

No. The performance is different by conditions.

table object has cursor on the server. The cursor points a record. It moves with function like seek or seekNext in the order of index. Network access will occur on each cursor-moving.

activeTable object gets multiple records in one network access.

Even if the target (result) is same 1 record, performance is not same between table and activeTable, because their behaviors are different.

In the case of searching with unique key field(s), table is faster than activeTable.

If you want to search record by duplicatable-key or non-key field(s), activeTable is faster than table, because the number of network access is fewer.

For get the high performance, it is necessary to choose method which is suitable for search conditions and database schema.

(For your reference: reject means that "stop searching if one record which is not match conditions was found". It does NOT mean that "return one record".)

rush2ko commented 8 years ago

Thank you so much. ^^