A question
regarding Views. If a views is created which is made up of several
unions from several tables; and when a select is placed on the view
with a filter on a particular field, will the view first run the entire
underlying query and then perform a filter, or otherwise. Please
explain. Thanks a lot
Gogula
Annoyingly, the answer seems to be 'it depends'.
The optimiser can do a lot, and if you have a 'union all', then the optimiser can tell that this can be expanded out. But it will use statistics and so on to check to see whether this is ideal or not.
The best thing to advise you is to try it. Get some sample data similar to your real-world situation, and try out some cases. If you find it's not doing what you want, try tweaking the view and query a little and see what you can do. Also try making sure that good indexes are used.
But also bear in mind that you may find that you can get results that are just as good using a user-defined function to pass in filter parameters.
Rob|||
as rob said..try it out..and while doin so , do go thru this article.. http://www.microsoft.com/technet/prodtechnol/sql/2005/impprfiv.mspx
spcially look fro the ..NOEXPAND view hint , may give u some more to try...
No comments:
Post a Comment