From b9eff63278d5bb8d59a40f7b837cff4843eaae05 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 2 Nov 2011 09:35:02 +0200 Subject: Optimize load_id(), load() sequence for SQLite and PostgreSQL In these databases both of these functions load the data into the object image. If there is no chance of image overwrite between these calls, then we don't need to load the image the second time. --- odb/object-result.hxx | 8 +++++++- odb/object-result.txx | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/odb/object-result.hxx b/odb/object-result.hxx index e4d28ee..8b0b502 100644 --- a/odb/object-result.hxx +++ b/odb/object-result.hxx @@ -111,8 +111,14 @@ namespace odb } protected: + // The fetch argument is a hint to the implementation. If it is + // false then it means load_id() was already called (and presumably + // fetched the data into the object image) and the object image + // is still valid (so the implementation doesn't need to fetch + // the data again). + // virtual void - load (object_type&) = 0; + load (object_type&, bool fetch = true) = 0; virtual id_type load_id () = 0; diff --git a/odb/object-result.txx b/odb/object-result.txx index 843ec59..c84abe8 100644 --- a/odb/object-result.txx +++ b/odb/object-result.txx @@ -52,7 +52,7 @@ namespace odb object_type& obj (pointer_traits::get_ref (p)); current (p); - load (obj); + load (obj, false); ig.release (); } } @@ -106,7 +106,7 @@ namespace odb typename reference_cache_traits::insert_guard ig ( reference_cache_traits::insert ( res_->database (), res_->load_id (), obj)); - res_->load (obj); + res_->load (obj, false); ig.release (); } } -- cgit v1.1