Hi Ronak -
It's the latter - the original query is "wrapped" in additional SQL (WHERE, GROUP BY, etc.) statements based on what you're doing with the fields from your data source in the viz itself.
A slightly deeper look at this can be found here: http://tableaulove.tumblr.com/post/20781994395/tableau-performance-multiple-tables-or-custom-sql
Moral of the story - Test it both ways and see what works best for you.
Hope this helps!