Open desssai opened 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.
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 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 it g:db_ui_show_size = 1
by default and provide people with a way to turn it off.
But I will take details toggle into development as I think it is a great idea.
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.
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 for TB
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 the db_ui_show_size
flag and toggling via H
(show_details).
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.