diff --git a/plugins/views_plugin_query_default.inc b/plugins/views_plugin_query_default.inc
index 5a46bc8..08d1978 100644
--- a/plugins/views_plugin_query_default.inc
+++ b/plugins/views_plugin_query_default.inc
@@ -80,6 +80,11 @@ class views_plugin_query_default extends views_plugin_query {
    var $pager = NULL;
 
   /**
+   * A query comment.
+   */
+  var $query_comment = '';
+
+  /**
    * Constructor; Create the basic query object and fill with default values.
    */
   function init($base_table = 'node', $base_field = 'nid', $options) {
@@ -139,6 +144,15 @@ class views_plugin_query_default extends views_plugin_query {
   }
 
   /**
+   * Set the query comment.
+   */
+  function set_query_comment($value = '') {
+    if (!empty($value)) {
+      $this->query_comment = $value;
+    }
+  }
+
+  /**
    * Set what field the query will count() on for paging.
    */
   function set_count_field($table, $field, $alias = NULL) {
@@ -176,6 +190,10 @@ class views_plugin_query_default extends views_plugin_query {
       'default' => FALSE,
       'bool' => TRUE,
     );
+    $options['query_comment'] = array(
+      'default' => '',
+      'bool' => FALSE,
+    );
     $options['field_language'] = array(
       'default' => '***CURRENT_LANGUAGE***',
     );
@@ -206,6 +224,12 @@ class views_plugin_query_default extends views_plugin_query {
       '#description' => t('This will make the query attempt to connect to a slave server if available.  If no slave server is defined or available, it will fall back to the default server.'),
       '#default_value' => !empty($this->options['slave']),
     );
+    $form['query_comment'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Query Comment'),
+      '#description' => t('If set, this comment will be embedded in the query and passed to the SQL server. This can be helpful for logging or debugging.'),
+      '#default_value' => $this->options['query_comment'],
+    );
 
     $entities = entity_get_info();
     $entity_tables = array();
@@ -1207,6 +1231,11 @@ class views_plugin_query_default extends views_plugin_query {
       $query->condition($condition);
     }
 
+    // Add a query comment.
+    if (!empty($this->options['query_comment'])) {
+      $query->comment($this->options['query_comment']);
+    }
+
     // Add all query substitutions as metadata.
     $query->addMetaData('views_substitutions', module_invoke_all('views_query_substitutions', $this));
 
