A common issue of high latency transactions. SQLite has a high per-transaction overhead, which can be amortized across multiple INSERTs or UPDATEs to improve the average INSERT rate. You are doing a single INSERT per transaction, so wrap multiple INSERTs inside a single "BEGIN" ... "END" transaction.

See:
http://www.sqlite.org/cvstrac/wiki?p=PerformanceConsiderations

Christian

Igor Mironchick uttered:

Hi.

How can I improve productivity of this code:

a_messenger_t::data_buff_t --> std::deque< some_struct >

//////////////////////////////////////////////////////////////////////////////////////////////

  char * errors = 0;

  for( a_messenger_t::data_buff_t::const_iterator it = msg.m_buff.begin(),
      last = msg.m_buff.end(); it != last; ++it )
  {
      // Converting long to std::string...
      std::string sec( itos( it->m_time.sec() ) );
      std::string usec( itos( it->m_time.usec() ) );

// Columns in 'data' table defined like (INTEGER, INTEGER, INTEGER, TEXT) char * sql = sqlite3_mprintf( "INSERT INTO data VALUES( '%q', '%q', '%q', '%q' )",
          m_sources_map[ it->m_source ].m_sid.c_str(),
          sec.c_str(), usec.c_str(), it->m_value.c_str() );

      // m_db --> sqlite3*
      int ret = sqlite3_exec( m_db, sql, 0, 0, &errors );

      if( ret != SQLITE_OK )
      {
          ACE_DEBUG( ( LM_INFO, ACE_TEXT( "[%D] %M -- %C\n" ), errors ) );
          sqlite3_free( errors );
      }

      sqlite3_free( sql );
  }

Any idea? This method are so slow - about 1 kB per second new data in my DB.



--
    /"\
    \ /    ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
     X                           - AGAINST MS ATTACHMENTS
    / \

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to