Why is the program execution efficiency so low?

Source: Internet
Author: User
Yesterday, the apsaradb for Warcraft database of the new project went online for testing. The feedback showed that the skill block was a little slow. After reading it, it was indeed analyzed using eqatec. The results are as follows:

Apparently, the problem occurs in the sqldataprovider. getiteminfo method. Code As follows:

Public iteminfo getiteminfo (INT Itemid)
{
Using (sqlconnection connection = getsqlconnection ())
{
Sqlcommand cmd = new sqlcommand ("proc_item_getmodel", connection );
Cmd. commandtype = commandtype. storedprocedure;
Cmd. Parameters. Add ("@ Itemid", sqldbtype. INT). value = Itemid;

Iteminfo item = NULL;
Connection. open ();
Sqldatareader reader = cmd. executereader ();
If (reader. Read ())
{
Item = loaditeminfofromdatareader (Reader );
}
Reader. Close ();
Reader. Dispose ();

Cmd. Dispose ();

Connection. Close ();

Return item;
}
}
The average time of this method is 84 ms, and the time of the two called methods is less than 1 ms.ProgramI can't optimize the code. I feel the problem is probably in cmd. executereader, that is to say, the problem lies in getting data from the database. However, this stored procedure is very simple, that is, a SELECT statement. Currently, there are more than two million database records.

Where is the problem?

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.