My application is similar to a very simple CAD program. The user can create and modify a database of several thousand, simple 3D objects (e.g. cubes and spheres). Each object has a position, orientation, and size. I anticipate having these objects serialized in the database.I want to render objects in the database in 3D views. The 3D views could be the entire database or a particular query (e.g. objects of a certain size). The views should always reflect the current state of the database as objects are added/removed.So my question is: how can I have the render loop efficiently access the database? These are the options I can think of:Give render loop direct access to database. Deserialize objects and render at each loop. This seems inefficient, but maybe not as bad as I fear.Give render loop direct access to database, but try to store data in such a way that it does not need to be serialized.Create another data structure that always mirrors the database, but is more easily rendered.
How to efficiently render objects in a database?
database;graphics;rendering
In general, it doesn't seem wise to bind one of the potentially slowest parts of an app (disk-based DB access) to one that's performance sensitive (3D rendering).I would consider either a Repository-style abstraction where you keep both an in-memory representation of the data and the DB store, flushing to the latter when the user is done editing; or, if the size of the data is manageable, an in-memory store such as Redis or memcached.All that said, I would only consider the above if you're actually running into performance or data consistency problems with a simpler setup. 