Open rush2ko opened 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.
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) )
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".)
Thank you so much. ^^