store media number in memory, db access is too slow when used as sort key
authorMichael Andres <ma@suse.de>
Fri, 3 Aug 2007 16:07:31 +0000 (16:07 +0000)
committerMichael Andres <ma@suse.de>
Fri, 3 Aug 2007 16:07:31 +0000 (16:07 +0000)
zypp/repo/cached/PackageImpl.cc
zypp/repo/cached/PackageImpl.h
zypp/repo/cached/SrcPackageImpl.cc
zypp/repo/cached/SrcPackageImpl.h

index b47c9f2..2587dc4 100644 (file)
@@ -136,7 +136,11 @@ Changelog PackageImpl::changelog() const
 
 unsigned PackageImpl::mediaNr() const
 {
-  return _repository->resolvableQuery().queryNumericAttribute( _id, cache::attrPackageLocationMediaNr() );
+  if ( _mnr == (unsigned)-1 )
+  {
+    _mnr = _repository->resolvableQuery().queryNumericAttribute( _id, cache::attrPackageLocationMediaNr() );
+  }
+  return _mnr;
 }
 
 ByteCount PackageImpl::downloadSize() const
index a8f47f1..a490a8e 100644 (file)
@@ -82,6 +82,8 @@ namespace cached
   private:
     repo::cached::RepoImpl::Ptr _repository;
     data::RecordId _id;
+
+    mutable DefaultIntegral<unsigned,(unsigned)-1> _mnr;
   };
   /////////////////////////////////////////////////////////////////
 } // namespace cached
index 1436a65..13cbeb9 100644 (file)
@@ -99,7 +99,11 @@ Date SrcPackageImpl::installtime() const
 
 unsigned SrcPackageImpl::mediaNr() const
 {
-  return _repository->resolvableQuery().queryNumericAttribute( _id, cache::attrSrcPackageLocationMediaNr() );
+  if ( _mnr == (unsigned)-1 )
+  {
+    _mnr = _repository->resolvableQuery().queryNumericAttribute( _id, cache::attrSrcPackageLocationMediaNr() );
+  }
+  return _mnr;
 }
 
 ByteCount SrcPackageImpl::downloadSize() const
index bab1152..43f8b9a 100644 (file)
@@ -56,9 +56,12 @@ namespace cached
     virtual Date installtime() const;
 
     virtual OnMediaLocation location() const;
+
   private:
     repo::cached::RepoImpl::Ptr _repository;
     data::RecordId              _id;
+
+    mutable DefaultIntegral<unsigned,(unsigned)-1> _mnr;
   };
   /////////////////////////////////////////////////////////////////
 } // ns cached