Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tips for optimizing a read-only sql database

I have a mid-sized SQL Server 2008 database that has actuarial data in it. All of the use cases for it are read-only queries. Are there any special optimizations I should consider given this scenario? Or should I just stick with the normal rules for optimizing a database?

like image 735
Jason Avatar asked Dec 09 '09 20:12

Jason


People also ask

How do you optimize a read only data?

For a read-only table, consider altering the indexes to use a fill factor of 100%. This will increase the amount of data on each data page. More data per page, fewer pages to read, less I/O, thus better performance. I like this option because it improves performance without code changes or table changes.

How do I shrink a read only SQL Server database?

Use SQL Server Management StudioExpand Databases, and then right-click the database that you want to shrink. Point to Tasks, point to Shrink, and then select Database.


2 Answers

In database:

  1. Denormalize it.
  2. Use more indexes where needed.
  3. Aggregate some data if you need it in your reports.

In program:

  1. Use READ UNCOMMITTED isolation level.
  2. Use autocommits to escape long-run transactions.
like image 112
Andrew Lygin Avatar answered Oct 08 '22 03:10

Andrew Lygin


One strategy is to add a readonly filegroup to your DB, and put your readonly tables there. A readonly filegroup allows SQL Server to make a number of optimizations, including things like eliminating all locks.

In addition to standard DB optimization:

  1. Make sure all tables and indexes have zero fragmentation
  2. Consider adding indexes that you may have otherwise avoided due to excessive update costs
like image 33
RickNZ Avatar answered Oct 08 '22 04:10

RickNZ