[tracker/delete: 3/3] libtracker-data: Bypass update buffer for rdf:type deletes if possible
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/delete: 3/3] libtracker-data: Bypass update buffer for rdf:type deletes if possible
- Date: Mon, 27 Dec 2010 14:16:18 +0000 (UTC)
commit de697e61f33a833e66b70d5e59a66327ea7eb10e
Author: Jürg Billeter <j bitron ch>
Date: Mon Dec 27 14:52:57 2010 +0100
libtracker-data: Bypass update buffer for rdf:type deletes if possible
This improves delete performance.
src/libtracker-data/tracker-data-update.c | 49 +++++++++++++++++++++++++++-
1 files changed, 47 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 9c12bc6..3724146 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -1657,7 +1657,7 @@ cache_delete_resource_type (TrackerClass *class,
TrackerDBStatement *stmt;
TrackerDBResultSet *result_set = NULL;
TrackerProperty **properties, *prop;
- gboolean found;
+ gboolean found, direct_delete;
gint i;
guint p, n_props;
GError *error = NULL;
@@ -1694,6 +1694,7 @@ cache_delete_resource_type (TrackerClass *class,
if (error) {
g_warning ("%s", error->message);
g_error_free (error);
+ error = NULL;
}
if (result_set) {
@@ -1709,6 +1710,10 @@ cache_delete_resource_type (TrackerClass *class,
g_object_unref (result_set);
}
+ /* bypass buffer if possible
+ we need old property values with FTS */
+ direct_delete = (!HAVE_TRACKER_FTS && g_hash_table_size (resource_buffer->tables) == 0);
+
/* delete all property values */
properties = tracker_ontologies_get_properties (&n_props);
@@ -1730,6 +1735,28 @@ cache_delete_resource_type (TrackerClass *class,
table_name = tracker_property_get_table_name (prop);
field_name = tracker_property_get_name (prop);
+ if (direct_delete) {
+ if (multiple_values) {
+ stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_UPDATE, &error,
+ "DELETE FROM \"%s\" WHERE ID = ?",
+ table_name);
+
+ if (stmt) {
+ tracker_db_statement_bind_int (stmt, 0, resource_buffer->id);
+ tracker_db_statement_execute (stmt, &error);
+ g_object_unref (stmt);
+ }
+
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+ }
+ /* single-valued property values are deleted right after the loop by deleting the row in the class table */
+ continue;
+ }
+
old_values = get_old_property_values (prop, NULL);
for (y = old_values->n_values - 1; y >= 0 ; y--) {
@@ -1766,7 +1793,25 @@ cache_delete_resource_type (TrackerClass *class,
}
}
- cache_delete_row (class);
+ if (direct_delete) {
+ stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_UPDATE, &error,
+ "DELETE FROM \"%s\" WHERE ID = ?",
+ tracker_class_get_name (class));
+
+ if (stmt) {
+ tracker_db_statement_bind_int (stmt, 0, resource_buffer->id);
+ tracker_db_statement_execute (stmt, &error);
+ g_object_unref (stmt);
+ }
+
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+ } else {
+ cache_delete_row (class);
+ }
if (!in_journal_replay && delete_callbacks) {
guint n;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]