running totals

Поиск
Список
Период
Сортировка
От Mike Castle
Тема running totals
Дата
Msg-id 20001205115446.C17698@thune.mrc-home.org
обсуждение исходный текст
Ответы Re: running totals
Список pgsql-novice
I'm seeking advise on best way to handle something.

I have a series of containers of a variety of fixed sizes and I want to
put items into them, each of which may be different sizes.  (Actually it's
the length of a video tape and how many hours of tv shows I can put onto
it, but it's a pretty general problem).

The question is:  is it better to keep a running total on the containers
and update it every time an item is put into/removed from the container or
is it better to do a select every time and recalculate the size of the
items in the containers?

Or is this one of those in the class:  it depends?

Currently I have a trigger plpgsql function that updates a tape by
adding/subtracting the show just added/deleted from that tape. Since
intervals are integeral (sp?) types, I'm not worried about round off
errors.  If the value was a float, I'd suppose one would want to a select
at least every so often to account for round off error.

Also, right now I have the running total as part of the object.  This means
that when the object is not in use, that's an extra field that isn't being
utilized.  Not an issue in this case since the containers are almost all in
use at any given time.  But, when a field of a row is updated, is the whole
row read from the database, updated, then written back out?  If so, would
it be that in some cases, it would be better to break out fields that are
updated often into their own table with a reference?  Which is more
efficient?

Thanks,
mrc  (Going book shopping tonight for good Tcl/TK and general SQL books)
--
       Mike Castle       Life is like a clock:  You can work constantly
  dalgoda@ix.netcom.com  and be right all the time, or not work at all
www.netcom.com/~dalgoda/ and be right at least twice a day.  -- mrc
    We are all of us living in the shadow of Manhattan.  -- Watchmen

В списке pgsql-novice по дате отправления:

Предыдущее
От: Helge Bahmann
Дата:
Сообщение: Re: Transactions
Следующее
От: "Romina N. Tulisi"
Дата:
Сообщение: inner join