mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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
This commit is contained in:
parent
bde496195d
commit
05148a0532
@ -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 );
|
||||
|
Loading…
Reference in New Issue
Block a user