r16924 - gnucash/branches/gda-dev2/src/backend/gda - When opening a register, there are now 5 queries: 1) get tx guids for
Phil Longstaff
plongstaff at cvs.gnucash.org
Sun Feb 3 16:16:06 EST 2008
Author: plongstaff
Date: 2008-02-03 16:16:06 -0500 (Sun, 03 Feb 2008)
New Revision: 16924
Trac: http://svn.gnucash.org/trac/changeset/16924
Modified:
gnucash/branches/gda-dev2/src/backend/gda/gnc-transaction-gda.c
Log:
When opening a register, there are now 5 queries: 1) get tx guids for
all splits in the register 2) get all tx'es for those guids 3) get all
slots for those tx'es 4) get all splits for those tx'es 5) get all
slots for those splits. This makes register manipulation much faster.
However, more work may need to be done to ensure that we don't make the
sql line too long by splitting one or more of the queries.
Modified: gnucash/branches/gda-dev2/src/backend/gda/gnc-transaction-gda.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/gda/gnc-transaction-gda.c 2008-02-03 21:12:41 UTC (rev 16923)
+++ gnucash/branches/gda-dev2/src/backend/gda/gnc-transaction-gda.c 2008-02-03 21:16:06 UTC (rev 16924)
@@ -353,13 +353,52 @@
static void
load_splits_for_tx_list( GncGdaBackend* be, GList* list )
{
+ GString* sql;
+ GdaQuery* query;
+ QofCollection* col;
+ GdaObject* ret;
+ gchar guid_buf[GUID_ENCODING_LENGTH+1];
+ gboolean first_guid = TRUE;
+
g_return_if_fail( be != NULL );
if( list == NULL ) return;
+ sql = g_string_sized_new( 40+(GUID_ENCODING_LENGTH+3)*g_list_length( list ) );
+ g_string_append_printf( sql, "SELECT * FROM %s WHERE %s IN (", SPLIT_TABLE, guid_col_table[0].col_name );
for( ; list != NULL; list = list->next ) {
- load_all_splits_for_tx( be, qof_instance_get_guid( QOF_INSTANCE(list->data) ) );
- }
+ QofInstance* inst = QOF_INSTANCE(list->data);
+ guid_to_string_buff( qof_instance_get_guid( inst ), guid_buf );
+
+ if( !first_guid ) {
+ g_string_append( sql, "," );
+ }
+ g_string_append( sql, "'" );
+ g_string_append( sql, guid_buf );
+ g_string_append( sql, "'" );
+ first_guid = FALSE;
+ }
+ g_string_append( sql, ")" );
+
+ // Execute the query and load the splits
+ query = gnc_gda_create_query_from_sql( be, sql->str );
+ g_string_free( sql, TRUE );
+ ret = gnc_gda_execute_query( be, query );
+ if( GDA_IS_DATA_MODEL( ret ) ) {
+ GdaDataModel* pModel = GDA_DATA_MODEL(ret);
+ int numRows = gda_data_model_get_n_rows( pModel );
+ int r;
+ GList* list = NULL;
+
+ for( r = 0; r < numRows; r++ ) {
+ load_single_split( be, pModel, r, &list );
+ }
+
+ if( list != NULL ) {
+ gnc_gda_slots_load_for_list( be, list );
+ }
+ }
+ g_object_unref( ret );
}
static void
@@ -382,7 +421,7 @@
}
xaccTransBeginEdit( pTx );
gnc_gda_load_object( be, pModel, row, GNC_ID_TRANS, pTx, tx_col_table );
- gnc_gda_slots_load( be, QOF_INSTANCE(pTx) );
+// gnc_gda_slots_load( be, QOF_INSTANCE(pTx) );
*pList = g_list_append( *pList, pTx );
// load_all_splits( be, qof_instance_get_guid( QOF_INSTANCE(pTx) ) );
@@ -412,6 +451,7 @@
}
if( tx_list != NULL ) {
+ gnc_gda_slots_load_for_list( be, tx_list );
load_splits_for_tx_list( be, tx_list );
}
}
More information about the gnucash-changes
mailing list