You are here: Tuning > Main Operations Performance > Query Performance > Client-Server

Client-Server

In client-server use the connection speed can play an important role in the query performance.

QueryPerformanceBenchmark.cs: RunClientServerTest
private void RunClientServerTest()
         {

            InitForClientServer();
            Clean();
            System.Console.WriteLine("Storing " + _count + 
" objects of depth " + _depth
                    + " remotely:");
            Open(ConfigureClientServer());
            Store();
            Close();
            Open(ConfigureClientServer());
            StartTimer();
            IQuery query = objectContainer.Query();
            query.Constrain(typeof(Item));
            query.Descend("_name").Constrain("level1/1");
            Item item = (Item)query.Execute().Next();
            StopTimer("Select 1 object: " + item._name);
            Close();

            Init();
            Clean();
            System.Console.WriteLine("Storing " + _count + 
" objects of depth " + _depth
                    + " locally:");
            Open(ConfigureClientServer());
            Store();
            Close();
            Open(ConfigureClientServer());
            StartTimer();
            query = objectContainer.Query();
            query.Constrain(typeof(Item));
            query.Descend("_name").Constrain("level1/1");
            item = (Item)query.Execute().Next();
            StopTimer("Select 1 object: " + item._name);
            Close();
        }
QueryPerformanceBenchmark.cs: InitForClientServer
private void InitForClientServer()
         {
            _filePath = "performance.db4o";
            _isClientServer = true;
            _host = "localhost";
        }
QueryPerformanceBenchmark.cs: ConfigureClientServer
private IConfiguration ConfigureClientServer()
         {
            IConfiguration config = Db4oFactory.NewConfiguration();
            config.Queries().EvaluationMode(QueryEvaluationMode.Immediate);
            config.ClientServer().SingleThreadedClient(true);
            return config;
        }

Results from the test machine:

Storing 30000 objects of depth 3 remotely:

Store 90000 objects: 10725ms

Select 1 object: level1/1: 1763ms

Storing 10000 objects of depth 3 locally:

Store 30000 objects: 2904ms

Select 1 object: level1/1: 630ms

In order to improve the performance use Lazy or Snapshot evaluation modes.

Download example code:

c#