[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Modify performance



Ahh , found it:) It was really silly indeed:)

libraries/libldbm/ldbm.c:ldbm_delete() was written like so:

int
ldbm_delete( LDBM ldbm, Datum key )
{
   int    rc;
   LDBM_WLOCK;
#if DB_VERSION_MAJOR >= 2
   rc = ldbm->del( ldbm, NULL, &key, 0 );
   rc = (-1) * rc;
#else
   rc = ldbm->del( ldbm, &key, 0 );
#endif

   ldbm->sync( ldbm, 0 );

   LDBM_WUNLOCK;

   return( rc );
}


As you can see, it used to do a db sync after every delete operation. A bit wasteful and goes against the idea of user controlled dbsync (which is set as a flag upon dbopen). Removing this sync solved the problem - deletes and modify's are blazingly fast. (Well, i made this a flag to the function just in case i may want to control it in the future)

BTW there is exactly the same problem in 2.1.x - ldbm_delete
is ALWAYS syncing regardless of user preferences.
--Ugen

Howard Chu wrote:

In a modify, existing index values are deleted and new values are added. As
such, it takes (at least) twice as many I/O operations as an add. Depending
on the underlying database library and database structure (Btree, hash,
whatever) there may be more operations to coalesce freed pages, rebalance
trees, etc...

 -- Howard Chu