]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update core sql for some speed tuning
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 11 Feb 2008 16:49:07 +0000 (16:49 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 11 Feb 2008 16:49:07 +0000 (16:49 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7581 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/private/switch_core_pvt.h
src/switch_core_sqldb.c

index e5d7bdab9faefd8c7d4d0ee8645d22a4ef4e6706..7760babacffa4af93690d45dd9a86ed8c4612ed0 100644 (file)
@@ -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
index e33de610fd0a1e3bbdd8f737995cdac5bcb96a1d..dcc5f5351b277699e199496d072f5608fda07d15 100644 (file)
@@ -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);