a0a29de65597450922d9a16c95f7a62e3f7bce23
diff --git a/plugins/symbol-db/symbol-db-engine-core.c b/plugins/symbol-db/symbol-db-engine-core.c
index 96f495e..b0961a7 100644
--- a/plugins/symbol-db/symbol-db-engine-core.c
+++ b/plugins/symbol-db/symbol-db-engine-core.c
@@ -1766,8 +1766,7 @@ sdb_engine_ctags_output_thread (gpointer data, gpointer user_data)
 					gint tmp_updated;
 
 					/* scan has ended. Go go with second step. */
-					DEBUG_PRINT ("%s", "FOUND end-of-group-files marker."
-								 "go on with sdb_engine_second_pass_do ()");
+					DEBUG_PRINT ("FOUND end-of-group-files marker.");
 					
 					chars_ptr += len_marker;
 					remaining_chars -= len_marker;
@@ -1818,10 +1817,19 @@ sdb_engine_ctags_output_thread (gpointer data, gpointer user_data)
 					}
 					
 					
-					/* emit signal. The end of files-group can be cannot be
+					/* emit signal. The end of files-group cannot be
 					 * determined by the caller. This is the only way.
 					 */
-					DEBUG_PRINT ("%s", "EMITTING scan-end");
+					DEBUG_PRINT ("EMITTING scan-end");
+#ifdef DEBUG	
+					if (priv->first_scan_timer_DEBUG != NULL)
+					{
+						DEBUG_PRINT ("TOTAL FIRST SCAN elapsed: %f",
+						    g_timer_elapsed (priv->first_scan_timer_DEBUG, NULL));
+						g_timer_stop (priv->first_scan_timer_DEBUG);
+					}
+#endif
+
 					g_async_queue_push (priv->signals_queue, GINT_TO_POINTER(SCAN_END + 1));
 				}
 				
@@ -2173,9 +2181,15 @@ sdb_engine_scan_files_1 (SymbolDBEngine * dbe, const GPtrArray * files_list,
 	{
 		sdb_engine_ctags_launcher_create (dbe);
 	}
-	
+
+	DEBUG_PRINT ("EMITTING scan begin.");
 	g_signal_emit_by_name (dbe, "scan-begin",
 	                       anjuta_launcher_get_child_pid (priv->ctags_launcher));
+
+#ifdef DEBUG	
+	if (priv->first_scan_timer_DEBUG == NULL)
+		priv->first_scan_timer_DEBUG = g_timer_new ();
+#endif
 	
 	/* create the shared memory file */
 	if (priv->shared_mem_file == 0)
@@ -5586,9 +5600,10 @@ sdb_engine_second_pass_do (SymbolDBEngine * dbe)
 	/* are we in a first population scan? */
 	if (priv->is_first_population == TRUE)
 	{
-		sdb_engine_tablemap_db_flush_sym_type (dbe);
-		sdb_engine_tablemap_db_flush_scope_def (dbe);
 		sdb_engine_tablemap_db_flush_symbol (dbe);
+		
+		sdb_engine_tablemap_db_flush_sym_type (dbe);
+		sdb_engine_tablemap_db_flush_scope_def (dbe);		
 	}
 
 	
@@ -5605,13 +5620,6 @@ static void
 sdb_engine_tablemap_db_flush_symbol (SymbolDBEngine * dbe)
 {
 	SymbolDBEnginePriv *priv;
-	gint i;
-	gint queue_length;
-	const GdaSet *plist;
-	const GdaStatement *stmt;
-	GdaHolder *param;
-	GValue *ret_value;
-	gboolean ret_bool;
 	GError *error = NULL;
 
 	priv = dbe->priv;
@@ -5619,182 +5627,14 @@ sdb_engine_tablemap_db_flush_symbol (SymbolDBEngine * dbe)
 #ifdef DEBUG
 	GTimer *sym_timer_DEBUG  = g_timer_new ();
 #endif
-	queue_length = g_queue_get_length (priv->symbol_tablemap_queue);
-
-	gda_connection_begin_transaction (priv->db_connection, "symboltrans", 
-	    GDA_TRANSACTION_ISOLATION_READ_UNCOMMITTED, &error);
-	
-	if (error)
-	{
-		g_warning (error->message);
-		g_error_free (error);
-		error = NULL;
-	}
-	
-	if ((stmt = sdb_engine_get_statement_by_query_id (dbe, PREP_QUERY_SYMBOL_NEW))
-		== NULL)
-	{
-		g_warning ("query is null");
-		return;
-	}
-
-	plist = sdb_engine_get_query_parameters_list (dbe, PREP_QUERY_SYMBOL_NEW);
-	
-	for (i = 0; i < queue_length; i++)
-	{
-		TableMapSymbol * node;
-		node = (TableMapSymbol *)g_queue_pop_head (priv->symbol_tablemap_queue);
-
-		/* filedefid parameter */
-		if ((param = gda_set_get_holder ((GdaSet*)plist, "filedefid")) == NULL)
-		{
-			g_warning ("param filedefid is NULL from pquery!");
-			return;
-		}
-		
-		MP_SET_HOLDER_BATCH_INT(priv, param, node->file_defined_id, ret_bool, ret_value);
 
-		/* name parameter */
-		if ((param = gda_set_get_holder ((GdaSet*)plist, "name")) == NULL)
-		{
-			g_warning ("param name is NULL from pquery!");			
-			return;
-		}
-		
-		MP_SET_HOLDER_BATCH_STR(priv, param, node->name, ret_bool, ret_value);		
-
-		/* typeid parameter */
-		if ((param = gda_set_get_holder ((GdaSet*)plist, "typeid")) == NULL)
-		{
-			g_warning ("param typeid is NULL from pquery!");
-			return;			
-		}
-		
-		MP_SET_HOLDER_BATCH_INT(priv, param, node->type_id, ret_bool, ret_value);		
-
-		/* common params */
-
-		/* fileposition parameter */
-		if ((param = gda_set_get_holder ((GdaSet*)plist, "fileposition")) == NULL)
-		{
-			g_warning ("param fileposition is NULL from pquery!");
-			return;
-		}
-		
-		MP_SET_HOLDER_BATCH_INT(priv, param, node->file_position, ret_bool, ret_value);
-		
-		/* isfilescope parameter */
-		if ((param = gda_set_get_holder ((GdaSet*)plist, "isfilescope")) == NULL)	
-		{
-			g_warning ("param isfilescope is NULL from pquery!");
-			return;
-		}
-		
-		MP_SET_HOLDER_BATCH_INT(priv, param, node->is_file_scope, ret_bool, ret_value);
-		
-		/* signature parameter */
-		if ((param = gda_set_get_holder ((GdaSet*)plist, "signature")) == NULL)	
-		{
-			g_warning ("param signature is NULL from pquery!");
-			return;
-		}
-		
-		MP_SET_HOLDER_BATCH_STR(priv, param, node->signature, ret_bool, ret_value);
-
-		/* returntype parameter */
-		if ((param = gda_set_get_holder ((GdaSet*)plist, "returntype")) == NULL)	
-		{
-			g_warning ("param returntype is NULL from pquery!");
-			return;
-		}
-		
-		MP_SET_HOLDER_BATCH_STR(priv, param, node->returntype, ret_bool, ret_value);	
-		
-		/* scopedefinitionid parameter */
-		if ((param = gda_set_get_holder ((GdaSet*)plist, "scopedefinitionid")) == NULL)	
-		{
-			g_warning ("param scopedefinitionid is NULL from pquery!");
-			return;
-		}
-		
-		MP_SET_HOLDER_BATCH_INT(priv, param, node->scope_definition_id, ret_bool, ret_value);
-		
-		/* scopeid parameter */
-		if ((param = gda_set_get_holder ((GdaSet*)plist, "scopeid")) == NULL)	
-		{
-			g_warning ("param scopeid is NULL from pquery!");
-			return;
-		}
-		
-		MP_SET_HOLDER_BATCH_INT(priv, param, node->scope_id, ret_bool, ret_value);
-		
-		/* kindid parameter */
-		if ((param = gda_set_get_holder ((GdaSet*)plist, "kindid")) == NULL)	
-		{
-			g_warning ("param kindid is NULL from pquery!");
-			return;
-		}
-		
-		MP_SET_HOLDER_BATCH_INT(priv, param, node->kind_id, ret_bool, ret_value);
-		
-		/* accesskindid parameter */
-		if ((param = gda_set_get_holder ((GdaSet*)plist, "accesskindid")) == NULL)	
-		{
-			g_warning ("param accesskindid is NULL from pquery!");
-			return;
-		}
-		
-		MP_SET_HOLDER_BATCH_INT(priv, param, node->access_kind_id, ret_bool, ret_value);
-
-		/* implementationkindid parameter */
-		if ((param = gda_set_get_holder ((GdaSet*)plist, "implementationkindid")) == NULL)	
-		{
-			g_warning ("param implementationkindid is NULL from pquery!");
-			return;
-		}
-		
-		MP_SET_HOLDER_BATCH_INT(priv, param, node->implementation_kind_id, ret_bool, ret_value);
-		
-		/* updateflag parameter */
-		if ((param = gda_set_get_holder ((GdaSet*)plist, "updateflag")) == NULL)
-		{
-			g_warning ("param updateflag is NULL from pquery!");
-			return;
-		}
-		
-		MP_SET_HOLDER_BATCH_INT(priv, param, node->update_flag, ret_bool, ret_value);
-
-		
-		/* execute the query with parametes just set */
-		gda_connection_statement_execute_non_select (priv->db_connection, 
-														 (GdaStatement*)stmt, 
-														 (GdaSet*)plist, NULL,
-														 NULL);
-
-		/* no need to free value, it'll be freed when associated value 
-		 * on hashtable'll be freed
-		 */
-		
-		MP_RESET_PLIST(plist);
-	}	
-	
 	gda_connection_commit_transaction (priv->db_connection, "symboltrans", &error);
 	
-	if (error)
-	{
-		g_warning (error->message);
-		g_error_free (error);
-		error = NULL;
-	}
-	
 #ifdef DEBUG	
 	gdouble elapsed_DEBUG = g_timer_elapsed (sym_timer_DEBUG, NULL);	
 	DEBUG_PRINT ("===== elapsed using GDA TRANSACTION: %f", elapsed_DEBUG);
 	g_timer_destroy (sym_timer_DEBUG);
 #endif	
-
-	/* free also all the keys/values on hashtable */
-	g_hash_table_remove_all (priv->symbol_tablemap_hash);
 }
 
 /**
@@ -5906,6 +5746,9 @@ sdb_engine_add_new_symbol_1st (SymbolDBEngine *dbe, const tagEntry *tag_entry,
  * particular case both base_prj_path and tag_entry->file will be ignored. 
  * fake_file is real_path of file on disk
  */
+
+static gboolean symboltrans = FALSE;
+
 static gint
 sdb_engine_add_new_symbol (SymbolDBEngine * dbe, const tagEntry * tag_entry,
 						   gint file_defined_id,
@@ -5953,13 +5796,20 @@ sdb_engine_add_new_symbol (SymbolDBEngine * dbe, const tagEntry * tag_entry,
 	g_return_val_if_fail (dbe != NULL, -1);
 	priv = dbe->priv;
 
-	if (priv->is_first_population == TRUE)
+	if (priv->is_first_population == TRUE && symboltrans == FALSE)
 	{
-		table_id = sdb_engine_add_new_symbol_1st (dbe, tag_entry, file_defined_id);
-		if (table_id > 0)
-			sdb_engine_add_new_tmp_heritage_scope (dbe, tag_entry, table_id);
+		GError *error = NULL;
+		symboltrans = TRUE;
+
+		gda_connection_begin_transaction (priv->db_connection, "symboltrans", 
+	    				GDA_TRANSACTION_ISOLATION_READ_UNCOMMITTED, &error);		
+
+		if (error)
+		{
+			g_warning (error->message);
+			g_error_free (error);
+		}
 		
-		return table_id;
 	}
 	
 	/* keep it at 0 if sym_update == false */
diff --git a/plugins/symbol-db/symbol-db-engine-priv.h b/plugins/symbol-db/symbol-db-engine-priv.h
index cf6a53c..ed66585 100644
--- a/plugins/symbol-db/symbol-db-engine-priv.h
+++ b/plugins/symbol-db/symbol-db-engine-priv.h
@@ -340,6 +340,10 @@ struct _SymbolDBEnginePriv
 	GQueue *mem_pool_string;
 	GQueue *mem_pool_int;
 #endif
+
+#ifdef DEBUG
+	GTimer *first_scan_timer_DEBUG;
+#endif	
 };
 
 #endif
