mirror of
https://github.com/edu4rdshl/based.fish.git
synced 2026-07-17 23:24:46 +00:00
(feat): add based maintenance to perform analyze + vacuum
It will help if your database has been runing for a very long time
This commit is contained in:
parent
88cbb3cc9b
commit
768bce39ec
2 changed files with 39 additions and 6 deletions
25
functions/__based_maintenance.fish
Normal file
25
functions/__based_maintenance.fish
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
function __based_maintenance
|
||||||
|
set -l db ~/.local/share/fish/based/based.db
|
||||||
|
if not test -f $db
|
||||||
|
echo "Database not found. Run 'based init' first."
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "Performing database maintenance..."
|
||||||
|
|
||||||
|
# Get database size before
|
||||||
|
set -l size_before (du -h $db | cut -f1)
|
||||||
|
|
||||||
|
# Vacuum the database
|
||||||
|
sqlite3 $db "VACUUM;"
|
||||||
|
|
||||||
|
# Update statistics
|
||||||
|
sqlite3 $db "ANALYZE;"
|
||||||
|
|
||||||
|
# Get database size after
|
||||||
|
set -l size_after (du -h $db | cut -f1)
|
||||||
|
|
||||||
|
echo "Database maintenance completed."
|
||||||
|
echo "Size before: $size_before"
|
||||||
|
echo "Size after: $size_after"
|
||||||
|
end
|
||||||
|
|
@ -8,14 +8,22 @@ function based
|
||||||
__based_stats
|
__based_stats
|
||||||
case reset
|
case reset
|
||||||
__based_reset_state
|
__based_reset_state
|
||||||
|
case maintenance vacuum
|
||||||
|
__based_maintenance
|
||||||
case help '*'
|
case help '*'
|
||||||
echo "Usage: based init|import|stats|reset|help"
|
echo "Usage: based init|import|stats|reset|maintenance|help"
|
||||||
echo "Commands:"
|
echo "Commands:"
|
||||||
echo " init - Initialize the Based database"
|
echo " init - Initialize the Based database"
|
||||||
echo " import - Import fish history into Based"
|
echo " import - Import fish history into Based"
|
||||||
echo " stats - Show Based statistics"
|
echo " stats - Show Based statistics"
|
||||||
echo " reset - Reset Based state (clears variables)"
|
echo " reset - Reset Based state (clears variables)"
|
||||||
|
echo " maintenance - Perform database maintenance (vacuum & analyze)"
|
||||||
echo " help - Show this help message"
|
echo " help - Show this help message"
|
||||||
|
echo ""
|
||||||
|
echo "Configuration variables:"
|
||||||
|
echo " BASED_NO_CONFIRMATION - Skip confirmation prompts"
|
||||||
|
echo " BASED_NO_FUZZY - Disable fuzzy matching"
|
||||||
|
echo " BASED_EXCLUDED_PATHS - Paths to exclude from history (glob patterns)"
|
||||||
case '*'
|
case '*'
|
||||||
echo "Unknown command: $argv[1]"
|
echo "Unknown command: $argv[1]"
|
||||||
echo "Use 'based help' for usage information."
|
echo "Use 'based help' for usage information."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue