开发者

table/view/indexed view strategy in SQL Server

We have a "reporting database" (SQL Server 2008) to performing simplified reporting off of an application database and a few other disparate database sources. We started small, so we used simple views to pull the data together in a way that novice SQL writers could make sense of it. We knew this would only work while the amount of data was small...

... well, it开发者_C百科's growing quickly and we need to determine a better way. Most of the data in the past does not change, but we need real-time reports. Conceptually, I'd like to do something like load these views into tables every night and then combine that data with a view of today's data - perhaps with a new view of a union between the table and a view of today?

I'm relatively new to SQL Server so I'm not sure of the gotchas or the considerations I need to have in this design. Any input or suggestions are welcome!

Thanks much!


If the schema of the application is identical with the schema for reporting then you can use:

  • database mirroring with snapshots
  • log shipping
  • AlwaysON Readable Secondaries (requires SQL 11)
  • SAN replication (I just mention it, it costs an arm and a leg in hardware)

If your schema in the reporting server can have some divergences from the application schema (eg. more indexes) then you can consider transactional replication.

If your schema differs significantly (like an OLAP reporting style schema) then the way to go is a proper ETL process. You can achieve near-real-time ETL.


The concept of a reporting database and nightly updates suggests that an OLAP-style system may work as a solution for you. In the SQL Server world this technology is called SSAS (SQL Server Analysis Services.)


Take a look at Indexed Views: http://msdn.microsoft.com/en-us/library/dd171921(v=sql.100).aspx

From the MSDN page:

Using indexes to improve query performance is not a new concept; however, indexed views provide additional performance benefits that cannot be achieved using standard indexes. Indexed views can increase query performance in the following ways:

  • Aggregations can be precomputed and stored in the index to minimize expensive computations during query execution.
  • Tables can be prejoined and the resulting data set stored.
  • Combinations of joins or aggregations can be stored.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜