Re: View vs Constantly Updated Table - Mailing list pgsql-general

From Ketema Harris
Subject Re: View vs Constantly Updated Table
Date
Msg-id 04AD8641-8ABD-4539-A960-4D86FE668BB5@ketema.net
Whole thread Raw
In response to Re: View vs Constantly Updated Table  ("Adam Rich" <adam.r@sbcglobal.net>)
List pgsql-general
 > How often are you using the "bank balance" value?
I have no data on this as of yet, but it obviously needs to be correct
for when the user looks at it.

 > The opposite argument, is how long does the computation take?
  The computation is simple, however the amount of data that goes into
it grows as there are more and more
   transactions added.  This is why I was thinking of storing the
balance in a table sort of as a cache
   to avoid spinning through all pas transaction to get the current
balance.

 > and how quickly do you need it?
   as fast as possible of course :)

 > Also, if you would be taking any
> action with the value returned by the balance calculation, remember to
> lock any tables necessary to ensure the balance doesn't change between
> the time you compute it and the time you act on it.

I'll keep this in mind.  never done a lot of manual locking before,
but I can see where this is going to be needed.  Its possible to take
row locks and not complete table locks correct? (manual chapter 13.3)
I'm thinking if I use a single table to hold all users cached balances
then I would not want to lock the entire table just to retrieve and
act on one users balance.

thanks for the input

On Dec 15, 2008, at 11:27 AM, Adam Rich wrote:

Truncated...

pgsql-general by date:

Previous
From: Ketema
Date:
Subject: Re: Trigger/Rules Order of operations
Next
From: "Gauthier, Dave"
Date:
Subject: Isolating a record column from a PL-Pgsql function call ?