[tracker/wip/carlosg/insert-perf: 8/13] libtracker-data: Throw away the ontology/regular resource ID distinction
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/insert-perf: 8/13] libtracker-data: Throw away the ontology/regular resource ID distinction
- Date: Tue, 1 Dec 2020 12:24:50 +0000 (UTC)
commit 56b8bf5711ba58de0febc2130552e2067c2d1ee4
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Nov 28 19:25:08 2020 +0100
libtracker-data: Throw away the ontology/regular resource ID distinction
This only mattered for journals and replays. We don't have that anymore.
Furthermore, the split pool of IDs means we don't have one overflow
condition but two, and we handle neither well.
Letting the ID pool be shared means we may let SQLite pick a ROWID for us,
and it will definitely fare better if ROWIDs flipped the counter. It would
still result in an unused ROWID, we would badly break.
src/libtracker-data/tracker-data-manager.c | 14 +++--
src/libtracker-data/tracker-data-update.c | 87 ++----------------------------
src/libtracker-data/tracker-ontologies.h | 2 -
3 files changed, 10 insertions(+), 93 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 575d70c1f..8cdf70827 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -4618,10 +4618,8 @@ data_manager_perform_cleanup (TrackerDataManager *manager,
g_string_append (str, ") ");
g_string_append_printf (str,
"DELETE FROM Resource "
- "WHERE Resource.ID > %d "
- "AND Resource.ID NOT IN (SELECT ID FROM referencedElements) "
- "AND Resource.ID NOT IN (SELECT ID FROM Graph)",
- TRACKER_ONTOLOGIES_MAX_ID);
+ "WHERE Resource.ID NOT IN (SELECT ID FROM referencedElements) "
+ "AND Resource.ID NOT IN (SELECT ID FROM Graph)");
stmt = tracker_db_interface_create_statement (iface,
TRACKER_DB_STATEMENT_CACHE_TYPE_UPDATE,
@@ -4922,7 +4920,7 @@ tracker_data_manager_clear_graph (TrackerDataManager *manager,
continue;
stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_NONE,
&inner_error,
- "DELETE FROM \"%s\".\"%s\" WHERE ID > 100000",
+ "DELETE FROM \"%s\".\"%s\"",
graph,
tracker_class_get_name (classes[i]));
if (!stmt)
@@ -4940,7 +4938,7 @@ tracker_data_manager_clear_graph (TrackerDataManager *manager,
service = tracker_property_get_domain (properties[i]);
stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_NONE,
&inner_error,
- "DELETE FROM \"%s\".\"%s_%s\" WHERE ID >
100000",
+ "DELETE FROM \"%s\".\"%s_%s\"",
graph,
tracker_class_get_name (service),
tracker_property_get_name (properties[i]));
@@ -4991,7 +4989,7 @@ tracker_data_manager_copy_graph (TrackerDataManager *manager,
stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_NONE,
&inner_error,
"INSERT OR REPLACE INTO \"%s\".\"%s\" "
- "SELECT * from \"%s\".\"%s\" WHERE ID > 100000",
+ "SELECT * from \"%s\".\"%s\"",
destination,
tracker_class_get_name (classes[i]),
source,
@@ -5012,7 +5010,7 @@ tracker_data_manager_copy_graph (TrackerDataManager *manager,
service = tracker_property_get_domain (properties[i]);
stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_NONE,
&inner_error,
"INSERT OR REPLACE INTO \"%s\".\"%s_%s\" "
- "SELECT * from \"%s\".\"%s_%s\" WHERE ID >
100000",
+ "SELECT * from \"%s\".\"%s_%s\"",
destination,
tracker_class_get_name (service),
tracker_property_get_name (properties[i]),
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 8a040c977..415843e6e 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -127,8 +127,6 @@ struct _TrackerData {
GPtrArray *delete_callbacks;
GPtrArray *commit_callbacks;
GPtrArray *rollback_callbacks;
- gint max_service_id;
- gint max_ontology_id;
};
struct _TrackerDataClass {
@@ -412,78 +410,6 @@ tracker_data_dispatch_delete_statement_callbacks (TrackerData *data,
}
}
-static gint
-tracker_data_update_get_new_service_id (TrackerData *data,
- GError **error)
-{
- TrackerDBCursor *cursor = NULL;
- TrackerDBInterface *iface;
- TrackerDBStatement *stmt;
- GError *inner_error = NULL;
-
- if (data->in_ontology_transaction) {
- if (G_LIKELY (data->max_ontology_id != 0)) {
- return ++data->max_ontology_id;
- }
-
- iface = tracker_data_manager_get_writable_db_interface (data->manager);
-
- stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_SELECT,
&inner_error,
- "SELECT MAX(ID) AS A FROM Resource WHERE ID <=
%d", TRACKER_ONTOLOGIES_MAX_ID);
-
- if (stmt) {
- cursor = tracker_db_statement_start_cursor (stmt, &inner_error);
- g_object_unref (stmt);
- }
-
- if (cursor) {
- if (tracker_db_cursor_iter_next (cursor, NULL, &inner_error)) {
- data->max_ontology_id = MAX (tracker_db_cursor_get_int (cursor, 0),
data->max_ontology_id);
- }
-
- g_object_unref (cursor);
- }
-
- if (G_UNLIKELY (inner_error)) {
- g_propagate_error (error, inner_error);
- return 0;
- }
-
- return ++data->max_ontology_id;
- } else {
- if (G_LIKELY (data->max_service_id != 0)) {
- return ++data->max_service_id;
- }
-
- data->max_service_id = TRACKER_ONTOLOGIES_MAX_ID;
-
- iface = tracker_data_manager_get_writable_db_interface (data->manager);
-
- stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_SELECT,
&inner_error,
- "SELECT MAX(ID) AS A FROM Resource");
-
- if (stmt) {
- cursor = tracker_db_statement_start_cursor (stmt, &inner_error);
- g_object_unref (stmt);
- }
-
- if (cursor) {
- if (tracker_db_cursor_iter_next (cursor, NULL, &inner_error)) {
- data->max_service_id = MAX (tracker_db_cursor_get_int (cursor, 0),
data->max_service_id);
- }
-
- g_object_unref (cursor);
- }
-
- if (G_UNLIKELY (inner_error)) {
- g_propagate_error (error, inner_error);
- return 0;
- }
-
- return ++data->max_service_id;
- }
-}
-
static gint
tracker_data_update_get_next_modseq (TrackerData *data)
{
@@ -791,17 +717,12 @@ tracker_data_update_ensure_resource (TrackerData *data,
iface = tracker_data_manager_get_writable_db_interface (data->manager);
- id = tracker_data_update_get_new_service_id (data, &error);
-
- if (id > 0) {
- stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_UPDATE,
&error,
- "INSERT INTO Resource (ID, Uri, BlankNode)
VALUES (?, ?, ?)");
- }
+ stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_UPDATE, &error,
+ "INSERT INTO Resource (Uri, BlankNode) VALUES (?, ?)");
if (stmt) {
- tracker_db_statement_bind_int (stmt, 0, id);
- tracker_db_statement_bind_text (stmt, 1, uri);
- tracker_db_statement_bind_int (stmt, 2, g_str_has_prefix (uri, "urn:bnode:"));
+ tracker_db_statement_bind_text (stmt, 0, uri);
+ tracker_db_statement_bind_int (stmt, 1, g_str_has_prefix (uri, "urn:bnode:"));
tracker_db_statement_execute (stmt, &error);
g_object_unref (stmt);
}
diff --git a/src/libtracker-data/tracker-ontologies.h b/src/libtracker-data/tracker-ontologies.h
index 36857df8a..c984b7a2e 100644
--- a/src/libtracker-data/tracker-ontologies.h
+++ b/src/libtracker-data/tracker-ontologies.h
@@ -34,8 +34,6 @@ G_BEGIN_DECLS
#error "only <libtracker-data/tracker-data.h> must be included directly."
#endif
-#define TRACKER_ONTOLOGIES_MAX_ID 100000
-
#define TRACKER_TYPE_ONTOLOGIES (tracker_ontologies_get_type ())
#define TRACKER_ONTOLOGIES(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_ONTOLOGIES,
TrackerOntologies))
#define TRACKER_ONTOLOGIES_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TRACKER_TYPE_ONTOLOGIES,
TrackerOntologiesClass))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]