Skip to content

Add --human-readable flag to db size #108

Closed

Description

@Reiner030

like many functions have like:

root@wordpress-test /var/lib/mysql/wordpress_test # du -h *.ibd
132K    wp_commentmeta.ibd
180K    wp_comments.ibd
112K    wp_links.ibd
15M     wp_options.ibd
2.2G    wp_postmeta.ibd
53M     wp_posts.ibd
996K    wp_termmeta.ibd
12M     wp_term_relationships.ibd
628K    wp_terms.ibd
564K    wp_term_taxonomy.ibd
484K    wp_usermeta.ibd
148K    wp_users.ibd

compared to default Bytes:

$ wp db size --format=csv --tables
Name,Size
wp_commentmeta,"49152 B"
wp_comments,"98304 B"
wp_links,"32768 B"
wp_options,"4751360 B"
wp_postmeta,"2116026368 B"
wp_posts,"46792704 B"
wp_term_relationships,"3178496 B"
wp_term_taxonomy,"507904 B"
wp_termmeta,"950272 B"
wp_terms,"573440 B"
wp_usermeta,"425984 B"
wp_users,"65536 B"

Activity

  1. BhargavBhandari90 commented on Oct 7, 2018

    @BhargavBhandari90

    @Reiner030

    I think you can do this with wp db size --format=csv --tables --size_format=kb

    You can use kb or mb as a size_format

  2. schlessera commented on Oct 24, 2018

    @schlessera
    Member

    @Reiner030 I'm open to adding this. Are you able and willing to provide a corresponding pull request?

    I think the flag should be --human-readable. People can then add this flag to their global WP-CLI config if they want to use it as default.

  3. Reiner030 commented on Nov 17, 2018

    @Reiner030
    Author

    Thanks for the idea from @schlessera with this parameter.
    Sadly I have no much experience with PHP since ~ 3.5 anymore and fight more last years with saltstack/jinja2/python and it's different kinds of problems/bugs to setup servers.

    The call as @BhargavBhandari90 mentioned didn't work nicely (already tested it before opening this issue) because it shows only defined units and not the best human readable one (2,2GB in kB are also not good "human readable").

  4. schlessera commented on Nov 17, 2018

    @schlessera
    Member

    @Reiner030 No worries, I'm sure something will be interested in picking this up.

  5. changed the title [-]Future Request/idea: setup additional size_format to h / human readable[/-] [+]Add `--human-readable` flag to `db size`[/+] on Nov 17, 2018
  6. kingkero commented on Nov 25, 2018

    @kingkero

    Does this depend on the environment? For me, it prints the size in human readable format by default

    $ wp db size --format=csv --tables
    Name,Size
    wp_users,"64 KB"
    wp_usermeta,"48 KB"
    wp_posts,"176 KB"
    wp_comments,"112 KB"
    wp_links,"32 KB"
    wp_options,"1 MB"
    wp_postmeta,"2 MB"
    wp_terms,"48 KB"
    wp_term_taxonomy,"48 KB"
    wp_term_relationships,"32 KB"
    wp_termmeta,"48 KB"
    wp_commentmeta,"48 KB"
    wp_woocommerce_payment_tokenmeta,"48 KB"
    wp_woocommerce_order_itemmeta,"48 KB"
    

    Config:

    $ wp cli info
    PHP binary:	/usr/bin/php7.2
    PHP version:	7.2.12-1+ubuntu16.04.1+deb.sury.org+1
    php.ini used:	/etc/php/7.2/cli/php.ini
    WP-CLI root dir:	phar://wp-cli.phar
    WP-CLI vendor dir:	phar://wp-cli.phar/vendor
    WP_CLI phar path:	/var/www/html/wordpress_DE
    WP-CLI packages dir:	
    WP-CLI global config:	
    WP-CLI project config:	
    WP-CLI version:	1.3.0
    
    $ mysql --version
    mysql  Ver 15.1 Distrib 10.0.36-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
    
  7. schlessera commented on Nov 28, 2018

    @schlessera
    Member

    @kingkero In command-line lingo, "human-readable" means that the numbers are adapted to their nearest biggest unit, to avoid big unwielding numbers when the unit is too small.

    As an example:

         48KB =>   48KB
       1500KB =>  1.5MB
    1750012KB => 1.75GB
    
  8. kingkero commented on Nov 28, 2018

    @kingkero

    @schlessera I understand. I just wanted to add that on my system this is the default behaviour, whereas on Reiner's it seems not to be.

    wp_options,"1 MB" (mine)
    instead of
    wp_options,"4751360 B" (his)

  9. schlessera commented on Nov 28, 2018

    @schlessera
    Member

    @kingkero It cannot be the default, it has not been implemented yet. Are you sure you don't just have a custom --size set up in your global config file?

  10. kingkero commented on Dec 4, 2018

    @kingkero

    @schlessera Don't have a global or local config. I was actually still using WP-CLI v1.3.0 on my local machine. Just updated to v2.0.1, now the output is in Bytes similar to Reiner's original output.

  11. schlessera commented on Dec 17, 2018

    @schlessera
    Member

    Fixed via #124

  12. added this to the 2.0.1 milestone on Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions