简体   繁体   中英

In-memory database slower - retrieving data from DB

I have been trying to evaluate BrightStar DB for my project initially what I did is -

Using brightstar DB (server sw) I stored my SQL Server database table into its default store ie file location ( C:\\Program Files\\BrightstarDB\\Data ) and then to measure performance gain compared to SQL Server database, I tried to query a table both in memory and SQL Server and tried to load into a gridview.

To my surprise I could see the time taken to load the data directly from SQL Server is half that of in memory db. I don't know if this is right way to check performance - if anyone has experienced working with in memory please guide.

Below is the code used to load direct from SQL Server and for in memory I followed this link http://brightstardb.com/documentation/Developing_With_BrightstarDB2.html .

protected void BtnDatabase_Click(object sender, EventArgs e)
{
        try
        {
            GridView2.DataSource = null;

            TDNdc = TextBox1.Text;
            if (!string.IsNullOrEmpty(TDNdc))
                selectCommand = "select * from dbo.TD_List where ID='" + TDNdc + "'";

            String connectionString = @"data source=TD-abc\SQLEXPRESS;initial catalog=ScriptSave;integrated security=True";
            DateTime varDateTime = DateTime.Now; 
            dataAdapter = new SqlDataAdapter(selectCommand, connectionString);
            // Create a command builder to generate SQL update, insert, and 
            // delete commands based on selectCommand.
            SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
            // Populate a new data table and bind it to the BindingSource.
            DataTable table = new DataTable();
           // table.Locale = System.Globalization.CultureInfo.InvariantCulture;
            dataAdapter.Fill(table);
            TimeSpan result = DateTime.Now - varDateTime;
            GridView2.DataSource = table;
            GridView2.DataBind();

            Response.Write("Time Taken to load " + GridView2.Rows.Count + " Record(s) From DB : " + result);
            //LblInMem.Text = GridView2.Rows.Count + " Record(s) From DB : " + result;  
            //Response.Write("Time Taken to load datafrom DataBase " + result.ToString() + "Total Record :" + GridView2.Rows.Count);
        }
        catch (SqlException)
        {
        }
}

I think there is a misunderstanding here. BrightstarDB is not an in-memory database - in fact it is a fully transactional persistent data store. So you still have disk access penalties to pay. In my testing I've found BrightstarDB to generally be disk-bound...running it on a fast disk / SSD really helps performance, though I guess you will find the same to be true of SQL Server.

As alroc mentions, I think you are better to benchmark on the types of queries your application will use and to balance performance considerations against the other features that BrightstarDB offers, which you may (or may not) decide outweigh the performance penalties for particular types of query.

You should also consider using SPARQL rather than LINQ to write your BrightstarDB queries. There is a performance penalty to be paid for using LINQ as the LINQ query is converted to SPARQL before being executed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM