aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs49
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>