db4o Developer Community

db4o open source object database, native to Java and .NET
Welcome to db4o Developer Community Sign in | Join
in Search
More Search Options

What is the proper way to make my query run faster

Last post 07-28-2008, 09:30 AM by Origon45. 1 replies.
Sort Posts: Previous Next
  •  07-27-2008, 06:27 AM 50330

    What is the proper way to make my query run faster

    I am learning db4o and like it a lot.
    Obviously I testing performance. And I do have a problem with the following.

    I am using SODA.

    My database contains 2 000 Products, 30 100 Customers and 300 100 Orders.
    An Order contains a reference to a Product instance and a Customer Instance.

    I have one index on Customer.LastName, Order.Amount and Product.Name.

    To make myself clear I will use the SQL metaphore.

    The following query run in 0.15s
     
        SELECT * FROM 'Order'
        WHERE
            Amount = '9560.333333333333333333333333'

    Bit the following query run in 5s

        SELECT * FROM 'Order'
        WHERE
            Amount = '9560.333333333333333333333333' and
            Customer.LastName = 'Colette U.1'

    Here I am referencing the property LastName from the Customer instance referenced by the Order instance.
     

    Here is my C# code

        IQuery          query   = cm._db.Query();
        query.Constrain(typeof(db4oMSE.TestClasses.Order));

        IConstraint C1 = query.Descend("Amount").Constrain(9560.333333333333333333333333M);
        IConstraint C2 = query.Descend("Customer").Descend("LastName").Constrain("Colette U.1");
        C2.And(C1);
        Db4objects.Db4o.IObjectSet ResultSet = query.Execute();


    What is the right way to write this kind of query ?


    How do we make it faster ?


        With a relational database this kind of query with a inner join with the right indexes would not take 5 seconds.

    Thanks.

    Filed under:
  •  07-28-2008, 09:30 AM 50343 in reply to 50330

    Re: What is the proper way to make my query run faster

    You have to set an index to the customer field, too.

    If you use single references to other objects you have to set an index on this field.

     

    mfg Origon
     

     


    Germany
View as RSS news feed in XML