diff --git includes/plugins.inc includes/plugins.inc
index b30145b..e100418 100644
--- includes/plugins.inc
+++ includes/plugins.inc
@@ -245,7 +245,8 @@ function views_views_plugins() {
       'views_query' => array(
         'title' => t('SQL Query'),
         'help' => t('Query will be generated and run using the Drupal database API.'),
-        'handler' => 'views_plugin_query_default'
+        'handler' => 'views_plugin_query_default',
+        'uses options' => TRUE,
       ),
     ),
     'cache' => array(
diff --git plugins/views_plugin_display.inc plugins/views_plugin_display.inc
index 81d43a5..f095c5a 100644
--- plugins/views_plugin_display.inc
+++ plugins/views_plugin_display.inc
@@ -39,7 +39,7 @@ class views_plugin_display extends views_plugin {
     if ($this->is_default_display() && isset($options['defaults'])) {
       unset($options['defaults']);
     }
-
+    
     $this->unpack_options($this->options, $options);
 
     // Translate changed settings:
@@ -250,6 +250,7 @@ class views_plugin_display extends views_plugin {
       'cache' => array('cache'),
       'title' => array('title'),
       'use_ajax' => array('use_ajax'),
+      'query' => array('query'),
       'items_per_page' => array('items_per_page', 'offset', 'use_pager', 'pager_element'),
       'pager' => array('pager'),
       'use_more' => array('use_more', 'use_more_always', 'use_more_text'),
@@ -314,6 +315,7 @@ class views_plugin_display extends views_plugin {
         'default' => array(
           'access' => TRUE,
           'cache' => TRUE,
+          'query' => TRUE,
           'title' => TRUE,
 
           'use_ajax' => TRUE,
@@ -404,6 +406,12 @@ class views_plugin_display extends views_plugin {
           'type' => array('default' => 'none', 'export' => 'export_plugin'),
          ),
       ),
+      'query' => array(
+        'contains' => array(
+          'type' => array('default' => 'default', 'export' => 'export_plugin'),
+          'options' => array('default' => array(), 'export' => FALSE),
+         ),
+      ),
       // Note that exposed_form plugin has options in a separate array,
       // while access and cache do not. access and cache are legacy and
       // that pattern should not be repeated, but it is left as is to
@@ -423,6 +431,7 @@ class views_plugin_display extends views_plugin {
          ),
       ),
 
+
       // Note that the styles have their options completely independent.
       // Like access and cache above, this is a legacy pattern and
       // should not be repeated.
@@ -500,7 +509,6 @@ class views_plugin_display extends views_plugin {
 
   /**
    * Check to see if the display has a 'path' field.
-   *
    * This is a pure function and not just a setting on the definition
    * because some displays (such as a panel pane) may have a path based
    * upon configuration.
@@ -622,7 +630,7 @@ class views_plugin_display extends views_plugin {
 
           // access & cache store their options as siblings with the
           // type; all others use an 'options' array.
-          if ($type != 'access' && $type != 'cache') {
+          if ($type != 'access' && $type != 'cache' && $type != 'query') {
             $options = $options['options'];
           }
       }
@@ -911,6 +919,17 @@ class views_plugin_display extends views_plugin {
       );
     }
 
+    $options['query'] = array(
+      'category' => 'advanced',
+      'title' => t('Query settings'),
+      'value' => t('Settings'),
+      'desc' => t('Allow to set some advanced settings for the query plugin'),
+    );
+
+    if (!empty($this->view->query->definition['uses options'])) {
+      $options['query']['links']['query_options'] = t('Change settings for this access type.');
+    }
+
     $access_plugin = $this->get_plugin('access');
     if (!$access_plugin) {
       // default to the no access control plugin.
@@ -1196,6 +1215,48 @@ class views_plugin_display extends views_plugin {
           $plugin->options_form($form['cache_options'], $form_state);
         }
         break;
+      case 'cache':
+        $form['#title'] .= t('Query');
+        $form['query'] = array(
+          '#prefix' => '<div class="clear-block">',
+          '#suffix' => '</div>',
+          '#tree' => TRUE,
+        );
+
+        $cache = $this->get_option('query');
+        $form['query']['type'] =  array(
+          '#type' => 'radios',
+          '#options' => views_fetch_plugin_names('query'),
+          '#default_value' => $cache['type'],
+        );
+
+        $query_plugin = views_fetch_plugin_data('query', $cache['type']);
+        if (!empty($query_plugin['uses options'])) {
+          $form['markup'] = array(
+            '#prefix' => '<div class="form-item description">',
+            '#suffix' => '</div>',
+            '#value' => t('You may also adjust the !settings for the currently selected query mechanism by clicking on the icon.', array('!settings' => $this->option_link(t('settings'), 'query_options'))),
+          );
+        }
+        break;
+      case 'query_options':
+        $this->view->init_query();
+        $form['#title'] .= t('Query options');
+        if ($this->view->query) {
+          $form['#help_topic'] = $this->query->definition['help topic'];
+          $form['#help_module'] = $this->query->definition['module'];
+
+          $form['query_options'] = array(
+            '#tree' => TRUE,
+          );
+          // TODO allow to select the query plugin: every child of views_query_default.
+          //$form['query_options']['type'] = array(
+            //'#type' => 'value',
+            //'#value' => $cache['type'],
+          //);
+          $this->view->query->options_form($form['query_options'], $form_state);
+        }
+        break;
       case 'style_plugin':
         $form['#title'] .= t('How should this view be styled');
         $form['#help_topic'] = 'style';
@@ -1651,6 +1712,11 @@ class views_plugin_display extends views_plugin {
           $plugin->options_validate($form['access_options'], $form_state);
         }
         break;
+      case 'query_options':
+        if ($this->view->query) {
+          $this->view->query->options_validate($form['query_options'], $form_state);
+        }
+        break;
       case 'cache_options':
         $plugin = $this->get_plugin('cache');
         if ($plugin) {
@@ -1735,6 +1801,29 @@ class views_plugin_display extends views_plugin {
           $this->set_option('cache', $form_state['values'][$section]);
         }
         break;
+
+      case 'query':
+        $query = $this->get_option('query');
+        if ($query['type'] != $form_state['values']['query']['type']) {
+          $plugin = views_get_plugin('query', $form_state['values']['query']['type']);
+          if ($plugin) {
+            $query = array('type' => $form_state['values']['query']['type']);
+            $this->set_option('query', $query);
+            if (!empty($plugin->definition['uses options'])) {
+              views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('query_options'));
+            }
+          }
+        }
+
+        break;
+      case 'query_options':
+        $plugin = views_get_plugin('query', $form_state['values'][$section]['type']);
+        if ($plugin) {
+          $plugin->options_submit($form['query_options'], $form_state);
+          $this->set_option('query', $form_state['values'][$section]);
+        }
+        break;
+
       case 'title':
       case 'link_display':
         $this->set_option($section, $form_state['values'][$section]);
@@ -2292,7 +2381,7 @@ class views_plugin_display extends views_plugin {
 
       $output .= $indent . $new_prefix . "['$option'] = '$value';\n";
 
-      if ($plugin_type != 'access' && $plugin_type!= 'cache') {
+      if ($plugin_type != 'access' && $plugin_type!= 'cache' && $plugin_type != 'query') {
         $new_prefix .= "['options']";
       }
 
diff --git plugins/views_plugin_query.inc plugins/views_plugin_query.inc
index e4c4b90..ec13742 100644
--- plugins/views_plugin_query.inc
+++ plugins/views_plugin_query.inc
@@ -63,6 +63,15 @@ class views_plugin_query extends views_plugin {
   function get_aggregation_info() { }
 
   /**
+   * Add settings for the ui.
+   */
+  function options_form(&$form, &$form_state) { }
+
+  function options_validate(&$form, &$form_state) { }
+
+  function options_submit(&$form, &$form_state) { }
+
+  /**
    * Set a LIMIT on the query, specifying a maximum number of results.
    */
   function set_limit($limit) {
diff --git plugins/views_plugin_query_default.inc plugins/views_plugin_query_default.inc
index e1c9483..32f5efb 100644
--- plugins/views_plugin_query_default.inc
+++ plugins/views_plugin_query_default.inc
@@ -149,6 +149,47 @@ class views_plugin_query_default extends views_plugin_query{
     $this->header = $header;
   }
 
+
+  function summary_title() {
+    return t('Settings');
+  }
+
+  /**
+   * Intelligently get an option either from this display or from the
+   * default display, if directed to do so.
+   */
+  function get_option($option) {
+    if ($this->is_defaulted($option)) {
+      return $this->default_display->get_option($option);
+    }
+
+    if (array_key_exists($option, $this->options)) {
+      return $this->options[$option];
+    }
+  }
+
+  function option_definition() {
+    $options = parent::option_definition();
+    $options['disable_node_access'] = array('default' => FALSE, 'translatable' => FALSE);
+
+    return $options;
+  }
+  /**
+   * Add settings for the ui.
+   */
+  function options_form(&$form, &$form_state) {
+    drupal_set_message(t('You have to know what you are doing here, be sure that you really want to disable node access'), 'warning');
+    $form['disable_node_access'] = array(
+      '#title' => t('Disable node access'),
+      '#description' => t('Disable node access for this query, it also disables any kind of db_rewrite_sql'),
+      '#type' => 'checkbox',
+      '#default_value' => $this->options['disable_node_access'],
+    );
+  }
+
+  function options_submit(&$form, &$form_state) {
+  }
+
   // ----------------------------------------------------------------
   // Table/join adding
 
