You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'SELECT SUM(data_length + index_length) FROM information_schema.TABLES where table_schema = %s GROUP BY table_schema;',
DB_NAME
)
);
I don't believe there is a similar way to get the size of a SQLite database, and the preferred method is to just get the size of the .sqlite file itself.
I wonder what the general solution should be to detect SQLite use in wp-cli commands so any new code is consistent across various projects? It could be good to have a helper function to give the current database type and maybe also the location of the .sqlite file if it is SQLite.
Or is this just better left until WordPress adopts SQLite officially and adds a built in method for wbdp?
Or is this just better left until WordPress adopts SQLite officially and adds a built in method for wbdp?
I don't think it's likely that WordPress core will add exactly what we need. wp db size is something we invented for our own use.
I wonder what the general solution should be to detect SQLite use in wp-cli commands so any new code is consistent across various projects? It could be good to have a helper function to give the current database type and maybe also the location of the .sqlite file if it is SQLite.
I'm open to it! I'd suggest we fix SQLite support for a couple/few commands first, and then figure out what abstraction they need.
I don't believe there is a similar way to get the size of a SQLite database, and the preferred method is to just get the size of the .sqlite file itself.
Worth noting: wp db size also supports a --tables argument:
$ wp db size --tables
+-----------------------+-----------+
| Name | Size |
+-----------------------+-----------+
| wp_commentmeta | 49152 B |
| wp_comments | 98304 B |
| wp_links | 32768 B |
| wp_options | 1163264 B |
| wp_postmeta | 49152 B |
| wp_posts | 81920 B |
| wp_term_relationships | 32768 B |
| wp_term_taxonomy | 49152 B |
| wp_termmeta | 49152 B |
| wp_terms | 49152 B |
| wp_usermeta | 49152 B |
| wp_users | 65536 B |
+-----------------------+-----------+
Here's what I see with SQLite:
$ wp db size
+--------+------------------+
| Name | Size |
+--------+------------------+
| wplite | WP_COMMENTMETA B |
+--------+------------------+
$ wp db size --tables
+-------------------------+------------------+
| Name | Size |
+-------------------------+------------------+
| _mysql_data_types_cache | WP_COMMENTMETA B |
| sqlite_sequence | WP_COMMENTMETA B |
| wp_commentmeta | WP_COMMENTMETA B |
| wp_comments | WP_COMMENTMETA B |
| wp_links | WP_COMMENTMETA B |
| wp_options | WP_COMMENTMETA B |
| wp_postmeta | WP_COMMENTMETA B |
| wp_posts | WP_COMMENTMETA B |
| wp_term_relationships | WP_COMMENTMETA B |
| wp_term_taxonomy | WP_COMMENTMETA B |
| wp_termmeta | WP_COMMENTMETA B |
| wp_terms | WP_COMMENTMETA B |
| wp_usermeta | WP_COMMENTMETA B |
| wp_users | WP_COMMENTMETA B |
+-------------------------+------------------+
Activity
danielbachhuber commentedon Oct 18, 2023
I don't think it's likely that WordPress core will add exactly what we need.
wp db sizeis something we invented for our own use.I'm open to it! I'd suggest we fix SQLite support for a couple/few commands first, and then figure out what abstraction they need.
Worth noting:
wp db sizealso supports a--tablesargument:Here's what I see with SQLite:
wp dbcommands #234