Subject | Re: [firebird-support] Re: Calculating median value on a large table |
---|---|
Author | Bill Katelis |
Post date | 2004-01-14T02:13:23Z |
Many thanks !
Great idea - although it's not median age I'm trying to calculate (bad
example on my part) it is actual message timings
BUT I can use this method ... triggers on the insert table to update
counters on a timing range table ...
As far as concurrent updates - no problem as there is only 1 connection
updating the table.
so much appreciated.
bill
Svein Erling wrote:
Great idea - although it's not median age I'm trying to calculate (bad
example on my part) it is actual message timings
BUT I can use this method ... triggers on the insert table to update
counters on a timing range table ...
As far as concurrent updates - no problem as there is only 1 connection
updating the table.
so much appreciated.
bill
Svein Erling wrote:
>Depending upon your database, one option could be to have another
>table containing the total number of records per age. This table would
>have to be updated through an after insert/update/delete trigger.
>Though it could lead to problems if there are lots of concurrent
>updating of your database - it is not very uncommon for persons to be
>of the same age.
>
>If there are lots of conflicts like this, you could of course try to
>rather insert into one 'change table' with your trigger and then run a
>procedure updating the total number of records per age according to
>this change table (and removing the records from the change table) at
>set intervals.
>
>It is of course also possible to simply use a stored procedure to find
>the median, but with 30 million records this would be somewhat time
>consuming.
>
>Set
>- I support Firebird, I am a FirebirdSQL Foundation member.
>- Join today at http://www.firebirdsql.org/ff/foundation
>
>--- In firebird-support@yahoogroups.com, Bill Katelis wrote:
>
>
>>Hi,
>>Using FirebirdCS-1.5.0.4027-RC7.i686.rpm:
>>
>>Suppose I have a table with 30 million records as follows:
>>
>>create table (
>> name char(10),
>> age integer
>>);
>>
>>Can anybody suggest an efficient method of calculating the median
>>age (not average) ?
>>
>>thanks
>>bill
>>
>>
>
>
>
>
>