yes, this is slow. it always forces q to interpret and the string and
atomic operations are slow (single row inserts is an example of this).
build a list of vectors with the bulk data and insert it in one
operation:
…
int i;
int n=… // the number of rows
K x=ktn(0,3); // a genric list with 3 elements
K times=ktn(KT,n); // the time vector
K ports=ktn(KI,n); // ports
K hosts=ktn(KS,n);
kK(x)[0]=times;kK(x)[1]=ports;kK(x)[2]=hosts; // assign the vectors in
list
// fill the vectors
// note that time is an interger counting the ms since midnight
for(i=0;i kI(times)[i]=…;kI(ports)[i]=…;kS(hosts)[i]=ss(…);} k(-c,“insert”,ks(ss(“tbl_log”)),x,(K)0); // push the data async k(c,“”,(K)0); // flush the buffers // you don’t need to free the created objects because k(.. takes care of this …
Thank you. I will use that method instead.On 13 Maj, 11:51, Felix Lungu <felix.lu…> wrote:> yes, this is slow. it always forces q to interpret and the string and ?> atomic operations are slow (single row inserts is an example of this).>> build a list of vectors with the bulk data and insert it in one ?> operation:> …> int i;> int n=… // the number of rows> K x=ktn(0,3); // a genric list with 3 elements> K times=ktn(KT,n); // the time vector> K ports=ktn(KI,n); // ports> K hosts=ktn(KS,n);> kK(x)[0]=times;kK(x)[1]=ports;kK(x)[2]=hosts; // assign the vectors in ?> list> // fill the vectors> // note that time is an interger counting the ms since midnight> for(i=0;i ? kI(times)[i]=…;kI(ports)[i]=…;kS(hosts)[i]=ss(…);}> k(-c,“insert”,ks(ss(“tbl_log”)),x,(K)0); // push the data async> k(c,“”,(K)0); // flush the buffers> // you don’t need to free the created objects because k(.. takes care ?> of this> …>> felix>> On 13 May 2009, at 12:24, Jespr wrote:>>>>>> > What is the fastest to insert data into a kdb+ database using a c++> > interface. I have tried to use this code>> > for(int i = 0; i < numberOfRecords; i++) {> > ? ?k(-c,“tbl_log insert(09:30:00.000; 1010; p)”,(K)0);> > ?}>> > and I noticed that it was a lot slower than using a while loop i q to> > insert the data.- Skjul tekst i anf?rselstegn ->> - Vis tekst i anf?rselstegn -</felix.lu…>