![]() |
Datenbank: Firebird • Version: 2.5 • Zugriff über: egal
Anzahl Pages pro Tabelle ermitteln
Moin,
manchmal möchten Kunden wissen, warum ihre Datenbank so groß ist. Daher hab ich mir gedacht, ich mache mir ein Procedure, die mir die Größe jeder Tabelle ermittelt. Dazu hätte ich gern gewusst, wie viele Pages eine bestimmte Tabelle belegt. Ich hab es so versucht, wie unten zu sehen. Jedoch kommen mir die Ergebnisse nicht plausibel vor. Stimmt das so, was ich da mache? Kann ich die Anzahl Pages einfach mit einem Select count aus RDB$PAGES auslesen? Danke!
Code:
SET TERM ^ ;
CREATE OR ALTER PROCEDURE TABLE_COUNTS returns ( tabelle varchar(31), datensaetze integer, pagecount bigint, kb numeric(15,3), mb numeric(15,3)) as declare variable pagesize smallint; declare variable stmt varchar(200); begin SELECT MON$PAGE_SIZE FROM mon$database INTO :PAGESIZE; FOR select r.rdb$relation_name, count(*) as PageCount from rdb$relations r left outer join RDB$PAGES p on (p.rdb$relation_id = r.RDB$RELATION_ID) where rdb$system_flag = 0 and rdb$relation_type <> 1 group by r.RDB$RELATION_ID, r.rdb$relation_name into :TABELLE, :PageCount do begin STMT = 'SELECT COUNT(*) FROM ' || :TABELLE ||';'; execute statement stmt INTO :DATENSAETZE; KB = (:PAGECOUNT * :PAGESIZE) / 1024; MB = :KB / 1024; suspend; end end^ SET TERM ; ^ /* Aktuelle Priviligien auf dieser Prozedur */ GRANT EXECUTE ON PROCEDURE TABLE_COUNTS TO SYSDBA; |
AW: Anzahl Pages pro Tabelle ermitteln
Ich glaube, da hast du ein grundsätzliches Problem, weil in der RDB$PAGES keine Daten-Pages gelistet werden.
Jedenfalls bei mir nicht. Da taucht nirgendswo eine Page vom Typ 5 auf. Und das sind imho die Daten-Pages. gstat wird dich wohl eher zum Ziel bringen. |
AW: Anzahl Pages pro Tabelle ermitteln
Da brauchst gstat dazu.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:57 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz