Skip to content
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

TiDB should be able to use sql to get the disk usage #7468

Closed
winoros opened this issue Aug 23, 2018 · 3 comments
Closed

TiDB should be able to use sql to get the disk usage #7468

winoros opened this issue Aug 23, 2018 · 3 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

Comments

@winoros
Copy link
Member

winoros commented Aug 23, 2018

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.

  2. What did you expect to see?

There's a builtin function or something else, which we can use to get the disk-usage of one table or one database.

  1. What did you see instead?

Currently there's only http API to do this. And we can use tidb-ctl to do this.
But sql may be much easier.

  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
@winoros winoros added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Aug 23, 2018
@morgo
Copy link
Contributor

morgo commented Aug 23, 2018

The SQL standard way to do this is information_schema. Currently TiDB sets information_schema.tables.data_length to always be 16384 (1 InnoDB page).

+1 for exposing more features through the server. The MySQL team is doing this too (See #1 Use SQL).

@shenli
Copy link
Member

shenli commented Aug 24, 2018

@morgo Use SQL API is on the plan. I think it is more convenient. We have a project to expose more cluster internal info to users and tidb admin tools. Will public it on the Github soon.

@morgo
Copy link
Contributor

morgo commented Aug 28, 2018

Related to this, SHOW TABLE STATUS and information_schema both report different numbers for data size statistics (0 versus 100). When a value is not available, it is better to report NULL:

MySQL [world]> show table status like 'country'\G
*************************** 1. row ***************************
           Name: country
         Engine: InnoDB
        Version: 10
     Row_format: Compact
           Rows: 100
 Avg_row_length: 100
    Data_length: 100
Max_data_length: 100
   Index_length: 100
      Data_free: 100
 Auto_increment: 100
    Create_time: 2018-08-13 15:36:54.137 +0000 UTC
    Update_time: 2018-08-28 15:13:23
     Check_time: 2018-08-28 15:13:23
      Collation: utf8_general_ci
       Checksum:
 Create_options:
        Comment:
1 row in set (0.00 sec)

MySQL [world]> SELECT * FROM information_schema.tables WHERE table_name='country'\G
*************************** 1. row ***************************
  TABLE_CATALOG: def
   TABLE_SCHEMA: world
     TABLE_NAME: country
     TABLE_TYPE: BASE TABLE
         ENGINE: InnoDB
        VERSION: 10
     ROW_FORMAT: Compact
     TABLE_ROWS: 239
 AVG_ROW_LENGTH: 0
    DATA_LENGTH: 16384
MAX_DATA_LENGTH: 0
   INDEX_LENGTH: 0
      DATA_FREE: 0
 AUTO_INCREMENT: 0
    CREATE_TIME: 2018-08-13 15:36:54
    UPDATE_TIME: NULL
     CHECK_TIME: NULL
TABLE_COLLATION: utf8_bin
      CHECK_SUM: NULL
 CREATE_OPTIONS:
  TABLE_COMMENT:
1 row in set (0.03 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
Projects
None yet
Development

No branches or pull requests

3 participants