diff options
author | Melanie | 2009-09-02 03:33:31 +0100 |
---|---|---|
committer | Melanie | 2009-09-02 03:33:31 +0100 |
commit | f32de6fe885915b11fd349c0d8f3e6a98d4dd2bf (patch) | |
tree | 231027018a6e1dda86352e88a472f54c7786b5e1 /OpenSim/Data/MySQL/MySQLRegionData.cs | |
parent | Merge branch 'master' of ssh://MyConnection/var/git/opensim (diff) | |
download | opensim-SC_OLD-f32de6fe885915b11fd349c0d8f3e6a98d4dd2bf.zip opensim-SC_OLD-f32de6fe885915b11fd349c0d8f3e6a98d4dd2bf.tar.gz opensim-SC_OLD-f32de6fe885915b11fd349c0d8f3e6a98d4dd2bf.tar.bz2 opensim-SC_OLD-f32de6fe885915b11fd349c0d8f3e6a98d4dd2bf.tar.xz |
Thank you, dslake, for a set of patches to improve OpenSim startup
and idle performance.
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLRegionData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLRegionData.cs | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 9c2ee4a..4a16a70 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -412,8 +412,8 @@ namespace OpenSim.Data.MySQL | |||
412 | public List<SceneObjectGroup> LoadObjects(UUID regionUUID) | 412 | public List<SceneObjectGroup> LoadObjects(UUID regionUUID) |
413 | { | 413 | { |
414 | UUID lastGroupID = UUID.Zero; | 414 | UUID lastGroupID = UUID.Zero; |
415 | List<SceneObjectGroup> objects = new List<SceneObjectGroup>(); | 415 | Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>(); |
416 | List<SceneObjectPart> prims = new List<SceneObjectPart>(); | 416 | Dictionary<UUID, SceneObjectPart> prims = new Dictionary<UUID, SceneObjectPart>(); |
417 | SceneObjectGroup grp = null; | 417 | SceneObjectGroup grp = null; |
418 | 418 | ||
419 | lock (m_Connection) | 419 | lock (m_Connection) |
@@ -441,14 +441,14 @@ namespace OpenSim.Data.MySQL | |||
441 | else | 441 | else |
442 | prim.Shape = BuildShape(reader); | 442 | prim.Shape = BuildShape(reader); |
443 | 443 | ||
444 | prims.Add(prim); | 444 | prims[prim.UUID] = prim; |
445 | 445 | ||
446 | UUID groupID = new UUID(reader["SceneGroupID"].ToString()); | 446 | UUID groupID = new UUID(reader["SceneGroupID"].ToString()); |
447 | 447 | ||
448 | if (groupID != lastGroupID) // New SOG | 448 | if (groupID != lastGroupID) // New SOG |
449 | { | 449 | { |
450 | if (grp != null) | 450 | if (grp != null) |
451 | objects.Add(grp); | 451 | objects[grp.UUID] = grp; |
452 | 452 | ||
453 | lastGroupID = groupID; | 453 | lastGroupID = groupID; |
454 | 454 | ||
@@ -487,16 +487,47 @@ namespace OpenSim.Data.MySQL | |||
487 | } | 487 | } |
488 | 488 | ||
489 | if (grp != null) | 489 | if (grp != null) |
490 | objects.Add(grp); | 490 | objects[grp.UUID] = grp; |
491 | cmd.Dispose(); | 491 | cmd.Dispose(); |
492 | } | 492 | } |
493 | 493 | ||
494 | foreach (SceneObjectPart part in prims) | 494 | // Instead of attempting to LoadItems on every prim, |
495 | LoadItems(part); | 495 | // most of which probably have no items... get a |
496 | // list from DB of all prims which have items and | ||
497 | // LoadItems only on those | ||
498 | List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); | ||
499 | lock (m_Connection) | ||
500 | { | ||
501 | MySqlCommand itemCmd = m_Connection.CreateCommand(); | ||
502 | itemCmd.CommandText = "select distinct primID from primitems"; | ||
503 | IDataReader itemReader = ExecuteReader(itemCmd); | ||
504 | try | ||
505 | { | ||
506 | while (itemReader.Read()) | ||
507 | { | ||
508 | if (!(itemReader["primID"] is DBNull)) | ||
509 | { | ||
510 | UUID primID = new UUID(itemReader["primID"].ToString()); | ||
511 | if (prims.ContainsKey(primID)) | ||
512 | { | ||
513 | primsWithInventory.Add(prims[primID]); | ||
514 | } | ||
515 | } | ||
516 | } | ||
517 | } | ||
518 | finally | ||
519 | { | ||
520 | itemReader.Close(); | ||
521 | } | ||
522 | itemCmd.Dispose(); | ||
523 | } | ||
496 | 524 | ||
525 | foreach (SceneObjectPart prim in primsWithInventory) | ||
526 | { | ||
527 | LoadItems(prim); | ||
528 | } | ||
497 | m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); | 529 | m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); |
498 | 530 | return new List<SceneObjectGroup>(objects.Values); | |
499 | return objects; | ||
500 | } | 531 | } |
501 | 532 | ||
502 | /// <summary> | 533 | /// <summary> |