hi, everyone,
   I program in an embaded system: ARM9 soc S3C2410 +Linux 2.4+sqlite  
 3.3.
 All data store in NAND FLASH , the file system is YAFFS .
  My question is the function "sqlite3_exec(.....)"  take too many   
 seconds,
  the following is my source code, please see the "printf" 's comment,
  every "sqlite3_exec(.....)"   takes 5 seconds, but how to reduce  
 the time?
 //------------------------------ start of code
 #define RECORD_NUM 1
 char QueryData(void)
 {
 struct timeval tpstart,tpend;
 float timeuse;
 char ErrorFlag=1;
 unsigned int di,dj,dk;
 DataBuffer[0]='\0'; //DataBuffer is goblal variable
 sprintf(sqlstr,"select * from db where isSent=0 limit  
 %d;",RECORD_NUM);
 p(semid);
 gettimeofday(&tpstart,NULL);
 rc = sqlite3_exec(db, sqlstr, SQLCallBack, 0, &zErrMsg);
 gettimeofday(&tpend,NULL);
 timeuse=1000000*(tpend.tv_sec-tpstart.tv_sec)+
 tpend.tv_usec-tpstart.tv_usec;
 timeuse/=1000000;
 printf("sqlite3 select * Used Time:%f\n",timeuse); // print value :5  
 seconds
 v(semid);
 sprintf(sqlstr,"update db set isSent=1 where ID in (select ID from  
 db where isSent=0 limit %d);",RECORD_NUM);
 p(semid);
 gettimeofday(&tpstart,NULL);
 rc = sqlite3_exec(db, sqlstr, 0, 0, &zErrMsg);
 gettimeofday(&tpend,NULL);
 timeuse=1000000*(tpend.tv_sec-tpstart.tv_sec)+
 tpend.tv_usec-tpstart.tv_usec;
 timeuse/=1000000;
 printf("sqlite3 update Used Time:%f\n",timeuse); //print value : 5s
 v(semid);
 }
 static int SQLCallBack(void *NotUsed, int argc, char **argv, char  
 **azColName)
 {
 struct timeval tpstart,tpend;
 float timeuse;
 int i;
 char tstr[500];
 gettimeofday(&tpstart,NULL);
 // argv[0] is ID ,no use for server
 sprintf(tstr,"'%s',",argv[1]);
 strcat(DataBuffer,tstr);
 for(i=2; i<argc; i++){
 // printf("%s,",argv[i] ? argv[i] : "N");
 sprintf(tstr,"%s,",argv[i]);
 strcat(DataBuffer,tstr);
 }
 strcat(DataBuffer,"\n");
 gettimeofday(&tpend,NULL);
 timeuse=1000000*(tpend.tv_sec-tpstart.tv_sec)+
 tpend.tv_usec-tpstart.tv_usec;
 timeuse/=1000000;
 printf("SQLCallBack Used Time:%f\n",timeuse); // print value : 
 0.000280s
 return 0;
 }



backup
2010-06-17
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to