Coginiti menu Coginiti menu

Conversing with a Duck: Unlocking AI Debugging

Matthew Mullins
February 19, 2024

Rubber duck debugging is a method of debugging code by articulating the problem to someone else, even when that someone can’t give you feedback like a rubber duck. The very process of describing the problem in detail often illuminates the path to a solution. It’s a great practice when you’re not ready to bother a co-worker or you’re working remotely. Coginiti’s AI Assistant is the ultimate rubber duck debugging tool though because it talks back! Below are some sample prompts to help get you started.

  1. Describe the SQL Problem Clearly
    “I have a SQL query that’s supposed to [describe expected outcome], but instead it [describe the incorrect behavior or error]. Here’s the query: [insert SQL query]. Can you help me understand why it’s not working as expected?”
  2. Share Specific Error Messages
    “I’m getting a [specific error message] when I run the following SQL query: [insert SQL query]. What does this error mean, and how can I fix it?”
  3. Explain the Desired Outcome
    “I need to write a SQL query to [describe the task, such as ‘retrieve all records from Table A that…’]. I’ve tried [insert SQL query], but it’s not giving me the results I expect. What am I doing wrong?”
  4. Detail the Database Structure “My database has these tables: [list of tables, with key columns and relationships]. I’m trying to [describe the task or problem]. Here’s my current query: [insert SQL query]. How can I adjust this to work correctly?”
  5. Ask for Optimization Suggestions
    “This SQL query works, but it’s very slow: [insert SQL query]. How can I optimize it for better performance?”
  6. Request Explanation of SQL Concepts or Functions
    “Can you explain how [specific SQL function or concept, like JOINs, window functions, etc.] works? I’m trying to use it in this context: [brief description of context or problem].”
  7. Inquire About Best Practices
    “Is there a best practice for [specific task, like indexing, writing complex queries, etc.] in SQL? Here’s what I’m currently doing: [insert SQL query or description]. How can I improve?”
  8. Share Attempts and Ask for Feedback
    “I’ve attempted to solve this problem with the following query: [insert SQL query]. It’s not working as expected. Can you review it and suggest improvements?”
  9. Query Logical or Syntax Errors
    “I think there’s a logical/syntax error in my SQL query: [insert SQL query]. I’ve looked over it several times but can’t spot the issue. Can you help identify the error?”
  10. Discuss Performance and Scalability
    “I’m concerned about the scalability of my SQL query as the database grows: [insert SQL query]. Do you have any suggestions to ensure it remains efficient?”

When framing your prompt, the more detail you can provide, the better. When enabled, the AI Assistant has the context of your SQL dialect and current schema, but you can enhance this with examples of the data you’re working with or expect to receive. Such comprehensive prompts enable the AI Assistant to provide more accurate and helpful responses, facilitating an effective debugging session.