Ticket Q304015
Visible to All Users

Server Mode Performance

created 14 years ago

I've just used a sample project ( Q181109 ) in your website to load a Grid Control with 200 Columns & more than 3.000.000 rows. It's out of memory when open the form ( can open with 400.000 rows but very slow performance, it takes 3 minutes ).
I'm testing with DX 2010.2.4 trial.
Can you show me the best solution ?
Thanks

Show previous comments (8)
DevExpress Support Team 14 years ago

    Hi Vu,
    I've reviewed the project you sent. In it, XPDataView is used. This is not a server mode approach. XPDataView and other similar components are used to directly send queries to a database and return the result as XP objects. However, these components do not have any relation to server mode. And, yes, XPDataView doesn't support compound keys. Generally, the entire XPO doesn't support compound keys. The approach proposed in the mentioned KB article only provides backward compatibility when you already have a database and don't have any chance to change its structure. So, if you need to enable server mode, you should use the approach I showed you in the sample project attached to one of my previous messages. Only XPServerCollectionSource, XPInstandFeedbackSource, LinqServerModeSource and LinqInstandFeedbackSource can be used as a data source for GridControl to enable server mode. Other approaches will lead to the same result as if you are using a common DataSet - first, you execute a query, retrieve data, store it locally, and then show it in a data-aware control. Please review the documentation articles I gave you the links to and other documentation related to server mode.
    Thanks,
    Ted

      I did project with server mode many time, but not ok for me. I search in
      your website and make a project like http://www.devexpress.com/Support/Center/p/Q141364.aspx.
      Here the code :
      InitializeComponent();
                  SqlConnection conn = new SqlConnection("server=(local); Initial Catalog=Contoso_NAV_Staging_2; Integrated Security=SSPI");
                  conn.Open();
                  SqlCommand cmd = new SqlCommand("Select top 1 * from [dbo].[G_L Entry]", conn);
                  SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo);
                  DataTable table = new DataTable("myTable");
                  table.Load(reader);
                  conn.Close();
                  ReflectionDictionary dict = new ReflectionDictionary();
                  XPClassInfo classInfo = new XPDataObjectClassInfo(dict.GetClassInfo(typeof(LiteDataObject)), "dataset");
                  List<string> keyColumns = new List<string>();
                  foreach (DataColumn key in table.PrimaryKey)
                  {
                      keyColumns.Add(key.ColumnName);
                  }
                  foreach (DataColumn col in table.Columns)
                  {
                      if (keyColumns.Contains(col.ColumnName)) {
                          classInfo.CreateMember(col.ColumnName, col.DataType, new KeyAttribute());
                      }
                      else
                      {
                          classInfo.CreateMember(col.ColumnName, col.DataType);
                      }
                  }
                  xpServerCollectionSource1 = new XPServerCollectionSource(session1, classInfo);
                  XpoDefault.DataLayer = XpoDefault.GetDataLayer(DevExpress.Xpo.DB.MSSqlConnectionProvider.GetConnectionString(@"(local)", "Contoso_NAV_Staging_2"), dict, AutoCreateOption.None);

      gridControl1.ServerMode = true;
                  gridControl1.DataSource = xpServerCollectionSource1;
      But It cannot popup the form with 3.000.000 row. What happened ? Can you help me fixed the code above
      Thanks for your support.

      DevExpress Support Team 14 years ago

        Hi Vu,
        The approach from these articles is correct. In order to make this approach work, you should pass a correct table name in the XPDataObjectClassInfo constructor. Also, the best practice is to initialize DataLayer only once when the application starts. I've modified this code, taking all the explanations into account, and created a sample project. You will find it in the attachment. I hope it will be helpful to you.
        Thanks,
        Ted

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.