Comparison of data storage and performance in Windows azure (2)

Source: Internet
Author: User

2. Table Storage: It stores data in the form of key-value. The maximum size of each record is 4 MB, and there is no limit on the number of records.

(1) entity operation. Entity operations are performed on tableservicecontext (inherited from dataservicecontext) obtained from cloudtableclient. The addobject (), updateojbect (), and deleteobject () methods are called for addition, update, and deletion. Only the addobject method needs to specify the table name of the operation. After the methods are called for entity Operations, you must call the savechanage () method to save the operation results.

 

Example of adding entity:

            CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;            CloudTableClient tableclient = storageAccount.CreateCloudTableClient();            tableclient.CreateTableIfNotExist("tabletest");            TableServiceContext context = tableclient.GetDataServiceContext();            context.AddObject("tabletest", new PersonInfo() { PersonID = "0", Name = "Tom", Age = 20 });            context.AddObject("tabletest", new PersonInfo() { PersonID = "1", Name = "Jerry", Age = 25 });            context.SaveChanges();

(2) query table records. Table query is a query executed using a LINQ Statement by calling the createquery () method of tableservicecontext.

Table query example:

            CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;            CloudTableClient tableclient = storageAccount.CreateCloudTableClient();            tableclient.CreateTableIfNotExist("tabletest");            TableServiceContext context = tableclient.GetDataServiceContext();            var query = context.CreateQuery<PersonInfo>("tabletest").Where(c => c.PersonID == "1").ToList();            var info = query.FirstOrDefault();

 

The personinfo type definition used in the preceding sample code.

 

    public class PersonInfo : TableServiceEntity    {        public string PersonID        {            get { return this.RowKey; }            set { this.RowKey = value; }        }        public string Name { get; set; }        public int Age { get; set; }        public PersonInfo()        {            this.PartitionKey = "PartKey";        }    }

 

(3) Table operation performance curve

A. The performance curves for adding, updating, and deleting records are shown in. We can analyze the linear relationship between the number of records and the consumed time, but it takes nearly 20 seconds for 100 data records, A little scary (this may be related to the operation record size and the location of the ECS deployed in webrole ).

 

B. the query performance curve is as good as the query performance.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.