Complete setup guide to get SmartSQL monitoring and optimizing your PostgreSQL databases in minutes.
Before setting up SmartSQL, ensure your PostgreSQL environment meets these requirements:
PostgreSQL 14 or higher
Database must be publicly accessible
Configure your PostgreSQL instance to enable query statistics collection:
Add the following configuration to your
postgresql.conf file:
shared_preload_libraries = 'pg_stat_statements'
Add these additional settings to track all queries:
pg_stat_statements.track = all compute_query_id = on
Restart your PostgreSQL service to apply the configuration changes:
sudo systemctl restart postgresql
Create a dedicated read-only user for SmartSQL to ensure secure database access:
Connect to your PostgreSQL database and create a new user:
CREATE USER smartsql_monitor WITH PASSWORD 'your_secure_password_here';
Grant the necessary read permissions for monitoring. Run these commands for each schema you want to monitor:
-- Grant connection to database GRANT CONNECT ON DATABASE your_database_name TO smartsql_monitor; -- Grant usage on schema (repeat for each schema you want to monitor) GRANT USAGE ON SCHEMA public TO smartsql_monitor; GRANT USAGE ON SCHEMA your_other_schema TO smartsql_monitor; -- Grant select on all tables in schema (repeat for each schema) GRANT SELECT ON ALL TABLES IN SCHEMA public TO smartsql_monitor; GRANT SELECT ON ALL TABLES IN SCHEMA your_other_schema TO smartsql_monitor; -- Grant select on future tables (repeat for each schema) ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO smartsql_monitor; ALTER DEFAULT PRIVILEGES IN SCHEMA your_other_schema GRANT SELECT ON TABLES TO smartsql_monitor; -- Grant access to statistics views GRANT SELECT ON pg_stat_statements TO smartsql_monitor; GRANT SELECT ON pg_stat_user_tables TO smartsql_monitor; GRANT SELECT ON pg_stat_user_indexes TO smartsql_monitor;
Create the pg_stat_statements extension in your database:
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
Once your database is configured, connect it to SmartSQL:
In your SmartSQL dashboard, add a new database configuration using a PostgreSQL connection string:
postgresql://smartsql_monitor:your_secure_password_here@your-database-host.com:5432/your_database_name
Replace the following values in the connection string:
Confirm that SmartSQL is successfully monitoring your database:
Check that your database shows as "Connected" in the SmartSQL dashboard.
Verify that query statistics are being collected by running some test queries and checking the dashboard.
Configure notification preferences to receive alerts about optimization opportunities.
SmartSQL is now monitoring your PostgreSQL database and will begin identifying optimization opportunities. You'll receive notifications when performance improvements are available.
Join WaitlistSmartSQL analyzes your database queries and provides two main types of optimizations. Important: No optimizations are automatically applied to your database. You maintain full control over which optimizations to implement.
Our AI analyzes your SQL queries and suggests more efficient alternatives that produce the same results with better performance. These optimizations include:
SELECT * FROM orders WHERE user_id IN ( SELECT id FROM users WHERE active = true );
SELECT o.* FROM orders o INNER JOIN users u ON o.user_id = u.id WHERE u.active = true;
SmartSQL identifies missing indexes that could significantly improve query performance. Our recommendations are based on:
CREATE INDEX idx_orders_user_id_created_at ON orders(user_id, created_at) WHERE status = 'active';
This partial index optimizes queries filtering by user_id and date range for active orders.
SmartSQL runs EXPLAIN ANALYZE on your database
to empirically determine if each optimization actually
improves performance compared to the original query. You'll
see concrete metrics showing:
If you encounter any issues during setup, our support team is here to help: