diff --git a/servers/slapd/back-bdb/idl.h b/servers/slapd/back-bdb/idl.h
index 3ce8e19ed126bc7a552ef1dab858b26e6db887e5..f7574ff791df5d5ad220067325feb19a6b134abf 100644
--- a/servers/slapd/back-bdb/idl.h
+++ b/servers/slapd/back-bdb/idl.h
@@ -12,11 +12,11 @@
 
 #include "slap.h"
 
-#define BDB_IDL_DB_SIZE		(1<<16) /* 64K IDL on disk */
+#define BDB_IDL_DB_SIZE		(1<<8) /* 64K IDL on disk */
 #define BDB_IDL_DB_MAX		(BDB_IDL_DB_SIZE-32)
 /* #define BDB_IDL_DB_ALLOC	(BDB_IDL_DB_SIZE * sizeof(ID)) */
 
-#define BDB_IDL_SIZE		(1<<17) /* 128K IDL in memory */
+#define BDB_IDL_SIZE		(1<<10) /* 128K IDL in memory */
 #define BDB_IDL_MAX			(BDB_IDL_DB_SIZE-32)
 /* #define BDB_IDL_DB_ALLOC	(BDB_IDL_DB_SIZE * sizeof(ID)) */
 
@@ -54,4 +54,4 @@
 LDAP_BEGIN_DECL
 LDAP_END_DECL
 
-#endif
\ No newline at end of file
+#endif
diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c
index af3e2c3b02a6c3441ca902732edf3788e26606cc..f64e5a35708c21b00cc41eab656503a8541bc870 100644
--- a/servers/slapd/back-bdb/init.c
+++ b/servers/slapd/back-bdb/init.c
@@ -209,6 +209,16 @@ bdb_db_open( BackendDB *be )
 		bdb->bi_databases[i] = db;
 	}
 
+	/* get nextid */
+	rc = bdb_last_id( be, NULL );
+	if( rc != 0 ) {
+		Debug( LDAP_DEBUG_ANY,
+			"bdb_db_open: last_id(%s) failed: %s (%d)\n",
+			bdb->bi_dbenv_home, db_strerror(rc), rc );
+		return rc;
+	}
+
+
 	/* <insert> open (and create) index databases */
 
 
diff --git a/servers/slapd/back-bdb/nextid.c b/servers/slapd/back-bdb/nextid.c
index a534840ae3085dd1e77a183335911229d0409ba0..7ceda5f9cfffe78305dd657981a227c2c53af9fb 100644
--- a/servers/slapd/back-bdb/nextid.c
+++ b/servers/slapd/back-bdb/nextid.c
@@ -121,3 +121,58 @@ done:	(void) txn_abort( ltid );
 
 	return rc;
 }
+
+int bdb_last_id( BackendDB *be, DB_TXN *tid )
+{
+	struct bdb_info *bdb = (struct bdb_info *) be->be_private;
+	int rc;
+	ID kid = NOID;
+	ID id;
+	DBT key, data;
+
+	DBTzero( &key );
+	key.data = (char *) &kid;
+	key.size = sizeof( kid );
+
+	DBTzero( &data );
+	data.data = (char *) &id;
+	data.ulen = sizeof( id );
+	data.flags = DB_DBT_USERMEM;
+
+retry:
+	/* get existing value for read/modify/write */
+	rc = bdb->bi_nextid->bdi_db->get( bdb->bi_nextid->bdi_db,
+		tid, &key, &data, 0 );
+
+	switch(rc) {
+	case DB_LOCK_DEADLOCK:
+	case DB_LOCK_NOTGRANTED:
+		goto retry;
+
+	case DB_NOTFOUND:
+		id = 0;
+		rc = 0;
+		break;
+
+	case 0:
+		if ( data.size != sizeof( id ) ) {
+			Debug( LDAP_DEBUG_ANY,
+				"=> bdb_last_id: get size mismatch: expected %ld, got %ld\n",
+				(long) sizeof( id ), (long) data.size, 0 );
+			rc = -1;
+			goto done;
+		}
+		break;
+
+	default:
+		Debug( LDAP_DEBUG_ANY,
+			"=> bdb_next_id: get failed: %s (%d)\n",
+			db_strerror(rc), rc, 0 );
+		goto done;
+	}
+
+	bdb->bi_lastid = id;
+
+done:
+	return rc;
+}
diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h
index 1c473150a9e8cec2065734fa1ede443f90ac7e39..60d11f2cba7d5ef00b1c9c9e7b876df1a385c524 100644
--- a/servers/slapd/back-bdb/proto-bdb.h
+++ b/servers/slapd/back-bdb/proto-bdb.h
@@ -181,6 +181,7 @@ bdb_key_read(
  * nextid.c
  */
 int bdb_next_id( BackendDB *be, DB_TXN *tid, ID *id );
+int bdb_last_id( BackendDB *be, DB_TXN *tid );
 
 /*
  * modify.c