
|
 |
'CREATE DOMAIN T_INTEGER
' AS INTEGER;
'
'CREATE GENERATOR GEN_ID_TEST_QUERY_POOL_TABLE;
'
'CREATE TABLE TEST_QUERY_POOL_TABLE
'(
' TEST_ID T_INTEGER NOT NULL,
' A0 T_INTEGER,
' A1 T_INTEGER,
' A2 T_INTEGER,
' A3 T_INTEGER,
' A4 T_INTEGER,
' A5 T_INTEGER,
' A6 T_INTEGER,
' A7 T_INTEGER,
' A8 T_INTEGER,
' A9 T_INTEGER,
'
' PRIMARY KEY (TEST_ID)
');
Sub sample7_4()
Const table_name As String = "test_query_pool_table"
Const col_prefix As String = "A"
Const col_first_num As Long = 0
Const col_count As Long = 10
Const table_size As Long = 500
Dim cn As New ADODB.Connection
cn.Open "provider=LCPI.IBProvider;data source=main:e:\database\ibp_test.gdb;ctype=win1251", "gamer", "vermut"
Debug.Print "Provider Version:" & cn.Properties("provider version")
cn.BeginTrans
Dim rs As New ADODB.Recordset
rs.ActiveConnection = cn
'INSERT - GEN KEY RULE
rs.Properties("auto_gen_key_rule") = "GEN_N.GEN_ID_TEST_QUERY_POOL_TABLE.TEST_ID"
'INSERT - ENUM ONLY MODIFIED FIELDS
rs.Properties("auto_insert_field_rule") = 1
'UPDATE -ENUM ONLY MODIFIED FIELDS
rs.Properties("auto_update_field_rule") = 1
'BUILD TEST TABLE
rs.Open table_name, , adOpenKeyset, adLockBatchOptimistic, adCmdTable
'clear table
While (Not rs.EOF)
'Debug.Print CStr(rs("test_id"))
rs.Delete
rs.MoveNext
Wend
Dim i As Long
'insert records
For i = 0 To table_size - 1
rs.AddNew 'IBProvider will be generate TEST_ID field
Next i
'APPLY ALL CHANGES
rs.UpdateBatch
rs.Close
'query_pool_size=0..9
Dim times(0 To col_count + 2) As Date
Dim query_pool_size As Long
Dim col_num As Long
Dim start_time As Date
For query_pool_size = LBound(times) To UBound(times)
rs.Properties("query_pool_size") = query_pool_size
rs.Open table_name, , adOpenKeyset, adLockOptimistic
'load all records
If (Not rs.EOF) Then rs.MoveLast
'restart
If (Not rs.EOF) Then rs.MoveFirst
start_time = Time
While Not rs.EOF
For col_num = col_first_num To col_first_num + col_count - 1
rs(col_prefix + CStr(col_num)) = col_num
rs.Update ' UPDATE SINGLE COLUMN
Next col_num
rs.MoveNext
Wend
times(query_pool_size) = Time - start_time
Debug.Print CStr(query_pool_size) & ": " & CStr(times(query_pool_size))
rs.Close
Next query_pool_size
cn.CommitTrans
End Sub 'sample7_4
|