-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add possibility to get index size on disk #3968
Comments
Indexes are not covered by the SQL Standard at all. Information about on-disk size isn't stored anywhere and its calculation can be slow, so it is a bad idea to include it into meta tables, but a separate function can be implemented. |
I think you are right as I am not expert in SQL. I meant that many RDBMS do it using their own version of
In SQL Server (sys):
|
@katzyn I am now testing |
Primary keys, unique keys and foreign keys are constraints. You can read information about them from (There are also other types of constraints and other tables in Some types of constraints in H2 currently always create or use an existing compatible index (or even multiple indexes in historic versions of H2), but in some other database systems such indexes aren't required. If a constraint has an index, H2 reports its name in additional non-standard and non-portable Detailed information about indexes is available in non-standard |
@katzyn Thank you very much for your detailed explanation. But can I use When I say that indexes disappear I mean the following. These are my indexes when everything is OK - 33 indexes: And these are my indexes when something happened - same database, no any changes (no alter, no insert/update/delete etc). As you see there are only 7 indexes. Maybe
The above SQL has an error - see space before schema name. Now I am trying to reproduce this situation. But I had it already 3 times. |
This function doesn't modify anything and I have no idea what happened with indexes in your database. |
@katzyn I have the same problem the 4'th time and now I saved the broken database and compared it with normal database:
As you see not only indexes gone, but also tables, schemas and all rows. One schema is empty - no table inside it. But in normal DB this schema has 2 tables. I use h2 I worked with |
As I understand H2 currently doesn't provide the size of index on disk. There is a function disk_space_used but this function doesn't provide index size.
So I suggest to add such posssibility.
As it is more preferable to get index size separately from table size maybe it is better to add function
disk_space_used_idx (index_name)
.Another way is to provide table and index size (separately from each other) via information_schema. I think that using
information_schema
will be closer to SQL standard.The text was updated successfully, but these errors were encountered: