gto250 发表于 2011-7-31 08:52:56

关于sqlite3数据库的问题

#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Local $hQuery, $aRow
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 543, 167, 192, 124)
$Label1 = GUICtrlCreateLabel("Label1", 16, 8, 516, 17)
$Label2 = GUICtrlCreateLabel("Label2", 16, 40, 524, 17)
$Label3 = GUICtrlCreateLabel("Label3", 16, 80, 524, 17)
$Button1 = GUICtrlCreateButton("下一题", 224, 128, 75, 25)
GUISetState(@SW_SHOW)
_SQLite_Startup ()
_SQLite_Open (@ScriptDir&"\题库数据库.db") ; 打开:内存:数据库

_SQlite_Query (-1, "SELECT * FROM panduanti where id=1;", $hQuery)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK ; 读出下一行
GUICtrlSetData($Label1,$aRow)
GUICtrlSetData($Label2,$aRow)
GUICtrlSetData($Label3,$aRow)
WEnd
Dim $i=1
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                       _SQLite_Close ()
_SQLite_Shutdown ()
                        Exit
                Case $Button1
                        $i=$i+1
               _SQlite_Query (-1, "SELECT * FROM panduanti where id="&$i&";", $hQuery)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK ; 读出下一行
GUICtrlSetData($Label1,$aRow)
GUICtrlSetData($Label2,$aRow)
GUICtrlSetData($Label3,$aRow)
WEnd       
        EndSwitch
WEnd

上面的这段代码是我操作sqlite数据库的代码,因为数据库比较大(54M)我就不传上来了。
家中的电脑是win7的系统,2.6G双核,4G内存
公司的电脑2.4双核,512M内存
数据库:sqlite 54M,数据类型是Binary,因为输入的内容是从RichEdit富文本框读出后通过Binary转换的

同样的代码,同样的数据库,为什么在公司里第一次打开的时候总是很慢才能从数据库中读取到数据,但是只要读到数据后,再点击下一题按钮,速度又很快的。
在家中的电脑,第一次运行就能很快从数据库中读取到数据。

是不是sqlite数据库载入的快慢和内存大小有关呢?
页: [1]
查看完整版本: 关于sqlite3数据库的问题