Home > Software engineering >  Ask you Daniel, extract the database records why so slow? In the waiting...
Ask you Daniel, extract the database records why so slow? In the waiting...

Time:10-05

My program is c/s mode, s is a fixed IP address of the server, my program is to use vb6 development, each client installed, placed a msflexgrid control on the form, procedure to access the database are implemented through stored procedures, meet a problem now, I wrote a program process, used to retrieve the record of this table, sp name p_assocmember_GetList
The content of the stored procedure:
Select * from doTable order by id
Put a msflexgrid control, form the form_load () add the following code:
Public Sub Data_Load ()
Dim As Integer I
MSFlexGrid_Format
Mand Set CMD=New ADODB.Com
The Set RST=New ADODB. You
DbConnect
CMD. The ActiveConnection=cnDatabase
Cmd.Com mandType=adCmdStoredProc
Cmd.Com mandText="p_assocmember_GetList"
The Set RST=CMD. The Execute
If RST. BOF=False Then
I=1
EOF
Do Until RST.Me. MsfgVisitor. TextMatrix (I, 1)=RST! Sn
Me. MsfgVisitor. TextMatrix (I, 2)=IIf (IsNull (RST! VisitDate), "", RST! VisitDate)
Me. MsfgVisitor. TextMatrix (I, 3)=IIf (IsNull (RST! VisitTime), "", RST! VisitTime)
Me. MsfgVisitor. TextMatrix (I, 4)=IIf (IsNull (RST! IsAppoint), "", the IIf (RST! IsAppoint=1, "yes", "no"))
Me. MsfgVisitor. TextMatrix (I, 5)=IIf (IsNull (RST! Name), "", RST! Name)
Me. MsfgVisitor. TextMatrix (I, 6)=IIf (IsNull (RST! Sex), "", RST! Sex)
Me. MsfgVisitor. TextMatrix (I, 7)=IIf (IsNull (RST! HomePhone), "", RST! HomePhone)
Me. MsfgVisitor. TextMatrix (I, 8)=IIf (IsNull (RST! Mobile), "", RST! Mobile)
Me. MsfgVisitor. TextMatrix (I, 9)=IIf (IsNull (RST! Age), "", RST! Age)
Me. MsfgVisitor. TextMatrix (I, 1)=IIf (IsNull (RST! CustomerSource), "", RST! CustomerSource)
Me. MsfgVisitor. TextMatrix (I, 11)=IIf (IsNull (RST! IsphTest), "", the IIf (RST! IsphTest=1, "yes", "no"))
Me. MsfgVisitor. TextMatrix (I, 12)=IIf (IsNull (RST! CoachName), "", RST! CoachName)
Me. MsfgVisitor. TextMatrix (I, 13)=IIf (IsNull (RST! MemberCon), "", RST! MemberCon)
Me. MsfgVisitor. TextMatrix (I, 14)=Format (IIf (IsNull (RST! FrontMoney), "0", the RST! FrontMoney), "# # #. 00")
Me. MsfgVisitor. TextMatrix (I, 15)=IIf (IsNull (RST! Regman), "", RST! Regman)
I=I + 1
RST. MoveNext
Loop
End the If
CnDatabase. Close
The Set of RST=Nothing
The Set of CMD=Nothing
End Sub
To solve the problem: now saved 90 records, access time is about: 36 seconds, my laptop is in wireless way, excuse me, Daniel, how to optimize the speed is too slow, so after record, to wait for half a day,

CodePudding user response:

How about you use cable connection test first, the speed,
Wireless is not suitable for direct remote database, the actual speed difference theory,

CodePudding user response:

I tried, cable, too, more than 30 seconds, should be has less to do with network or application problems, please help me to think it over, how to optimize it, it's only 92 records, after more than 900, wouldn't it be a long time, thank you!

CodePudding user response:

I optimization, query, convert to field, and then select what fields, it has been improved a lot,

CodePudding user response:

The order by who
In the index is built on the "who"

CodePudding user response:

Explain your table, in the design of a single record of data is too big,
The table vertical segmentation, small field in a table, big field in a table, one to one correspondence with id,
So that we can improve the speed of query small fields,

Big data can use external file storage, actually it is better than stored in the database performance,

CodePudding user response:

Upstairs right,

If there is a lot of fields, rather than the data exist outside of the file, the corresponding field only save the file path,

Otherwise, the record becomes too large, every record pointer migration to trigger the "cursor" (virtual cache database) with the database files in the disk of a large number of "disk exchange",

CodePudding user response:

In addition to the segmentation of table, there is no other technology on the way?

CodePudding user response:

Add me QQ2776478814, ask you Daniel and extract the database record why so slow? In the waiting

CodePudding user response:

In addition to the segmentation, only by improving hardware,

CodePudding user response:

Look at your code, the feeling is slow in two places, the first is the second line of code you grid format, the second is slow in the record in the database to the grid in the process of writing, such as you have 90 records, each record 10 fields, your pointer will move down 90 times, each time one by one again write 10 cell, equivalent to the loop 900 times, advice, query the records, direct msflexgrid=rs (record) should be quicker

CodePudding user response:

As for the first row of the grid titles, to write again