Is it possible to load an entire SQL Server CE database into RAM?

Posted by DanM on Stack Overflow See other posts from Stack Overflow or by DanM
Published on 2010-05-21T05:37:19Z Indexed on 2010/05/21 5:40 UTC
Read the original article Hit count: 200

I'm using LinqToSql to query a small SQL Server CE database.

I've noticed that any operations involving sub-properties are disappointingly slow.

For example, if I have a Customer table that is referenced by an Order table via a foreign key, LinqToSql will automatically create an EntitySet<Order> property. This is a nice convenience, allowing me to do things like Customer.Order.Where(o => o.ProductName = "Stopwatch"), but for some reason, SQL Server CE hangs up pretty bad when I try to do stuff like this. One of my queries, which isn't really that complicated takes 3-4 seconds to complete.

I can get the speed up to acceptable, even fast, if I just grab the two tables individually and convert them to List<Customer> and List<Order>, then join then manually with my own query, but this is throwing out a lot of the appeal of LinqToSql.

So, I'm wondering if I can somehow get the whole database into RAM and just query that way, then occasionally save it. Is this possible? How? If not, is there anything else I can do to boost the performance?

Note: My database in its initial state is about 250K and I don't expect it to grow to more than 1-2Mb. So, loading the data into RAM certainly wouldn't be a problem from a memory point of view.

© Stack Overflow or respective owner

Related posts about sql-server-ce

Related posts about linq-to-sql