Initial brainstorming helped us identify 2 possible approaches to replacing the Berkeley DB: a. Use SQLCE for data caching b. Use SQL Express for data caching (also applies to SQL Standard and Enterprise skew) In both the above choices the key to arriving at the target solution is buffer pool management, SQL Server internally tries to reduce the disk I/O by storing data pages into the buffer pool.
SQL CE seemed a good choice initially because its an inproc DB an this inherent nature could improve query performance however we concluded that it was not the right fit since:•
- SQL CE doesn’t have a native JDBC compliant driver, worst case we will have to use some .NET interop like JNBridge/ Web Services etc.
- SQL CE doesn’t expose performance counters it will be very difficult to evaluate performance and SQL CE behavior under load, we can only measure response time and throughput but would not be able to observe internal resource utilization.
- SQL CE doesn’t support very high level of concurrency (ideally meant for desktop and device usage)
- SQL CE does not offers good buffer pool management
So with SQL CE out of the way we could just focus on leveraging SQL Express and optimizing the buffer pool management. So how does the buffer pool work?
When SQL Server starts it calculates the virtual address space for the buffer based on several parameters the most important being the physical memory on the system. SQL Server only identifies the max amount it should reserve for the buffer pool it doesn’t reserve the memory on startup it only commits memory on a need basis. The DMV sys.dm_os_sys_info can be used to view the amount of buffer memory, bpool_commit_target show "target" memory limit for the buffer pool and bpool_committed displays the amount of memory currently committed to the buffer pool( both number represent the number of 8 KB pages). This is also impacted by the configuration in the min server memory and max server memory. Note that when SQL Server starts it tries to commit large number of pages to buffer pool memory this is called ramp up time, SQL 2005 Enterprise edition tries to improve the performance by allocating 8 pages at a time (i.e. 64KB). Buffer manager performs disk I/O asynchronously. Optimizing the table data types and length to fit optimally into pages, identifying the indexing strategy + index usage and optimizing the I/O subsystem would all be important in optimizing the buffer pool management.
Scenarios that are not discussed in this blog which impact the buffer pool include
- AWE (for 32 bit environment) - most organizations are going for 64bit servers so AWE itself would fade away
- NUMA
There is news in the air that Microsoft is planning to release an in-memory DB however we are under NDA not to disclose further information, will blog about it separately when the product plans are more concrete and when the NDA is lifted.

2 comments:
This is a very interesting topic and it happens that I'm currently looking for answers at same question: is there an in memory DB solution for SQL Server that can be currently used/implemented? Anything that will work with SQL Server until Microsoft own solution will be out? MTCache project from Microsoft started many years ago seems to address exactly this problem, but it looks like the project was abandoned.
Steven,
Microsoft answer to a in memory db is the project currently called as Velocity. Keep in mind that Velocity is not a relational data model - more like a gigantic hash table with some great features for eviction rules/ routing/ load balancing etc. Using cash dependency you should be able to use it with SQL Server. Velocity is a in mem only model so it does not persist the state in any physical form - so you will still need a data store like SQL Server for permanent storage.
The project is in CTP - find more at http://msdn.microsoft.com/en-us/data/cc655792.aspx
Post a Comment