78c8d4256c
- Moved all documentation to docs/ and updated README with categorized links and new docs/INDEX.md - Added HOW_TO_SWITCH_DATABASE.md and several new analysis/action docs - Introduced db-config.ps1 for centralized DB config; all scripts now use it for easy DB switching - Added db-quick.ps1 for interactive diagnostics and index management - Updated Add-All-Indexes.bat to use db-config.ps1 - Added Fix-ItemValues-Performance.ps1 to create 3 critical indexes on ItemValues, addressing 1.3B row seq scan issue - Updated performance_indexes.sql with new ItemValues indexes and ANALYZE - Updated diagnostics.sql and database_report.txt for improved output and clarity - All scripts and docs now reference the new config and index optimization workflow
58 lines
1.8 KiB
PowerShell
58 lines
1.8 KiB
PowerShell
# Database Configuration
|
|
# Edit this file to change which database commands run against
|
|
|
|
# Database connection settings
|
|
$PSQL_PATH = "C:\Program Files\PostgreSQL\18\bin\psql.exe"
|
|
$DB_USER = "postgres"
|
|
$DB_NAME = "jellyfin_testdata" # ← Change this to switch databases
|
|
$DB_HOST = "192.168.129.248"
|
|
$DB_PORT = "5432"
|
|
|
|
# Export for use in other scripts
|
|
$global:PSQL_PATH = $PSQL_PATH
|
|
$global:DB_USER = $DB_USER
|
|
$global:DB_NAME = $DB_NAME
|
|
$global:DB_HOST = $DB_HOST
|
|
$global:DB_PORT = $DB_PORT
|
|
|
|
# Helper function to run psql commands
|
|
function Invoke-PSQL {
|
|
param(
|
|
[string]$Query,
|
|
[string]$File,
|
|
[string]$OutputFile
|
|
)
|
|
|
|
$baseCmd = "& `"$PSQL_PATH`" -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME"
|
|
|
|
if ($File) {
|
|
$cmd = "$baseCmd -f `"$File`""
|
|
} elseif ($Query) {
|
|
$cmd = "$baseCmd -c `"$Query`""
|
|
} else {
|
|
Write-Error "Must provide either -Query or -File parameter"
|
|
return
|
|
}
|
|
|
|
if ($OutputFile) {
|
|
$cmd += " > `"$OutputFile`""
|
|
}
|
|
|
|
Write-Host "Connecting to: $DB_NAME@$DB_HOST as $DB_USER" -ForegroundColor Cyan
|
|
Invoke-Expression $cmd
|
|
}
|
|
|
|
# Display current configuration
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "Database Configuration Loaded" -ForegroundColor Cyan
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "Database: $DB_NAME" -ForegroundColor Yellow
|
|
Write-Host "User: $DB_USER" -ForegroundColor Yellow
|
|
Write-Host "Host: $DB_HOST" -ForegroundColor Yellow
|
|
Write-Host "Port: $DB_PORT" -ForegroundColor Yellow
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
Write-Host "To change database, edit: db-config.ps1" -ForegroundColor Gray
|
|
Write-Host "Then run: . .\db-config.ps1" -ForegroundColor Gray
|
|
Write-Host ""
|