Skip to content
JungJungIn edited this page Aug 26, 2025 · 3 revisions

Example Queries

🟢 Extension-Independent Tools (Always Available)

get_server_info

  • "Show PostgreSQL server version and extension status"
image
  • "Check if pg_stat_statements is installed"
image

get_active_connections

  • "Show all active connections"
image
  • "List current sessions with database and user"
image

get_postgresql_config

  • "Show all PostgreSQL configuration parameters"
image
  • "Find all memory-related configuration settings"
image

get_database_list

  • "List all databases and their sizes"
image
  • "Show database list with owner information"
image

get_table_list

  • "List all tables in the ecommerce database"
image
  • "Show table sizes in the public schema"
image

get_table_schema_info

📋 Features: Column types, constraints, indexes, foreign keys, table metadata

⚠️ Required: database_name parameter must be specified

  • "Show detailed schema information for the customers table in ecommerce database"
image
  • "Get column details and constraints for products table in ecommerce database"
image
  • "Analyze table structure with indexes and foreign keys for orders table in sales schema of ecommerce database"
image
  • "Show schema overview for all tables in public schema of inventory database"
image
  • "Get complete table structure including constraints and indexes for employees table in hr_system database"
image
  • "Display column information with data types and constraints for inventory_items table in inventory database"
image

get_database_schema_info

📋 Features: Schema owners, permissions, object counts, sizes, contents

⚠️ Required: database_name parameter must be specified

  • "Show all schemas in ecommerce database with their contents"
image
  • "Get detailed information about sales schema in ecommerce database"
image
  • "Analyze schema structure and permissions for inventory database"
image
  • "Show schema overview with table counts and sizes for hr_system database"
image

get_table_relationships

📋 Features: Foreign key relationships (inbound/outbound), cross-schema dependencies, constraint details

⚠️ Required: database_name parameter must be specified

💡 Usage: Leave table_name empty for database-wide relationship analysis

  • "Show all relationships for customers table in ecommerce database"
image
  • "Analyze foreign key relationships for orders table in sales schema of ecommerce database"
image
  • "Get database-wide relationship overview for ecommerce database"
image
  • "Find all tables that reference products table in ecommerce database"
image
  • "Show cross-schema relationships in inventory database"
image

get_user_list

  • "List all database users and their roles"
image
  • "Show user permissions for a specific database"
image

get_index_usage_stats

  • "Analyze index usage efficiency"
image
  • "Find unused indexes in the current database"
image

get_database_size_info

  • "Show database capacity analysis"
image

get_table_size_info

  • "Show table and index size analysis"
image

get_vacuum_analyze_stats

  • "Show recent VACUUM and ANALYZE operations"
image
  • "List tables needing VACUUM"
image

get_lock_monitoring

  • "Show all current locks and blocked sessions"
image
  • "Show only blocked sessions with granted=false filter"
image
  • "Monitor locks by specific user with username filter"
image
  • "Check exclusive locks with mode filter"
image

get_wal_status

  • "Show WAL status and archiving information"
image
  • "Monitor WAL generation and current LSN position"
image

get_replication_status

  • "Check replication connections and lag status"
image
  • "Monitor replication slots and WAL receiver status"
image

get_database_stats

  • "Show comprehensive database performance metrics"
image
  • "Analyze transaction commit ratios and I/O statistics"
image
  • "Monitor buffer cache hit ratios and temporary file usage"
image

get_bgwriter_stats

  • "Analyze checkpoint performance and timing"
image
  • "Show me checkpoint performance"
image
  • "Show background writer efficiency statistics"
image
  • "Monitor buffer allocation and fsync patterns"
image

get_all_tables_stats

  • "Show comprehensive statistics for all tables"
image
  • "Include system tables with include_system=true parameter"
image
  • "Analyze table access patterns and maintenance needs"
image

get_user_functions_stats

⚠️ Requires: track_functions = pl in postgresql.conf

  • "Analyze user-defined function performance"
image
  • "Show function call counts and execution times"
image
  • "Identify performance bottlenecks in custom functions"
image

get_table_io_stats

💡 Enhanced with: track_io_timing = on for accurate timing

  • "Analyze table I/O performance and buffer hit ratios"
image
  • "Identify tables with poor buffer cache performance"
image
  • "Monitor TOAST table I/O statistics"
image

get_index_io_stats

💡 Enhanced with: track_io_timing = on for accurate timing

  • "Show index I/O performance and buffer efficiency"
image
  • "Identify indexes causing excessive disk I/O"
image
  • "Monitor index cache-friendliness patterns"
image

get_database_conflicts_stats

  • "Check replication conflicts on standby servers"
image
  • "Analyze conflict types and resolution statistics"
image
  • "Monitor standby server query cancellation patterns"
image
  • "Monitor WAL generation and current LSN position"
image

get_replication_status

  • "Check replication connections and lag status"
image
  • "Monitor replication slots and WAL receiver status"
image

🚀 Version-Aware Tools (Auto-Adapting)

get_io_stats (New!)

📈 PG16+: Full pg_stat_io with timing, backend types, and contexts

📊 PG12-15: Basic pg_statio_* fallback with buffer hit ratios

  • "Show comprehensive I/O statistics" (PostgreSQL 16+ provides detailed breakdown)
image
  • "Analyze I/O statistics"
image
  • "Analyze buffer cache efficiency and I/O timing"
image
  • "Monitor I/O patterns by backend type and context"
image

get_bgwriter_stats (Enhanced!)

📈 PG15: Separate checkpointer and bgwriter statistics (unique feature)

📊 PG12-14, 16+: Combined bgwriter stats (includes checkpointer data)

  • "Show background writer and checkpoint performance"
image

get_server_info (Enhanced!)

  • "Show server version and compatibility features"
image
  • "Check server compatibility"
image
  • "Check what MCP tools are available on this PostgreSQL version"
image
  • "Displays feature availability matrix and upgrade recommendations"
image

🟡 Extension-Dependent Tools

get_pg_stat_statements_top_queries (Requires pg_stat_statements)

  • "Show top 10 slowest queries"
image
  • "Analyze slow queries in the inventory database"
image

get_pg_stat_monitor_recent_queries (Optional, uses pg_stat_monitor)

  • "Show recent queries in real time"
image
  • "Monitor query activity for the last 5 minutes"
image