Re: View vs Constantly Updated Table

From: Ketema Harris <ketema(at)ketema(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: View vs Constantly Updated Table
Date: 2008-12-16 17:07:51
Message-ID: 04AD8641-8ABD-4539-A960-4D86FE668BB5@ketema.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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...

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gauthier, Dave 2008-12-16 17:24:42 Isolating a record column from a PL-Pgsql function call ?
Previous Message Andreas 2008-12-16 16:42:27 Re: How restrict select on a view ?