Author
|
Message
|
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
|
11-13-2015
, 23:20
Efficient Database Insertion
|
#1
|
So I am working on a plugin that logs events to a database. The event firings vary vastly. Some fire ~ at every game frame and some fire once every 5 minutes. As of right now, all callbacks record the data to a database using SQL_TQuery.
However, for such rapid event logging, is it efficient to keep on calling SQL_TQuery that frequently? Are transactions better? Give me some advice here. I have a feeling that spamming SQL_TQuery on average 15 times a second isn't a good idea but I really don't know. Transactions also have that other issue where the whole query is stored in memory (maybe even compiled into bytecode?) until the entire transaction is executed. Furthermore, if one of the queries in the transaction fails for some reason, the whole transaction is nuked.
This is an sqlite database, so each query takes microseconds (~ 0 ms) to execute. However, that still doesn't mean I'd use a shitty solution if there is a better way of doing it.
EDIT: Forgot to mention. All queries are INSERT INTO queries, so the callback is basically a blank function that logs errors if there is an SQL error.
The question boils down to: What is the most efficient way of inserting data to a database when the database is being asked to insert stuff at ~ 15 single queries/second?
Last edited by Potato Uno; 11-13-2015 at 23:39.
|
|
|
|