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

Publish table size on schema #7444

Merged
merged 14 commits into from
Feb 9, 2021
Merged

Publish table size on schema #7444

merged 14 commits into from
Feb 9, 2021

Conversation

harshit-gangal
Copy link
Member

@harshit-gangal harshit-gangal commented Feb 4, 2021

Description

Adds more information per table in the exposed tablet metrics. They now include FileSize and AllocatedSize.

From the mysql docs:

FILE_SIZE
The apparent size of the file, which represents the maximum size of the file, uncompressed. This column pertains to the InnoDB transparent page compression feature.

ALLOCATED_SIZE
The actual size of the file, which is the amount of space allocated on disk. This column pertains to the InnoDB transparent page compression feature.

We do this by extending the query we already use to keep track of tables on the server so it returns more data.

Impacted Areas in Vitess

Components that this PR will affect:

  • Query Serving

@harshit-gangal harshit-gangal force-pushed the table-size branch 5 times, most recently from 555a136 to df42e86 Compare February 5, 2021 19:01
harshit-gangal and others added 10 commits February 6, 2021 01:02
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
systay and others added 3 commits February 9, 2021 08:32
… difficult table names

Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
@systay systay marked this pull request as ready for review February 9, 2021 08:44
db.AddQueryPattern(baseShowTablesPattern,
&sqltypes.Result{
Fields: mysql.BaseShowTablesFields,
RowsAffected: 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need to spell out default values

Copy link
Contributor

@shlomi-noach shlomi-noach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks legit! I like the per-version queries, and they seem good.

FROM information_schema.tables t
WHERE table_schema = database() AND NOT EXISTS(SELECT * FROM information_schema.innodb_sys_tablespaces i WHERE i.name = concat(t.table_schema,'/',t.table_name))
group by table_name, table_type, unix_timestamp(create_time), table_comment
`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

continue
if !curTables[tableName] {
dropped = append(dropped, tableName)
delete(se.tables, tableName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

tbl, isInTablesMap := se.tables[tableName]
if isInTablesMap && createTime < se.lastChange {
tbl.FileSize = fileSize
tbl.AllocatedSize = allocatedSize
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@systay systay merged commit c3e3e5b into vitessio:master Feb 9, 2021
@systay systay deleted the table-size branch February 9, 2021 11:25
@askdba askdba added this to the v10.0 milestone Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants