Add a comment to the top of any query that you are running.

There are a few good reasons to do this:

  • helps keep you focused on the intent of the query
  • can improve readability and reusability of the query
  • helpful when we investigate query logs looking for ways to improve performance

Examples

-- Get a list of 100 student ids
SELECT student_id, local_student_id
FROM students
LIMIT 100
SET application_name TO 'zrankin via pgAdmin, experimenting with queries';
SET statement_timeout TO '1000';

-- You can do it after setting your timeout and application
-- name too.  It can even be multiple lines.
-- Get crazy
SELECT 1;