Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Display total table relation size in the drawer#257

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
desssai wants to merge4 commits intokristijanhusak:master
base:master
Choose a base branch
Loading
fromdesssai:master

Conversation

@desssai
Copy link

Changes

  • new global boolean flag g:db_ui_show_size.
  • added 'schemes_tables_size_query' for postrgesql and sqlserver schemes.
  • displays total table relation size for each table in the right side of the db_ui drawer. It reserves 8 characters (1 space and 7 characters for size description e.g. min: 0.0B and max: 999.9GB).

The rendering takes into consideration drawer's width and calculates the necessary amount of spaces with repeat() so as to provide the drawer with the label in the format of {table-name}-{whitespace}-{table-size} that would fit with both nerd fonts enabled and different drawer width options. Does not break (throws no errors) if width is less than 8.

@desssaidesssai marked this pull request as draftJuly 5, 2024 11:01
@kristijanhusak
Copy link
Owner

Thanks for the PR! This is a very nice feature.
What do you think of calculating it always (no need fordb_ui_show_size), and putting it inside thedetails as they are shown on the database lines when you pressH ? That way, it would be shown only when requested, and hidden by default.

@desssai
Copy link
Author

Thanks for the PR! This is a very nice feature. What do you think of calculating it always (no need fordb_ui_show_size), and putting it inside thedetails as they are shown on the database lines when you pressH ? That way, it would be shown only when requested, and hidden by default.

I think it is a great idea to provide people with this flag as making queries for not only tables' names but sizes as well makes the delay slightly longer when opening the connection. For example, I tested it on a postgres database with over 11000 tables and the request took approximately 6 seconds for the first time and 4 seconds each call after, while the original took only 2 seconds. There is also pretty little I can do regarding optimization of size calculation as it is my first experience with vimscript. I will do something regarding it with bitwise shifts instead of divisions soon. Yet nothing can be done on the db's part. As it feels less straining on smaller databases, I would like to leave some options for people to turn off querying and calculating table size completely, for those of users who wish to retain their workflow speed.

What about making itg:db_ui_show_size = 1 by default and provide people with a way to turn it off.

@desssai
Copy link
Author

But I will take details toggle into development as I think it is a great idea.

@kristijanhusak
Copy link
Owner

Ok, we can leave it as a togglable variable with the default off in that case. I thought there is no performance hit with it.

@desssaidesssai marked this pull request as ready for reviewJuly 6, 2024 17:26
@desssai
Copy link
Author

  • I reworked the code for size calculations with smaller amount of operations.Cannot do more as it turns out vimscript does not support bit shifts.

  • Added support forTB values (never seen one in a db table myself but who knows someone may need them).

  • Made the size parser universal (if there is no size then I populate the variable to an empty string in the request's return list) so as to make the code more clean and readable while it almost doesn't affect performance.

  • Removed an error when I try to access a size variable that doesn't exist.

  • Changed description to provide details on thedb_ui_show_size flag and toggling viaH (show_details).

@desssai
Copy link
Author

Here's a preview

image

Copy link
Owner

@kristijanhusakkristijanhusak left a comment

Choose a reason for hiding this comment

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

Looks solid, but we just need to address few more things.

else
leticon=self.get_toggle_icon('table',a:tables.items[a:table])
letlabel=repeat('',shiftwidth()*a:level).icon.(!empty(icon) ?"" :"")
ifstrchars(label)+strchars(a:table) >g:db_ui_winwidth-8

Choose a reason for hiding this comment

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

Let's not rely ondb_ui_winwidth variable for this. Table names can be longer than the width.
We should find the longest table name and use that as a reference for padding.
We also need to put the values in parenthesis so it's picked up by highlighter.

This should be enough for the currentelse block:

let longest=max(map(copy(a:tables.list),'strchars(v:val)'))returnprintf('%-'.longest.'s (%s)',a:table,a:tables.items[a:table].size)

Comment on lines +462 to +464
if!g:db_ui_show_size||!self.show_details
let name=a:table
else

Choose a reason for hiding this comment

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

We can just return early here and avoid having anelse block:

Suggested change
if!g:db_ui_show_size||!self.show_details
let name=a:table
else
if!g:db_ui_show_size||!self.show_details
returna:table
endif

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@kristijanhusakkristijanhusakkristijanhusak requested changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@desssai@kristijanhusak

[8]ページ先頭

©2009-2025 Movatter.jp