Enzo SQL Shard

This library provides a Shard technology that allows you to spread the load of database queries over multiple databases easily (SQL Server and SQL Azure). Uses the Task Parallel Library (TPL) and caching for high performance.
  • ENZO SHARD 3.0 IS NOW RELEASED. THIS VERSION SUPPORTS COMPRESSED SHARD FOR SaaS APPLICATIONS, SQL DATABASE FEDERATION AND DISTRIBUTED QUERIES. *

For more information about our company, visit http://www.bluesyntax.net.

About the Shard Strategies Implementations

This library allows you to perform all the usual tasks in database management: create, read, update and delete records. Except that your code can execute against two or more databases seemlessly. Using the usual SqlCommand object, spread the load of your commands to multiple databases to improve performance and scalability. This library uses a Horizontal Partion Shard (the ShardStrategyExpanded class), which requires your tables to be partitionned horizontally, or a federation library for SQL Database federations (the ShardStrategyFederation class), or a Compress Strategy (the ShardStrategyCompressed class) allowing you to build SaaS and Multitenant applications easily. The download comes with three sample applications that shows you how to use each library.

The project is organized by centralizing common sharding operations in specialized classes. In addition, the basic underlying core logic of performing a shard call was placed in a Core class. By inheriting this class, any new strategy gains access to specific sharding options and settings. The Federation and Compressed Shard Strategies uses the Core class and additional capabilities provided by this release, such as the Distributed Query.

For a complete description of the available shard libraries and how to use them, see the documentation here: https://enzosqlshard.codeplex.com/downloads/get/687199

Examples

Here are a few examples on how to use this library using the Compressed Shard and the Federation Shard Strategies.

How to query a single tenant in a compressed shard

To query a single tenant you need to know the tenant key (for a federation strategy, the tenant key is the member key). FILTERING_ON indicates that you only want to query a single tenant.

RootDatabase root_db = new RootDatabase(connectionString);
rootdb.Tenants.DefaultExecutionContext.Mode = ShardCore.ShardOperationMode.FILTERINGON;
root_db.Tenants.DefaultExecutionContext.MemberValue = “CUST1”;
DataTable data = root_db.Tenants.ExecuteDataTable("SELECT * FROM history");

How to query all tenants in a compressed shard

To query all the tenants you need to specify the FAN_OUT option (for both federation and compress shard strategies).

RootDatabase root_db = new RootDatabase(connectionString);
rootdb.Tenants.DefaultExecutionContext.Mode = ShardCore.ShardOperationMode.FANOUT;
root_db.Tenants.DefaultExecutionContext.MemberValue = “”;
DataTable data = root_db.Tenants.ExecuteDataTable("SELECT * FROM history");

How to query a single tenant in a Federation

In the following example, you are using WIndows Azure Federations and you are querying a single tenant within a federation member.

RootDatabase root_db = new RootDatabase(connectionString);
{"rootdb["purchase"].Tenants.DefaultExecutionContext.Mode = ShardCore.ShardOperationMode.FILTERINGON;
root_db["purchase"].Tenants.DefaultExecutionContext.MemberValue = 3;
DataTable data = root_db.Tenants.ExecuteDataTable("SELECT * FROM history");}"

Requirements

This library runs only with the .NET 4.0 framework using Visual Studio 2010.

Last edited May 30, 2013 at 4:26 AM by hroggero, version 22