当只有 1W 条记录时,差别不大,差别约 2 秒。
当有 10W 条记录时,差别开始明显,一个耗时约 29秒,另一个约 5秒。
Clear
Close Databases
*!*
测试一:29s
Create Cursor Test1 (Id Int Autoinc, Name C(10), XingBie C(2), PhoneNum C(5))
For I = 1 To 100000
Insert Into Test1 (Name, XingBie, PhoneNum) Values(Sys(2015), Iif(Int(I/2) = I/2, '男', '女'), Sys(3))
Endfor
t1 = Seconds( )
Select Id, Field(1) + ':' As 字段A, (Select Padl(Id, 10, " ")
As 字段B From Test1 Where Id = A.Id) From Test1 As A ;
Union ;
Select Id, Field(2) + ':' As 字段A, (Select Name
As 字段B From Test1 Where Id = A.Id) From Test1 As A ;
Union ;
Select Id, Field(3) + ':' As 字段A, (Select XingBie
As 字段B From Test1 Where Id = A.Id) From Test1 As A ;
Union ;
Select Id, Field(4) + ':' As 字段A, (Select Padl(PhoneNum, 10, " ") As 字段B From Test1 Where Id = A.Id) From Test1 As A ;
Into Cursor Query
Select 字段A, 字段B From Query Into Cursor Query
Browse Last Nowait
? Transform(Seconds( ) - T1) + '秒'
Messagebox(Transform(Seconds( ) - T1) + '秒')
*!*
Return
*!*
测试二:5s
Create Cursor Test1 (Id Int Autoinc, Name C(10), XingBie C(2), PhoneNum C(5))
For I = 1 To 100000
Insert Into Test1 (Name, XingBie, PhoneNum) Values(Sys(2015), Iif(Int(I/2) = I/2, '男', '女'), Sys(3))
EndFor
t1 = Seconds( )
Create Cursor tt (S1 C(10), S2 C(10))
Select Test1
Scan
For i = 1 To Fcount()
ss1 = Field(i)
ss2 = Transform(Evaluate(ss1))
Insert Into tt Values (ss1, ss2)
Endfor
Endscan
Select tt
Go Top
Browse Last Nowait
? Transform(Seconds( ) - T1) + '秒'
Messagebox(Transform(Seconds( ) - T1) + '秒')
[此贴子已经被作者于2016-3-15 11:01编辑过]