kristijanhusak / vim-dadbod-ui

Simple UI for https://github.com/tpope/vim-dadbod
MIT License
1.54k stars 94 forks source link

Display total table relation size in the drawer #257

Open desssai opened 4 months ago

desssai commented 4 months ago

Changes

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.

kristijanhusak commented 4 months ago

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

desssai commented 4 months ago

Thanks for the PR! This is a very nice feature. What do you think of calculating it always (no need for db_ui_show_size), and putting it inside the details as they are shown on the database lines when you press H ? 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 it g:db_ui_show_size = 1 by default and provide people with a way to turn it off.

desssai commented 4 months ago

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

kristijanhusak commented 4 months ago

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.

desssai commented 4 months ago
desssai commented 4 months ago

Here's a preview

image