From 217a70e4e06ce811dba532c5df04b579d812a079 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 11 Feb 2008 16:49:07 +0000 Subject: [PATCH] update core sql for some speed tuning git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7581 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/private/switch_core_pvt.h | 2 +- src/switch_core_sqldb.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index e5d7bdab9f..7760babacf 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -78,7 +78,7 @@ typedef apr_os_thread_t switch_thread_id_t; #define SWITCH_EVENT_QUEUE_LEN 256 #define SWITCH_MESSAGE_QUEUE_LEN 256 -#define SWITCH_SQL_QUEUE_LEN 2000 +#define SWITCH_SQL_QUEUE_LEN 100000 #define SWITCH_BUFFER_BLOCK_FRAMES 25 #define SWITCH_BUFFER_START_FRAMES 50 diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index e33de610fd..dcc5f5351b 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -154,6 +154,7 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t * thread, char *tmp, *sqlbuf = (char *) malloc(sql_len); char *sql; switch_size_t newlen; + int lc = 0; switch_assert(sqlbuf); @@ -211,6 +212,11 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t * thread, *sqlbuf = '\0'; } + if (++lc == 300000) { + switch_core_db_exec(sql_manager.db, "vacuum;", NULL, NULL, NULL); + lc = 0; + } + if (nothing_in_queue) { switch_yield(1000); } @@ -394,6 +400,11 @@ void switch_core_sqldb_start(switch_memory_pool_t *pool) switch_core_db_exec(sql_manager.db, "drop table calls", NULL, NULL, NULL); switch_core_db_exec(sql_manager.db, "drop table interfaces", NULL, NULL, NULL); switch_core_db_exec(sql_manager.db, "drop table tasks", NULL, NULL, NULL); + switch_core_db_exec(sql_manager.db, "PRAGMA synchronous=OFF;", NULL, NULL, NULL); + switch_core_db_exec(sql_manager.db, "PRAGMA count_changes=OFF;", NULL, NULL, NULL); + switch_core_db_exec(sql_manager.db, "PRAGMA cache_size=8000", NULL, NULL, NULL); + switch_core_db_exec(sql_manager.db, "PRAGMA temp_store=MEMORY;", NULL, NULL, NULL); + switch_core_db_exec(sql_manager.db, create_channels_sql, NULL, NULL, NULL); switch_core_db_exec(sql_manager.db, create_calls_sql, NULL, NULL, NULL); switch_core_db_exec(sql_manager.db, create_interfaces_sql, NULL, NULL, NULL);