PromptBase
PromptBase SelectGet Select
Close icon
General
Home
Marketplace
Create
Hire
Login
Chat
Sell
Explore

Prompt Details

Model
Chat - (gpt-5.6)
Token size
713
Example input
[SCHEMA]: orders ( id bigint PRIMARY KEY, created_at timestamp without time zone NOT NULL ) [QUERY]: SELECT COUNT(*) AS orders_count FROM orders WHERE DATE(created_at) = DATE '2026-09-15'; [ERROR_OR_ISSUE]: The query is slow on a large orders table even though an index exists on created_at. [EXPECTED_RESULT]: Return the number of orders created on September 15, 2026, while allowing PostgreSQL to use the existing index on created_at efficiently. [CONTEXT]: PostgreSQL 15. The orders table contains several million rows and already has a B-tree index on created_at.
Example output
### 1. Diagnosis The query is valid, but applying the DATE() function to `created_at` can prevent PostgreSQL from efficiently using a normal B-tree index on that column. On a large table, this may cause PostgreSQL to scan far more rows than necessary. ### 2. Corrected SQL ```sql SELECT COUNT(*) AS orders_count FROM orders WHERE created_at >= TIMESTAMP '2026-09-15 00:00:00' AND created_at < TIMESTAMP '2026-09-16 00:00:00';
GPT

Postgresql Query Doctor

Add to Cart
PromptBase Select
Get this prompt + 9 more with Select$14 your first month, then $19/mo$14 first month, then $19/mo
View Select
Instant accessInstant access
Usage rightsCommercial use
Money-back guaranteeMoney‑back
By purchasing this prompt, you agree to our terms of service
GPT-5.6
Tested icon
Guide icon
4 examples icon
Free credits icon
Fix, optimize, and explain PostgreSQL queries. This prompt analyzes SQL errors, JOINs, filters, performance issues, and indexing opportunities. It returns a corrected query, explains what was wrong, highlights risks, and suggests improvements without inventing tables or columns. Ideal for developers, analysts, and database administrators.
...more
Added over 1 month ago
Report
Browse Marketplace