Subject | RE: [firebird-support] What programming languages and toolkits do you use to access Firebird? |
---|---|
Author | RB Smissaert |
Post date | 2008-09-30T23:02:59Z |
> you can guess at it from the number of RDB$PAGES entries there are forpointer
> pages for the table.Thanks will have a look at that; it sounds promising.
RBS
_____
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Ann W. Harrison
Sent: 30 September 2008 23:41
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] What programming languages and toolkits do
you use to access Firebird?
Mercea Paul wrote:
>That's a great way to induce update conflicts - every transaction
>...
>
> and make triggers on interested table like:
>
> CREATE OR ALTER TRIGGER mytable_COUNTROWS FOR mytable
> ACTIVE AFTER INSERT POSITION 0
> AS
> begin
> if (not exists(select 1 from tablesrows t where t.table_name='mytable')
> then
> insert into tablesrows (table_name, table_rows) values ('mytable',1);
>
> update tablesrows set table_rows = (select count(id) from mytable);
> end
> ^
that adds, changes, or removes rows from the table has to update a
single gatekeeper record.
If you don't care about how accurate your count is, you can guess
at it from the number of RDB$PAGES entries there are for pointer
pages for the table.
First, you'll have to find the RDB$RELATION_ID for the table -
select rdb$relation_id from rdb$relations
where rdb$relation_name = UPPER (<tablename>);
Then, use gstat to get an estimate of the number of records per
data page.
gstat -a >gstat.txt
Then, compute the approximate number of data pages per pointer
page
dp_per_pp =~ <page size> / 8
Then get the number of pointer pages in the table
select count(*) from rdb$pages
where rdb$page_type = 4 and rdb$relation_id = <saved id>
Multiply the count by the number of records per page and the
number of data pages per pointer page.
Don't use rdb$db_key - there are huge gaps in the number space.
Regards,
Ann
[Non-text portions of this message have been removed]