Re: Help with rewriting query - Mailing list pgsql-performance

From Tobias Brox
Subject Re: Help with rewriting query
Date
Msg-id 20050611095909.GR8451@tobias.nordicbet.com
Whole thread Raw
In response to Re: Help with rewriting query  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-performance
[Kevin Grittner - Fri at 02:49:57PM -0500]
> If you add a column to the person table for "last_food_id" and triggers
> to maintain it when the food table is modified, voila!  You have a
> simple and fast way to get the results you want.

Reminds me about the way the precursor software of our product was made,
whenever it was needed to check the balance of a customer, it was needed to
scan the whole transaction table and sum up all transactions.  This
operation eventually took 3-4 seconds before we released the new software,
and the customers balance was supposed to show up at several web pages :-)

By now we have the updated balance both in the customer table and as
"post_balance" in the transaction table.  Sometimes redundancy is good.
Much easier to solve inconsistency problems as well :-)

--
Tobias Brox, +47-91700050

pgsql-performance by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: faster search
Next
From: Cosimo Streppone
Date:
Subject: Re: faster search