Jump to content

OpenSimulator Internals/Databases

From Open Simulator Technical Help

OpenSimulator Internals/Databases

[edit]

Overview

[edit]

OpenSimulator uses two categories of database:

  • The grid database (osimdev_robust) -- owned by ROBUST, holds grid-wide data: user accounts, inventory, assets, presence, region registration, friends, avatar appearance
  • Region databases (osimdev_t1, osimdev_t2, ...) -- owned by the simulator, one per region, holds in-world object and terrain data

Both databases run on the same MariaDB instance. ROBUST never touches region databases. Simulators connect to ROBUST services over HTTP for grid data, and directly to their own region database for local data.

See OpenSimulator Internals/GridService, OpenSimulator Internals/Asset Connector, and OpenSimulator Internals/ROBUST Services for the service layer above these tables.


Grid Database (osimdev_robust)

[edit]

Table List

[edit]
Table Purpose
regions Region registration -- one row per online or recently-seen region
UserAccounts User accounts including the internal GRID SERVICES account
Avatars Avatar appearance: worn items, attachment points, visual params (key-value store)
GridUser Home region, last region, last position, login/logout timestamps
Presence Active sessions -- who is online right now and in which region
auth Password hashes and authentication tokens
tokens Session tokens for region-to-region and HyperGrid authentication
inventoryfolders Inventory folder hierarchy
inventoryitems Inventory item records
assets Asset metadata and binary data
Friends Friend relationships and permissions, including HyperGrid friends
AgentPrefs Per-user preferences (hover height, language, default permissions)
hg_traveling_data HyperGrid travel state for avatars currently visiting foreign grids
MuteList Per-user mute lists
im_offline Stored offline instant messages
migrations Schema version tracking for each service

regions

[edit]

One row per registered region. Written on simulator startup (RegisterRegion), updated on shutdown (DeregisterRegion).

Field Type Notes
uuid varchar(36) Primary key -- region UUID
regionHandle bigint unsigned locY
regionName varchar(128) Display name, max 128 chars
serverURI varchar(255) HTTP endpoint of the simulator e.g. http://osimdev.org:9000/
locX int unsigned Region origin X in metres (region coord * 256)
locY int unsigned Region origin Y in metres (region coord * 256)
sizeX int Region width in metres (512 for a 2x2 varregion)
sizeY int Region height in metres
flags int Bitmask of RegionFlags (4 = RegionOnline)
last_seen int Unix timestamp of last registration or deregistration
owner_uuid varchar(36) Estate owner UUID
ScopeID char(36) Grid scope -- zero UUID for default scope
access int unsigned Parcel access level (1 = PG)
regionMapTexture varchar(36) UUID of map tile image asset
PrincipalID char(36) Used for reservation authentication
Token varchar(255) Authentication token for reserved regions

Legacy fields present but unused in current code: regionRecvKey, regionSendKey, regionSecret, regionDataURI, regionAssetURI, regionAssetRecvKey, regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, serverRemotingPort, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle.

Sample row (T1 on osimdev):

Field Value
uuid 6f0a42d1-3053-422d-9c26-13205c9c7723
regionName T1
locX / locY 256000 (= region coordinate 1000)
sizeX / sizeY 512
flags 4 (RegionOnline)
serverURI http://osimdev.org:9000/

UserAccounts

[edit]
Field Type Notes
PrincipalID char(36) UUID primary key
FirstName varchar(64)
LastName varchar(64)
Email varchar(64) Login email
UserLevel int 0 = normal user, 240 = god-level
UserFlags int Reserved
Created int Unix timestamp

Two rows on a fresh grid: the admin avatar (UserLevel 0) and the internal GRID SERVICES account (UserLevel 240). The GRID SERVICES account has no auth record and never logs in -- it is used internally by OpenSim services.


Avatars

[edit]

Key-value store. One row per attribute per avatar. PrincipalID + Name form the composite key.

Name pattern Value format Notes
_ap_N UUID or comma-separated UUIDs Attachment point N -- asset UUID of worn item. Comma-separated for multi-attach points.
Wearable N:0 inventoryUUID:assetUUID Worn wearable layer N. 0=shape, 1=skin, 2=shirt, 3=pants, 13=physics, etc.
AvatarHeight float Avatar height in metres
AvatarType int 0 = classic system avatar, 1 = mesh avatar
VisualParams comma-separated bytes 253-element appearance slider array -- body shape, skin tone, hair color etc.
Serial int Appearance version serial number

Attachment point numbers follow the SL/OpenSim standard: 2=chest, 5=left hand, 12=hair, 40=left foot, etc. Multi-attach points store comma-separated UUIDs.

Sample data (Jagga Meredith, 13 rows): AvatarType=1 (mesh), AvatarHeight=1.6885326, 4 attachment points, 5 wearable layers (shape, skin, shirt, pants, physics).


GridUser

[edit]

One row per user. Written on first login, updated on every login, logout, and teleport.

Field Type Notes
UserID varchar(255) UUID or HyperGrid URI -- primary key
HomeRegionID char(36) UUID of home region
HomePosition varchar(64) Vector3 in region-local metres
HomeLookAt varchar(64) Vector3 look direction
LastRegionID char(36) UUID of last visited region
LastPosition varchar(64) Vector3 in region-local metres
LastLookAt varchar(64) Vector3 look direction
Online tinyint 1 only while session is active
Login int Unix timestamp of last login
Logout int Unix timestamp of last logout

UserID is varchar(255) not char(36) -- accommodates HyperGrid user URIs from foreign grids.


Presence

[edit]

One row per active session. Empty when no users are logged in. Rows are created on login and deleted on logout.

Field Type Notes
SessionID char(36) Primary key -- unique per login session
UserID varchar(255) UUID or HyperGrid URI
RegionID char(36) Current region UUID -- zero UUID if not yet in a region
SecureSessionID char(36) Secondary session token for viewer authentication
LastSeen timestamp Auto-updated on change -- used to detect stale sessions

auth

[edit]

One row per user account. Stores password credentials.

Field Type Notes
UUID char(36) Primary key -- matches UserAccounts.PrincipalID
passwordHash char(32) MD5 hash of password
passwordSalt char(32) MD5 salt
webLoginKey varchar(255) UUID for web-based login -- zero UUID if not configured
accountType varchar(32) Default: UserAccount

GRID SERVICES account has no auth row -- it cannot log in.


tokens

[edit]

Short-lived session tokens used for region-to-region and HyperGrid authentication.

Field Type Notes
UUID char(36) User UUID -- composite primary key with token
token varchar(255) UUID-format token
validity datetime Expiry datetime -- expired tokens remain until cleaned up

Multiple tokens per user are normal -- one per teleport attempt. Expired tokens are not automatically deleted; they accumulate until a cleanup job runs.


assets

[edit]
Field Type Notes
id char(36) Primary key -- asset UUID
name varchar(64) Display name
description varchar(64) Description -- HG landmarks store grid URI here
assetType tinyint Asset type number (see below)
data longblob Raw binary asset data
local tinyint(1) 1 = local-only, not transferred to other grids
temporary tinyint(1) 1 = temporary, may be discarded
asset_flags int Bitmask of asset flags
CreatorID varchar(128) Creator UUID or HyperGrid URI
create_time int Unix timestamp of creation
access_time int Unix timestamp of last access

Asset types observed on osimdev:

assetType Name
0 Texture
3 Landmark -- HG landmarks store grid URI in description field
6 Object -- serialized prim/linkset XML
7 Notecard
10 Script
20 Animation

Library/system assets use non-random UUID patterns and CreatorID 11111111-1111-0000-0000-000100bba000. On osimdev after initial setup and one user session: 2602 total assets, 85 user-created (1 texture, 4 landmarks, 79 objects, 1 notecard).


inventoryfolders

[edit]
Field Type Notes
folderID char(36) Primary key
folderName varchar(64) Display name
type smallint Folder type (see below)
version int Incremented on folder contents change
agentID char(36) Owner UUID
parentFolderID char(36) Parent folder UUID -- zero UUID for root

System folder types:

type Name
-1 User-created folder
0 Textures
1 Sounds
2 Calling Cards
3 Landmarks
5 Clothing
6 Objects
7 Notecards
8 My Inventory (root)
10 Scripts
13 Body Parts
14 Trash
15 Photo Album
16 Lost And Found
20 Animations
21 Gestures
23 Favorites
46 Current Outfit
47 Outfit
48 My Outfits
50 Received Items
56 Settings
57 Materials
100 My Suitcase (HyperGrid)

My Suitcase (type 100) is the HyperGrid suitcase -- items here travel with the avatar to foreign grids. Firestorm creates system folders: #Firestorm (containing #AO, #LSL Bridge, #Wearable Favorites).


inventoryitems

[edit]
Field Type Notes
inventoryID char(36) Primary key
assetID varchar(36) Foreign key to assets.id
assetType int Asset type
invType int Inventory type (can differ from assetType)
inventoryName varchar(64) Display name
inventoryDescription varchar(128)
avatarID char(36) Owner UUID
parentFolderID char(36) Containing folder UUID
creatorID varchar(255) Creator UUID or HyperGrid URI
inventoryBasePermissions int unsigned Base permission bitmask
inventoryCurrentPermissions int unsigned Current permission bitmask
inventoryNextPermissions int unsigned Next owner permission bitmask
inventoryEveryOnePermissions int unsigned Everyone permission bitmask
inventoryGroupPermissions int unsigned Group permission bitmask
groupID varchar(36) Associated group UUID
groupOwned tinyint 1 if group-owned
salePrice int Sale price in grid currency
saleType tinyint 0=not for sale, 1=original, 2=copy, 3=contents
creationDate int Unix timestamp
flags int unsigned Item flags

creatorID is varchar(255) to accommodate HyperGrid creator URIs. Item count on osimdev after initial session and AviWorlds visit: 380 items (171 objects, 75 animations, 34 links, 28 textures, 24 body parts, 21 clothing, 15 landmarks, 6 notecards, 3 scripts, 2 sounds, 1 mesh).


Friends

[edit]

One row per directional friendship. Friendships are stored as two rows (A->B and B->A).

Field Type Notes
PrincipalID varchar(255) Owner UUID or HyperGrid URI -- composite primary key
Friend varchar(255) Friend UUID or HyperGrid compound string
Flags varchar(16) Permission flags (1 = accepted)
Offered varchar(32) Pending offer token

For HyperGrid friends, Friend field format is: UUID;GridURI;DisplayName;token

Example: 5a365446-ad4f-4f7f-a843-563494b0e78b;http://login.aviworlds.com:8002/;Jagga Meredith;23cba5bc


AgentPrefs

[edit]

One row per user. Written when user explicitly sets preferences in-world. Defaults apply if no row exists.

Field Type Default Notes
PrincipalID char(36) -- Primary key
AccessPrefs char(2) M Content rating: G, M, or A
HoverHeight double 0.0 Avatar hover offset in metres
Language char(5) en-us Viewer language preference
LanguageIsPublic tinyint 1 Whether language preference is visible to others
PermEveryone int 0 Default everyone permissions for new objects
PermGroup int 0 Default group permissions for new objects
PermNextOwner int 532480 Default next owner permissions for new objects

hg_traveling_data

[edit]

Tracks avatars currently traveling between grids via HyperGrid. One row per active HG session. Rows are deleted when the avatar returns home or logs out. Empty when no avatars are traveling.

Field Type Notes
SessionID varchar(36) Primary key
UserID varchar(36) Avatar UUID
GridExternalName varchar(255) URI of the grid being visited
ServiceToken varchar(255) Auth token for the foreign grid session
ClientIPAddress varchar(16) Avatar's client IP on the foreign grid
MyIPAddress varchar(16) This grid's external IP as seen by the foreign grid
TMStamp timestamp Auto-updated -- used to detect stale travel records

Region Database (osimdev_t1)

[edit]

Table List

[edit]
Table Purpose
prims Every prim/object in the region -- 103 fields
primshapes Shape, scale, and texture data for each prim
primitems Inventory items inside prim object contents
terrain Region heightmap -- one blob per region
bakedterrain Baked terrain data
land Parcel definitions
landaccesslist Per-parcel access lists
regionsettings Region-wide settings (gravity, water level, sun, terrain textures)
regionenvironment Environment/windlight settings
regionwindlight Legacy windlight settings
regionextra Extra region key-value data
estate_settings Estate configuration (name, owner, access flags)
estate_map Maps regions to estates
estate_managers Estate manager UUID list
estate_groups Estate group access list
estate_users Estate user access list
estateban Estate ban list
regionban Region-level ban list
spawn_points Avatar spawn point locations
migrations Schema version tracking

prims

[edit]

103 fields. One row per prim. The root prim of a linked object has UUID = SceneGroupID.

Key fields:

Field Notes
UUID Primary key -- prim UUID
SceneGroupID UUID of the root prim of the linked object this prim belongs to
RegionUUID Foreign key to regions table in osimdev_robust
Name Prim name
OwnerID Owner UUID
CreatorID Creator UUID or HyperGrid URI (varchar 255)
LinkNumber Position in linkset (1 = root, 2+ = children)
GroupPositionX/Y/Z World position of the linkset root in region-local metres
PositionX/Y/Z Position relative to the linkset root
RotationX/Y/Z/W Quaternion rotation
ScaleX/Y/Z Scale (in primshapes table)
ObjectFlags Prim property flags bitmask
OwnerMask/NextOwnerMask/GroupMask/EveryoneMask/BaseMask Permission bitmasks
Material Material type (default 3 = wood)
PhysicsShapeType Physics shape (0=prim, 1=none, 2=convex hull)
Density/Friction/Restitution/GravityModifier Physics properties
SitTargetOffset/Orient Sit target position and orientation
TextureAnimation Blob -- animated texture data
ParticleSystem Blob -- particle system data
KeyframeMotion Blob -- keyframe animation path
Vehicle Text -- vehicle parameters
DynAttrs Text -- dynamic attributes (LSL)
sopanims Blob -- object animation data
lnkstBinData Blob -- linkset binary data
pseudocrc Integer -- change detection checksum

Important: When querying object names by SceneGroupID, use WHERE UUID = SceneGroupID to get the root prim name. Using MIN(Name) or similar aggregates will return a child prim name, not the object name.

Sample objects on osimdev T1 (472 prims across 8 linksets):

Name Prims World Position
Athena Mesh Body Skin Applier (HUD) 193 178, 264, 26
Brown House 181 238, 255, 24
4 Chair Set 54 244, 266, 25
Athena Bento BoM Mesh Body 6.5 (worn attachment) 36 181, 284, 24
Brown House Sculpts 5 252, 255, 26
Sofa 1 247, 272, 25
Object (cube) 1 188, 275, 24
Box 1 219, 281, 24

primshapes

[edit]

One row per prim. UUID is foreign key to prims.UUID.

Field Notes
UUID Primary key -- foreign key to prims.UUID
ScaleX/Y/Z Prim dimensions in metres
PCode Primitive code: 9=primitive, 95=grass, 111=tree, 255=avatar
Shape Shape type: 0=box, 1=cylinder, 2=prism, 3=sphere, 4=torus, 5=tube, 6=ring, 7=sculpt/mesh
ProfileCurve Profile shape: 1=square, 0=circle, 2=isometric triangle, 4=equilateral triangle
PathCurve Path type: 16=straight, 32=circle, 17=flexible
PathBegin/End Path cut start/end (0-50000 maps to 0.0-1.0)
ProfileBegin/End Profile cut
ProfileHollow Hollow amount
PathTwist/TwistBegin Twist
PathTaperX/Y Taper
PathShearX/Y Shear (top shear)
PathSkew Skew
PathRadiusOffset Radius offset
PathRevolutions Revolutions (torus)
Texture Longblob -- serialized per-face texture data
ExtraParams Longblob -- mesh/sculpt UUID and extra parameters
Media Text -- media-on-a-prim settings
LastAttachPoint Last attachment point if worn
MatOvrd Blob -- material override data (PBR)

Sample (cube): PCode=9, Shape=0, Scale=0.5x0.5x0.5, ProfileCurve=1 (square), PathCurve=16 (straight).


primitems

[edit]

Inventory items inside prim contents. One row per item.

Field Notes
itemID Primary key
primID Foreign key to prims.UUID -- which prim contains this item
assetID Foreign key to osimdev_robust.assets.id -- cross-database reference
assetType Asset type
invType Inventory type
name Item name
CreatorID varchar(255) -- accommodates HyperGrid URIs
ownerID Owner UUID
parentFolderID Folder UUID (within prim inventory)
nextPermissions/currentPermissions/basePermissions/everyonePermissions/groupPermissions Permission bitmasks
salePrice/saleType Sale settings
creationDate Bigint Unix timestamp

The assetID field in primitems references osimdev_robust.assets -- a cross-database foreign key. The asset data lives in the grid database; only the inventory record lives in the region database.

Example: notecard "test note" (assetType 7) in the Box object, assetID 6f2d7ffb-99f4-431a-919e-eb8cd174a620 confirmed present in osimdev_robust.assets.


terrain

[edit]
Field Notes
RegionUUID varchar(255) -- region identifier
Revision int -- incremented on each terrain save
Heightfield longblob -- compressed binary heightmap

One row per region. Heightfield is a compressed float array. For a 512x512 varregion: 262144 points, stored compressed. Export via simulator console: terrain save filename.r32. R32 format is a flat array of 32-bit IEEE floats, one per point, row by row SW to NE. Point at index N: X = N % width, Y = N / width, Z = elevation in metres.

Sample (T1): Revision=23, Heightfield=27337 bytes compressed.


regionsettings

[edit]

One row per region. 50 fields covering all region-wide configuration.

Key fields:

Field Default Notes
regionUUID -- Primary key
agent_limit 40 Maximum simultaneous avatars
water_height 20 Water level in metres
terrain_texture_1..4 (library UUIDs) Terrain textures for SW, NW, NE, SE corners
elevation_1/2_nw/ne/se/sw 10/60 Elevation blend thresholds per corner
terrain_raise/lower_limit 100/-100 Terraforming range in metres
maturity 0 0=General, 1=Moderate, 2=Adult
disable_scripts 0 1 = scripts disabled region-wide
disable_collisions 0 1 = collisions disabled
disable_physics 0 1 = physics disabled
block_terraform 0 1 = terraforming blocked
block_fly 0 1 = flying blocked
allow_damage 0 1 = damage enabled
use_estate_sun 1 1 = follow estate sun settings
fixed_sun 0 1 = sun locked at sun_position
Sandbox 0 1 = sandbox mode
covenant NULL UUID of covenant notecard asset
map_tile_ID (UUID) UUID of generated map tile image
TelehubObject zero UUID UUID of telehub object if set
TerrainPBR1..4 (UUIDs) PBR terrain textures -- same UUIDs as terrain_texture on osimdev
object_bonus 1 Prim bonus multiplier

land

[edit]

One row per parcel. Bitmap field stores the parcel shape as a compressed bit array.

Key fields:

Field Notes
UUID Primary key -- parcel UUID
RegionUUID Region this parcel belongs to
LocalLandID Integer parcel ID within the region
Name Parcel name
OwnerUUID Owner UUID
Area Parcel area in square metres
LandStatus 0=owned, 1=for sale, 2=for sale to specific avatar
LandFlags Bitmask of parcel permissions and settings
Bitmap Longblob -- parcel shape bitmap
UserLocationX/Y/Z Landing point position (0,0,0 = no landing point set)
water_height Water level override
MusicURL Parcel music stream URL
MediaURL Parcel media URL
PassHours/PassPrice Temporary pass settings
OtherCleanTime Auto-return time in minutes (0 = disabled)
SeeAVs/AnyAVSounds/GroupAVSounds Avatar and sound visibility settings

Sample (T1): one parcel covering the entire 512x512 region (Area=262144), owned by Jagga, no landing point set.


estate_settings

[edit]

One row per estate.

Key fields:

Field Notes
EstateID Integer ID (101 on osimdev -- system default is 1)
EstateName Display name
EstateOwner UUID of estate owner
ParentEstateID 1 = top-level estate
PublicAccess 1 = open to all
AllowDirectTeleport 1 = no telehub routing required
AllowVoice 1 = voice enabled
AllowLandmark 1 = landmark creation permitted
AllowParcelChanges 1 = parcel subdivision/join permitted
AllowSetHome 1 = avatars can set home here
DenyMinors 1 = block avatars under 18
DenyAnonymous 1 = block unverified accounts
UseGlobalTime 1 = use grid-wide time
FixedSun 1 = sun locked
SunPosition Sun angle when FixedSun=1
ResetHomeOnTeleport 1 = reset home when teleporting out
EstateSkipScripts 1 = scripts disabled estate-wide
AllowEnviromentOverride 1 = parcels can override environment

estate_map

[edit]

Two-field mapping table linking regions to estates.

Field Notes
RegionID Primary key -- region UUID
EstateID Foreign key to estate_settings.EstateID

Sample (T1): RegionID = T1 UUID, EstateID = 101.


estate_managers / estate_groups / estate_users / estateban / regionban / landaccesslist

[edit]

All follow the same pattern -- EstateID or RegionID plus a UUID. All empty on a fresh single-user grid.

Table Purpose
estate_managers UUIDs of avatars with estate manager rights
estate_groups Groups with estate-level access
estate_users Individual avatars with estate-level access
estateban Avatars banned from the estate
regionban Avatars banned from the region
landaccesslist Per-parcel access and ban lists

spawn_points

[edit]

Stores avatar spawn locations for the region. Empty = use default spawn.

Field Notes
RegionID Region UUID
Yaw Horizontal angle in radians -- relative to region centre
Pitch Vertical angle in radians
Distance Distance from region centre in metres

Note: spawn points are stored as spherical coordinates (yaw/pitch/distance) relative to the region centre, not as absolute X/Y/Z world coordinates.


regionenvironment

[edit]

Modern EEP (Extended Environment Protocol) settings. Replaces regionwindlight for viewers that support EEP.

Field Notes
region_id Primary key -- region UUID
llsd_settings mediumtext -- full environment settings serialized as LLSD

Empty when using default environment settings.


regionwindlight

[edit]

Legacy Windlight environment settings. 63 fields covering water appearance, atmosphere, clouds, and sun/moon parameters. Present for backwards compatibility with viewers that do not support EEP.

Key field groups:

  • Water: water_color_r/g/b, water_fog_density_exponent, underwater_fog_modifier, reflection_wavelet_scale, fresnel_scale/offset, refract_scale, blur_multiplier, wave directions, normal_map_texture
  • Atmosphere: horizon_r/g/b/i, haze_horizon, blue_density_r/g/b/i, haze_density, density_multiplier, distance_multiplier, max_altitude
  • Sun/Moon: sun_moon_color_r/g/b/i, sun_moon_position, ambient_r/g/b/i, east_angle, sun_glow_focus/size, scene_gamma, star_brightness
  • Clouds: cloud_color, cloud_x/y, cloud_density/coverage/scale, cloud_detail, cloud_scroll_x/y with lock flags, draw_classic_clouds

Default values are the SL/OpenSim standard windlight preset. Empty when using defaults.


regionextra

[edit]

Generic key-value store for region-level extra data. Same pattern as the Avatars table in osimdev_robust.

Field Notes
RegionID Composite primary key
Name Key name -- varchar(32)
value Text value

Empty on osimdev -- no extra region data set.


migrations

[edit]

Schema version tracking. One row per migration set, recording the current schema revision. Used by OpenSim's migration system to apply database upgrades on startup.

Field Notes
version Current schema revision number for this migration set
name Migration set name (e.g. GridStore, AssetStore, InventoryStore)

See Also

[edit]