开发者

Followup: Table Per Concrete Type Performance/Scaling

开发者 https://www.devze.com 2022-12-30 09:48 出处:网络
This is a followup/post question to another question; as I have discovered a solution that has led me to a new problem.

This is a followup/post question to another question; as I have discovered a solution that has led me to a new problem.

Classes to Entities; Like-class inheritence problems

We're building this game system, so to speak; and I am using Table Per Concrete Type concept to perform inheritance modeling.

My concern is scalability and performance. I believe I have used a similar technique before and it cam开发者_Python百科e out pretty sluggish, but I am not a good DBA, I am a programmer. So I'm very foreign to how this will translate to SQL. But basically it seems to me that it would be slow and weak to have so many 'linked' queries running together. I've posted my schema and entity model for reference. If I can give clearer information, please ask, as I am really not certain what is relevant to 'tuning' this approach.

alt text http://img46.imageshack.us/img46/1043/database.png

alt text http://img293.imageshack.us/img293/6454/entities.png

Sample use would be typical as follows;

static void Main(string[] args)
{
    DataContext db = new DataContext();

    Character character = new Character()
    {
        Name = "First",
        Ring = new Mapping.Ring()
    };


    character.Ring.Keys.Add(
        new Random()
        {
            Dice = 2,
            Sides = 30,
        });

    character.Ring.Keys.Add(
        new Measure()
        {
            Maximum = 100,
            Minimum = 0
        });
    character.Ring.Keys.Add(
        new Measure()
        {
            Maximum = 100,
            Minimum = 0
        });

    db.Characters.AddObject(character);
    db.SaveChanges();

    foreach (Character c in db.Characters)
    {
        Console.WriteLine(c.Name);

        Console.WriteLine(new string('-', 80));

        foreach (Measure k in c.Ring.Keys.OfType<Measure>())
            Console.WriteLine(String.Format("{0}/{1}", k.Minimum, k.Maximum));

        foreach (Random k in c.Ring.Keys.OfType<Random>())
            Console.WriteLine(String.Format("{0}d{1}", k.Dice, k.Sides));
    }

    Console.ReadLine();
}


I think a lot of this is going to come down to how the database is tuned, the indexes you have on the tables and the scope of the data.

To truly "prove" a data model, I'm a big fan of filling the tables with a bunch of data, and query it, see what happens, that is the only real way for you to validate the performance, or lack thereof for an application.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号