Deciding whether or
not to use a select query versus
a table view when extracting data from a database can be a bit of a perplexed decision,
especially since, essentially… both queries and views can produce the same
result-set. Here are a few good ‘rules of thumb’ when choosing how to execute
your next data result:
·
For those of you who value performance above all
else, considers using Indexed views. They can significantly improve data flow.
·
Due to the fact that table views are dependent
on table data, if a corresponding table is dropped or modified in such a way
that the view can no longer access the data, (as in the case of a column name
change etc.), the view will become unusable, so if unsure as to whether or not data
restraints on a table will change, a query should be used. When In doubt…leave
it out!
·
If your query will be disbursed to a general audience,
then using a simple select statement will do the trick. However, If data abstraction
and permissions need to be set to control the audience of your dataset, a view
of the data may be more applicable.
·
Whenever the data being extracted will require
client interaction, a query may be more sufficient, as views are read-only.
·
If amendments or changes are likely to occur
within your query, a view may be more suitable rather than a table query, as code
reusability and the dynamic nature of views are one of their key attributes.
Instead of making changes to numerous queries, a single view can be changed
instead.
No comments:
Post a Comment