evolution-data-server r8883 - in branches/camel-db-summary/camel: . providers/local
- From: psankar svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r8883 - in branches/camel-db-summary/camel: . providers/local
- Date: Sun, 1 Jun 2008 19:00:56 +0000 (UTC)
Author: psankar
Date: Sun Jun 1 19:00:56 2008
New Revision: 8883
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8883&view=rev
Log:
Re-ordered SQL Quereies. Increases speed drastically.
Added Timer support to monitor time-taken to save to db.
etc.
Modified:
branches/camel-db-summary/camel/camel-db.c
branches/camel-db-summary/camel/camel-db.h
branches/camel-db-summary/camel/camel-folder-summary.c
branches/camel-db-summary/camel/camel-offline-journal.c
branches/camel-db-summary/camel/camel-store.c
branches/camel-db-summary/camel/providers/local/camel-local-summary.c
Modified: branches/camel-db-summary/camel/camel-db.c
==============================================================================
--- branches/camel-db-summary/camel/camel-db.c (original)
+++ branches/camel-db-summary/camel/camel-db.c Sun Jun 1 19:00:56 2008
@@ -10,7 +10,7 @@
#include <glib.h>
#include <glib/gi18n-lib.h>
-#define d(x) x
+#define d(x)
static int
cdb_sql_exec (sqlite3 *db, const char* stmt, CamelException *ex)
@@ -116,7 +116,7 @@
int ret;
d(g_print ("\nABORT TRANSACTION \n"));
- ret = cdb_sql_exec (cdb->db, "ABORT TRANSACTION", ex);
+ ret = cdb_sql_exec (cdb->db, "ABORT TRANSACTION;", ex);
g_mutex_unlock (cdb->lock);
return ret;
@@ -200,7 +200,6 @@
return count;
}
-
int
camel_db_select (CamelDB *cdb, const char* stmt, CamelDBSelectCB callback, gpointer data, CamelException *ex)
{
@@ -221,7 +220,6 @@
return ret;
}
-
int
camel_db_delete_folder (CamelDB *cdb, char *folder, CamelException *ex)
{
@@ -242,25 +240,38 @@
return ((camel_db_command (cdb, query, ex)));
}
-
-int
-camel_db_write_message_info_record (CamelDB *cdb, const char *folder_name, CamelMIRecord *record, CamelException *ex)
+int
+camel_db_prepare_message_info_table (CamelDB *cdb, const char *folder_name, CamelException *ex)
{
-
int ret;
-
- if (!cdb)
- return -1;
-
char *table_creation_query;
table_creation_query = g_strdup_printf ("CREATE TABLE IF NOT EXISTS %s ( uid TEXT PRIMARY KEY , flags INTEGER , read INTEGER , deleted INTEGER , replied INTEGER , important INTEGER , junk INTEGER , attachment INTEGER , size INTEGER , dsent NUMERIC , dreceived NUMERIC , subject TEXT , mail_from TEXT , mail_to TEXT , mail_cc TEXT , mlist TEXT , followup_flag TEXT , followup_completed_on TEXT , followup_due_by TEXT , part TEXT , labels TEXT , usertags TEXT , cinfo TEXT , bdata TEXT )", folder_name);
+ ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
+
+ g_free (table_creation_query);
+ return ret;
+}
+
+int
+camel_db_write_message_info_record (CamelDB *cdb, const char *folder_name, CamelMIRecord *record, CamelException *ex)
+{
+ int ret;
char *del_query;
char *ins_query;
- ins_query = g_strdup_printf ("INSERT INTO \"%s\" VALUES (\"%s\", %d, %d, %d, %d, %d, %d, %d, %d, %ld, %ld, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\" )", folder_name, record->uid, record->flags, record->read, record->deleted, record->replied, record->important, record->junk, record->attachment, record->size, record->dsent, record->dreceived, record->subject, record->from, record->to, record->cc, record->mlist, record->followup_flag, record->followup_completed_on, record->followup_due_by, record->part, record->labels, record->usertags, record->cinfo, record->bdata);
-
+ ins_query = g_strdup_printf ("INSERT INTO \"%s\" VALUES (\"%s\", %d, %d, %d, %d, %d, %d, %d, %d, %ld, %ld, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\" )",
+ folder_name, record->uid, record->flags,
+ record->read, record->deleted, record->replied,
+ record->important, record->junk, record->attachment,
+ record->size, record->dsent, record->dreceived,
+ record->subject, record->from, record->to,
+ record->cc, record->mlist, record->followup_flag,
+ record->followup_completed_on, record->followup_due_by,
+ record->part, record->labels, record->usertags,
+ record->cinfo, record->bdata);
+
del_query = g_strdup_printf ("DELETE FROM %s WHERE uid = \"%s\"", folder_name, record->uid);
#if 0
@@ -271,7 +282,6 @@
g_free (upd_query);
#else
- ret = camel_db_add_to_transaction (cdb, table_creation_query, ex);
ret = camel_db_add_to_transaction (cdb, del_query, ex);
ret = camel_db_add_to_transaction (cdb, ins_query, ex);
@@ -291,7 +301,11 @@
char *del_query;
char *ins_query;
- ins_query = g_strdup_printf ("INSERT INTO folders VALUES ( \"%s\", %d, %d, %d, 143, %d, %d, %d, %d, \"%s\" ) ", record->folder_name, record->version, record->flags , record->nextuid , record->saved_count , record->unread_count , record->deleted_count , record->junk_count , record->bdata);
+ ins_query = g_strdup_printf ("INSERT INTO folders VALUES ( \"%s\", %d, %d, %d, 143, %d, %d, %d, %d, \"%s\" ) ",
+ record->folder_name, record->version,
+ record->flags, record->nextuid,
+ record->saved_count, record->unread_count,
+ record->deleted_count, record->junk_count, record->bdata);
del_query = g_strdup_printf ("DELETE FROM folders WHERE folder_name = \"%s\"", record->folder_name);
Modified: branches/camel-db-summary/camel/camel-db.h
==============================================================================
--- branches/camel-db-summary/camel/camel-db.h (original)
+++ branches/camel-db-summary/camel/camel-db.h Sun Jun 1 19:00:56 2008
@@ -110,6 +110,8 @@
int camel_db_write_folder_info_record (CamelDB *cdb, CamelFIRecord *record, CamelException *ex);
int camel_db_read_folder_info_record (CamelDB *cdb, char *folder_name, CamelFIRecord **record, CamelException *ex);
+int camel_db_prepare_message_info_table (CamelDB *cdb, const char *folder_name, CamelException *ex);
+
int camel_db_write_message_info_record (CamelDB *cdb, const char *folder_name, CamelMIRecord *record, CamelException *ex);
int camel_db_read_message_info_records (CamelDB *cdb, char *folder_name, gpointer **p, CamelDBSelectCB read_mir_callback, CamelException *ex);
Modified: branches/camel-db-summary/camel/camel-folder-summary.c
==============================================================================
--- branches/camel-db-summary/camel/camel-folder-summary.c (original)
+++ branches/camel-db-summary/camel/camel-folder-summary.c Sun Jun 1 19:00:56 2008
@@ -71,7 +71,7 @@
/* this should probably be conditional on it existing */
#define USE_BSEARCH
-#define d(x) x
+#define d(x)
#define io(x) /* io debug */
#define w(x)
@@ -839,8 +839,12 @@
int i, count;
char *folder_name;
- /* Push MessageInfo-es */
folder_name = s->folder->full_name;
+ if (camel_db_prepare_message_info_table (cdb, folder_name, ex) != 0) {
+ return -1;
+ }
+
+ /* Push MessageInfo-es */
count = s->messages->len;
for (i = 0; i < count; ++i) {
mi = s->messages->pdata [i];
@@ -866,10 +870,16 @@
CamelDB *cdb = s->folder->parent_store->cdb;
CamelFIRecord *record;
int ret;
+ GTimer *timer, *trans_timer;
+
+
+ timer = g_timer_new ();
+ trans_timer = g_timer_new ();
d(printf ("\ncamel_folder_summary_save_to_db called \n"));
camel_db_begin_transaction (cdb, ex);
+ g_timer_start (trans_timer);
record = (((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_to_db (s));
if (!record) {
@@ -877,22 +887,32 @@
return -1;
}
+ g_timer_start (timer);
ret = camel_db_write_folder_info_record (cdb, record, ex);
g_free (record);
-
+ g_timer_stop (timer);
+
+ d(g_print ("\n Folderinfo record time taken : [%f] \n", g_timer_elapsed (timer, NULL)));
+
if (ret != 0) {
camel_db_abort_transaction (cdb, ex);
return -1;
}
+ g_timer_start (timer);
ret = save_message_infos_to_db (s, ex);
+ g_timer_stop (timer);
+
if (ret != 0) {
camel_db_abort_transaction (cdb, ex);
return -1;
}
+ d(g_print ("\n Messageinfo record time taken : [%f] \n", g_timer_elapsed (timer, NULL)));
camel_db_end_transaction (cdb, ex);
-
+ g_timer_stop (trans_timer);
+
+ d(g_print ("\n Transaction time taken : [%f] \n", g_timer_elapsed (trans_timer, NULL)));
return ret;
}
Modified: branches/camel-db-summary/camel/camel-offline-journal.c
==============================================================================
--- branches/camel-db-summary/camel/camel-offline-journal.c (original)
+++ branches/camel-db-summary/camel/camel-offline-journal.c Sun Jun 1 19:00:56 2008
@@ -45,7 +45,7 @@
#include "camel-offline-journal.h"
#include "camel-private.h"
-#define d(x) x
+#define d(x)
static void camel_offline_journal_class_init (CamelOfflineJournalClass *klass);
static void camel_offline_journal_init (CamelOfflineJournal *journal, CamelOfflineJournalClass *klass);
Modified: branches/camel-db-summary/camel/camel-store.c
==============================================================================
--- branches/camel-db-summary/camel/camel-store.c (original)
+++ branches/camel-db-summary/camel/camel-store.c Sun Jun 1 19:00:56 2008
@@ -42,7 +42,7 @@
#include "camel-store.h"
#include "camel-vtrash-folder.h"
-#define d(x) x
+#define d(x)
#define w(x)
static CamelServiceClass *parent_class = NULL;
Modified: branches/camel-db-summary/camel/providers/local/camel-local-summary.c
==============================================================================
--- branches/camel-db-summary/camel/providers/local/camel-local-summary.c (original)
+++ branches/camel-db-summary/camel/providers/local/camel-local-summary.c Sun Jun 1 19:00:56 2008
@@ -42,7 +42,7 @@
#define w(x)
#define io(x)
-#define d(x) x /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/
+#define d(x) /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/
#define CAMEL_LOCAL_SUMMARY_VERSION (1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]