Hi All,
I’m quite new to kdb and I’ve got question about inserts from client API. Let’s say I have lot of messages coming from some external system and I want to persist them to the table as quickly as possible (I’ll use Java API code, but i think this is pretty much same for all APIs):
public void onMessage(Message m) {
//prepare data for insertion here
conn.ks(insertExpression); //async insert
conn.k(“”); //flush
}
The “ks” method returns very fast. All it does - just puts data to the socket and return. The “k” method with empty argument does flushing as the side effect, but it really slow. If i remove it there can be data in the socket buffer stuck for some time.
I want on the one hand not to slow insertion calling additional method for flushing. On the other hand I want data to be flushed.
What the approach to this problem? Is there any obvious solution i’m missing? I think of flushing from another stream, but I’m not sure if it will be thread safe to use the same connection object.
Thanks in advance,
Alex.