Move 150+ scripts from root and scripts/ into client/project directories: - clients/dataforth/scripts/ (110 files: AD2, sync, SSH, DB, DOS scripts) - clients/bg-builders/scripts/ (14 files: Lesley mgmt, Exchange, termination) - clients/internal-infrastructure/scripts/ (10 files: GDAP, Gitea, backups) - projects/msp-tools/scripts/ (9 files: CIPP, MSP onboarding, Datto) - projects/gururmm-agent/scripts/ (3 files: API test, JWT, record counts) - clients/glaztech/scripts/ (1 file: CentraStage removal) Also reorganized: - VPN scripts → infrastructure/vpn-configs/ - Retrieved API/JS files → api/ - Forum posts → projects/community-forum/forum-posts/ - SSH docs → clients/internal-infrastructure/docs/ - NWTOC/CTONW docs → projects/wrightstown-smarthome/docs/ - ACG website files → projects/internal/acg-website-2025/ - Dataforth docs → clients/dataforth/docs/ - schema-retrieved.sql → docs/database/ Deleted 24 tmp_*.ps1 one-off debug scripts (preserved in git history). Root reduced from 220+ files to 62 items (docs + directories only). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
70 lines
3.2 KiB
PowerShell
70 lines
3.2 KiB
PowerShell
# Check database performance and optimization status
|
|
$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
|
|
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password)
|
|
|
|
Write-Host "[OK] Mounting AD2 C$ share..." -ForegroundColor Green
|
|
New-PSDrive -Name AD2 -PSProvider FileSystem -Root "\\192.168.0.6\C$" -Credential $cred -ErrorAction Stop | Out-Null
|
|
|
|
# Get server.js content to check timeout settings
|
|
Write-Host "[OK] Checking server.js configuration..." -ForegroundColor Green
|
|
$serverJs = Get-Content "AD2:\Shares\testdatadb\server.js" -Raw
|
|
|
|
if ($serverJs -match "timeout") {
|
|
Write-Host "[FOUND] Timeout configuration in server.js" -ForegroundColor Yellow
|
|
$serverJs -split "`n" | Where-Object { $_ -match "timeout" } | ForEach-Object {
|
|
Write-Host " $_" -ForegroundColor Cyan
|
|
}
|
|
} else {
|
|
Write-Host "[INFO] No explicit timeout configuration found" -ForegroundColor Cyan
|
|
}
|
|
|
|
# Check if better-sqlite3 is configured for performance
|
|
if ($serverJs -match "pragma") {
|
|
Write-Host "[FOUND] SQLite PRAGMA settings:" -ForegroundColor Green
|
|
$serverJs -split "`n" | Where-Object { $_ -match "pragma" } | ForEach-Object {
|
|
Write-Host " $_" -ForegroundColor Cyan
|
|
}
|
|
} else {
|
|
Write-Host "[WARNING] No PRAGMA performance settings found in server.js" -ForegroundColor Yellow
|
|
Write-Host " Consider adding: PRAGMA journal_mode = WAL, PRAGMA synchronous = NORMAL" -ForegroundColor Yellow
|
|
}
|
|
|
|
# Check routes/api.js for query optimization
|
|
Write-Host "`n[OK] Checking API routes..." -ForegroundColor Green
|
|
if (Test-Path "AD2:\Shares\testdatadb\routes\api.js") {
|
|
$apiJs = Get-Content "AD2:\Shares\testdatadb\routes\api.js" -Raw
|
|
|
|
# Check for LIMIT clauses
|
|
$hasLimit = $apiJs -match "LIMIT"
|
|
if ($hasLimit) {
|
|
Write-Host "[OK] Found LIMIT clauses in queries (good for performance)" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "[WARNING] No LIMIT clauses found - queries may return too many results" -ForegroundColor Yellow
|
|
}
|
|
|
|
# Check for index usage
|
|
$hasIndexHints = $apiJs -match "INDEXED BY" -or $apiJs -match "USE INDEX"
|
|
if ($hasIndexHints) {
|
|
Write-Host "[OK] Found index hints in queries" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "[INFO] No explicit index hints (relying on automatic optimization)" -ForegroundColor Cyan
|
|
}
|
|
}
|
|
|
|
# Check database file fragmentation
|
|
Write-Host "`n[OK] Checking database file stats..." -ForegroundColor Green
|
|
$dbFile = Get-Item "AD2:\Shares\testdatadb\database\testdata.db"
|
|
Write-Host " File size: $([math]::Round($dbFile.Length/1MB,2)) MB" -ForegroundColor Cyan
|
|
Write-Host " Last accessed: $($dbFile.LastAccessTime)" -ForegroundColor Cyan
|
|
Write-Host " Last modified: $($dbFile.LastWriteTime)" -ForegroundColor Cyan
|
|
|
|
# Suggestion to run VACUUM
|
|
$daysSinceModified = (Get-Date) - $dbFile.LastWriteTime
|
|
if ($daysSinceModified.TotalDays -gt 7) {
|
|
Write-Host "`n[SUGGESTION] Database hasn't been modified in $([math]::Round($daysSinceModified.TotalDays,1)) days" -ForegroundColor Yellow
|
|
Write-Host " Consider running VACUUM to optimize database file" -ForegroundColor Yellow
|
|
}
|
|
|
|
Remove-PSDrive -Name AD2 -ErrorAction SilentlyContinue
|
|
Write-Host "`n[OK] Done" -ForegroundColor Green
|