How can I tell what the query that is executing when I do an Advanced Search looks like?
In civicrm.settings.php, you can enable:

define('CIVICRM_DEBUG_LOG_QUERY', 1);


Then run the "Advanced Search" and look at the output in files/civicrm/ConfigAndLog/CiviCRM*log*. This will output for several queries; to avoid accumulation of junk data, you should probably disable the CIVICRM_DEBUG_LOG_QUERY after running the query.

There's some more discussion of this and other debugging techniques at http://wiki.civicrm.org/confluence/display/CRMDOC/Debugging+for+developers