Strategies for summary data in parent record based on detail data? I have parent-child relationship as shown below. I need to find the first order date for each customer. Obviously, writing a query to do this is fairly straight-forward but it does require reading all the records in CustomerOrders.

I've considered the following optimization approaches:


Add a FirstOrderDate field to CustomerMaster. Program the application to set the value when the customers orders for the first time. 
Same as #1 but use a trigger in the database instead of using the application.
Some other possibility that is better than the first two.


What is the best approach to handling this?

CustomerMaster
    CustomerID
    Customer Name
    .
    .
    .

CustomerOrders
    OrderID
    CustomerID
    OrderDate
    .
    .
    .


As for performance, there are 9.7 million records right now. The query takes 34 seconds. The data is growing all the time. 34 seconds is too slow right now and I expect it to be double that in two years
I would suggest doing it in the application rather than in the database with a trigger, only because it's not integral to the structure of the database; rather it's for performance reasons and I don't think doing it in the database will actually improve performance of the query that's running (it might slightly improve performance of the actual insert/update statements, but that's something that profiling could tell you better than I).

Doing it in the application would also give you more control of performing this operation optionally. It sounds like you would want this to always happen, but I have seen situations where testing would have been made easier if such logic were moved out of triggers so they could be turned on and off for testing purposes.