how to print sql query of view in runtime I would like to see view's sql query that is executed in runtime. I found this method in google, hook_views_pre_execute, but I am really beginner in drupal. Where I have to apply this method, when I put this method as project_views_pre_execute in template.php, nothing is shown and I don't know why, is it needed to write it in custom module? 

Any suggestion is greatly appreciated.
The Devel module provides a SQL query log for debugging/performance testing. You can enable this under Configuration > Development > Devel settings (/admin/config/development/devel) and by setting Display query log option.



Once enabled, the bottom of the page will contain all SQL queries executed in page rendering. For your needs, you'll need to look for views_plugin_query_default::execute function calls (the where column) to see the SQL query executed for your view.