From 05148a053210e16ab80437404dc408e09d0b7ed7 Mon Sep 17 00:00:00 2001 From: Phil Longstaff Date: Tue, 7 Jul 2009 00:14:45 +0000 Subject: [PATCH] Make split queries stupid - depend only on account. This makes them *much* faster on sqlite3. Once they can be sped up, the stupidity can be removed. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18181 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/backend/sql/gnc-transaction-sql.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/backend/sql/gnc-transaction-sql.c b/src/backend/sql/gnc-transaction-sql.c index c488cdbb1d..95991cd1c5 100644 --- a/src/backend/sql/gnc-transaction-sql.c +++ b/src/backend/sql/gnc-transaction-sql.c @@ -53,6 +53,8 @@ #include "splint-defs.h" #endif +#define SIMPLE_QUERY_COMPILATION 1 + /*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN; #define TRANSACTION_TABLE "transactions" @@ -987,11 +989,19 @@ compile_split_query( GncSqlBackend* be, QofQuery* query ) if( strcmp( paramPath->data, QOF_PARAM_BOOK ) == 0 ) continue; +#if SIMPLE_QUERY_COMPILATION + if( strcmp( paramPath->data, SPLIT_ACCOUNT ) != 0 + || strcmp( paramPath->next->data, QOF_PARAM_GUID ) != 0 ) continue; +#endif + if( need_AND ) g_string_append( sql, " AND " ); if( strcmp( paramPath->data, SPLIT_ACCOUNT ) == 0 && strcmp( paramPath->next->data, QOF_PARAM_GUID ) == 0 ) { convert_query_term_to_sql( "s.account_guid", term, sql ); +#if SIMPLE_QUERY_COMPILATION + goto done_compiling_query; +#endif } else if( strcmp( paramPath->data, SPLIT_RECONCILE ) == 0 ) { convert_query_term_to_sql( "s.reconcile_state", term, sql ); @@ -1042,7 +1052,13 @@ compile_split_query( GncSqlBackend* be, QofQuery* query ) } } +#if SIMPLE_QUERY_COMPILATION +done_compiling_query: +#endif if( sql->len != 0 ) { +#if SIMPLE_QUERY_COMPILATION + g_string_append( sql, ")" ); +#endif query_sql = g_strdup_printf( "SELECT DISTINCT t.* FROM %s AS t, %s AS s WHERE s.tx_guid=t.guid AND %s", TRANSACTION_TABLE, SPLIT_TABLE, sql->str );