[tracker/wip/carlosg/perf-improvements: 3/5] libtracker-data: Release non-select statements



commit 127d7b6cb49789c146b092307ba3150cbf9a959b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jun 4 16:58:35 2020 +0200

    libtracker-data: Release non-select statements
    
    Commit ed204139a1a added this extra flag to fix a race condition with
    select statements, but broke the accounting for update statements that
    don't get a TrackerDBCursor. This made statements in the update cache
    essentially non-reusable, making the update cache ineffective.
    
    Fix this by releasing the update statement after execution. This relies
    on an update statement only being executed once after fetching from the
    update cache, but that's how things work already.
    
    This makes update statements in the cache again able to be reused in the
    future, avoiding needlessly having to compile new statements from scratch.

 src/libtracker-data/tracker-db-interface-sqlite.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c 
b/src/libtracker-data/tracker-db-interface-sqlite.c
index 75b9b7e85..d294a698a 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -2937,11 +2937,15 @@ tracker_db_statement_sqlite_release (TrackerDBStatement *stmt)
        TrackerDBInterface *iface = stmt->db_interface;
 
        g_assert (stmt->stmt_is_owned);
-       stmt->stmt_is_used = FALSE;
+
+       if (stmt->stmt_is_used) {
+               stmt->stmt_is_used = FALSE;
+               tracker_db_statement_sqlite_reset (stmt);
+               g_object_unref (stmt);
+               g_object_unref (iface);
+       }
+
        stmt->stmt_is_owned = FALSE;
-       tracker_db_statement_sqlite_reset (stmt);
-       g_object_unref (stmt);
-       g_object_unref (iface);
 }
 
 static void
@@ -3490,6 +3494,7 @@ tracker_db_statement_execute (TrackerDBStatement  *stmt,
        g_return_if_fail (!stmt->stmt_is_used);
 
        execute_stmt (stmt->db_interface, stmt->stmt, NULL, error);
+       tracker_db_statement_sqlite_release (stmt);
 }
 
 TrackerDBCursor *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]