Views - Query Settings

Query settings in views is the catch all for all the odd settings that views has.

Of the odd settings there are six:

  • Disable SQL rewriting
  • Distinct
  • Use Slave Server
  • Query Comment
  • Query Tags

In your view, click the advance field in the right column and query settings will be located under the Other sub group.

 

Click the settings link will bring up the query options overlay.

By default, nothing in query options is checked or configured.

These are the empty / default query options

The first option, Disable SQL rewriting, is not used very often.  This causes Drupal to skip permission checks on content.  Drupal does not do any of the hook query alters.  Use with caution, especially if you plans of world domination that you do not want exposed.

The second option, Distinct, allows your query to use distinct.  Since a view is a glorified SQL statement, sometimes you need a distinct statement.

The third option, Use slave server, is much more than a simple check box.  To use this functionality, you will need a master / slave database architecture.  Some sites are so big, that for performance, they route all their select statements to a slave server.  If you do not have this database set up, leave this unchecked.

The next option is Query Comment.  Query comment is useful for debugging.  This will log a comment so you can determine the source of an sql statement.  This is a great idea that is seldom used, but should be used.

The final option is Query Tags.  Tagging allows you tag a query so Drupal knows what type it is.  When Drupal knows what type it is, it can take action via hooks on it.  Drupal.org's write up on this topic surpasses our attempt, so read about it there.