שאילתת SQL עם הסבר ואזהרות

שאילתה שעובדת על אלף שורות יכולה להפיל שרת על מיליון. הפרומפט הזה מבקש לא רק את השאילתה אלא גם הסבר, אזהרות ביצועים, ובעיקר בדיקה מה קורה עם ערכי NULL, שהם הסיבה הנפוצה ביותר לתוצאה שנראית נכונה ואינה. הפרומפט כתוב באנגלית ומוכן להעתקה, מתוך ספריית הפרומפטים של כליקס. מה שבסוגריים מרובעים הוא מה שאתם ממלאים לפני ההדבקה. מודל חזק. לעיצוב שאילתה קיימת אפשר גם בכלי עיצוב ה-SQL של כליקס.

קוד ומפתחים · SQL · מסד נתונים · שאילתה · ביצועים

Write a SQL query.

Database: [PostgreSQL / MySQL / SQLite / SQL Server]
Tables and columns:
[paste the schema, including types and which columns are nullable]

What I need:
[describe the result you want, in plain language]

Approximate size: [rows per table]

Give me:
1. The query, formatted readably.
2. A line-by-line explanation of what each part does.
3. NULL behavior: which columns here can be NULL, and where that changes the result. Be explicit about NOT IN, joins on nullable columns, and aggregates that skip NULLs.
4. Performance: which indexes this query needs, and what happens when the tables are ten times larger.
5. A safe way to check the result before I trust it, for example running it against a subset first.

Rules:
- Use only columns that exist in the schema I gave you. Do not invent columns or tables.
- If the request is ambiguous about duplicates, ties, or time zones, ask instead of choosing silently.
- If this needs to modify data, show me the SELECT that previews exactly which rows will be affected, before the UPDATE or DELETE.

איך להשתמש בזה נכון