用程式產生資料庫和表格要設定哪些東西才會讓寫入最快ㄋ |
答題得分者是:tech_state
|
China Join
中階會員 發表:81 回覆:242 積分:89 註冊:2003-03-12 發送簡訊給我 |
請問: 小弟在程式裡面動態建立表格,還要設定那些東西才能讓寫入達到最快呢?
之前很多文章都提到要利用外部工具設定,是否這些設定,也可以寫在程式
裡面?(例如:控制 BLOCK SIZE 來決定資料庫的容量) 下面是目前的作法,是否要先設定別名... >>>DatabaseName = ".\\db">TableName = "Test.db";
NewTable->FieldDefs->Add("Subject",ftString,100,true);
NewTable->FieldDefs->Add("DateTime",ftDateTime,0,true);
NewTable->IndexDefs->Add("","Subject", TIndexOptions() << ixPrimary << ixUnique);
NewTable->CreateTable();
NewTable->Free();
|
tech_state
版主 發表:44 回覆:638 積分:641 註冊:2003-02-10 發送簡訊給我 |
怎麼樣最快我不知道
不過bruce0211版主提供的心得分享[Paradox 資料庫的極限]
這篇文章的確可以提昇速度
http://delphi.ktop.com.tw/topic.php?TOPIC_ID=18760 至於設定別名
我的習慣是會先設定啦
我測試了一下
如果不設定別名而直接給路徑的話也可以
引言: NewTable->DatabaseName = ".\\db";這行少了一個. 程式執行起來會有路徑的問題 應改為 NewTable->DatabaseName = "..\\db"; 發表人 - tech_state 於 2003/04/22 12:07:38 |
China Join
中階會員 發表:81 回覆:242 積分:89 註冊:2003-03-12 發送簡訊給我 |
|
tech_state
版主 發表:44 回覆:638 積分:641 註冊:2003-02-10 發送簡訊給我 |
|
China Join
中階會員 發表:81 回覆:242 積分:89 註冊:2003-03-12 發送簡訊給我 |
|
BeautyGirl
一般會員 發表:1 回覆:7 積分:6 註冊:2003-04-11 發送簡訊給我 |
|
tech_state
版主 發表:44 回覆:638 積分:641 註冊:2003-02-10 發送簡訊給我 |
China Join, 您好
不知以下的程式是否是您所說的由程式修改 BLOCK SIZE void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
hDBIDb hDb ;
DBIResult dbResult ;
CRTblDesc TblDesc ;
FLDDesc pFDesc;
String OptData;
//Initialize the BDE
DbiInit(NULL); //Open a Database
DbiOpenDatabase(DatabaseAlias,NULL,dbiREADONLY,dbiOPENSHARED,NULL,0,NULL,NULL,hDb); memset((void *) &TblDesc, 0, sizeof(CRTblDesc));
lstrcpy(TblDesc.szTblName, TableName);
lstrcpy(TblDesc.szTblType, szPARADOX);
OptData = "4096"; // BLOCK SIZE
pFDesc.iOffset = 0;
pFDesc.iLen = OptData.Length 1;
lstrcpy(pFDesc.szName, "BLOCK SIZE");
TblDesc.iOptParams = 1; // Only one optional parameter
TblDesc.pfldOptParams = &pFDesc;
TblDesc.pOptData = &OptData[1]; dbResult = DbiDoRestructure(hDb, 1, &TblDesc, NULL, NULL, NULL, false);
if(dbResult == DBIERR_NONE)
ShowMessage("Success");
else
ShowMessage("Failure");
//Close Database
DbiCloseDatabase(hDb);
} 藍色部分可根據您的需求修改
我只測試有先設定別名的部分
如果以上程式符合您的需求
不設別名
直接給路徑的部份就由您來修改囉 發表人 - tech_state 於 2003/04/22 18:16:30
|
China Join
中階會員 發表:81 回覆:242 積分:89 註冊:2003-03-12 發送簡訊給我 |
謝謝大家幫小弟的忙 這個問題小弟已經藉由修改 RegEdit 解決了,tech_state 版主提供的方法
小弟試著去執行,但是還是有一些問題 小弟資料庫存放在 程式目錄下的 db 子目錄 檔名是 aaa.db 修改程式如下 #include 〈BDE.hpp〉 void __fastcall TForm1::Button1Click(TObject *Sender)
{
hDBIDb hDb ;
DBIResult dbResult ;
CRTblDesc TblDesc ;
FLDDesc pFDesc;
String OptData;
//Initialize the BDE
DbiInit(NULL); //Open a Database
DbiOpenDatabase(".//db",NULL,dbiREADONLY,dbiOPENSHARED,NULL,0,NULL,NULL,hDb); memset((void *) &TblDesc, 0, sizeof(CRTblDesc));
lstrcpy(TblDesc.szTblName,"aaa");
lstrcpy(TblDesc.szTblType, szPARADOX);
OptData = "4096"; // BLOCK SIZE
pFDesc.iOffset = 0;
pFDesc.iLen = OptData.Length + 1;//這裡怪怪ㄉ
lstrcpy(pFDesc.szName, "BLOCK SIZE");
TblDesc.iOptParams = 1; // Only one optional parameter
TblDesc.pfldOptParams = &pFDesc;
TblDesc.pOptData = &OptData[1]; dbResult = DbiDoRestructure(hDb, 1, &TblDesc, NULL, NULL, NULL, false);
if(dbResult == DBIERR_NONE)
ShowMessage("Success");
else
ShowMessage("Failure");
//Close Database
DbiCloseDatabase(hDb);
} 錯誤訊息為:[C++ Error] Unit1.cpp(36): E2235 Member function must be called or its address taken 這一行好像有問題
pFDesc.iLen = OptData.Length + 1; 如果版主大人沒空的話,可否告訴小弟資料出處,小弟自行研究就好啦 ~
非常謝謝你們的幫忙
|
China Join
中階會員 發表:81 回覆:242 積分:89 註冊:2003-03-12 發送簡訊給我 |
|
China Join
中階會員 發表:81 回覆:242 積分:89 註冊:2003-03-12 發送簡訊給我 |
小弟自行加入別名,結果也是錯一樣的地方 MyAlias="MyAlias">IsAlias(MyAlias))
Session->AddStandardAlias(MyAlias, ExtractFilePath(Application->ExeName) "DB", "PARADOX"); hDBIDb hDb ;
DBIResult dbResult ;
CRTblDesc TblDesc ;
FLDDesc pFDesc;
String OptData;
//Initialize the BDE
DbiInit(NULL); //Open a Database
DbiOpenDatabase("MyAlias",NULL,dbiREADONLY,dbiOPENSHARED,NULL,0,NULL,NULL,hDb);
|
China Join
中階會員 發表:81 回覆:242 積分:89 註冊:2003-03-12 發送簡訊給我 |
|
tech_state
版主 發表:44 回覆:638 積分:641 註冊:2003-02-10 發送簡訊給我 |
|
China Join
中階會員 發表:81 回覆:242 積分:89 註冊:2003-03-12 發送簡訊給我 |
小弟的需求很簡單,就是讓使用者可以決定他新增資料庫的最大容量,因為如果 BLOCK SIZE 越大,相對的檔案空間也越大,所以目的就是讓客戶決定他新增的這個資料庫容量的上限。 沒有其他工具,就只有用 用 BCB 內建的 BDE Administrator 來改的經驗,目前資料量還不夠多,所以沒有辦法實際驗證資料庫的上限,不過如果用 BDE Administrator 來看,這段程式並沒有作用,另外 BeautyGirl 大大提供的方法,的確可以用,因為改完之後 BDE Administrator 裡面的值也會跟著變,但如同版主大人所說,這段程式可能對特定 DataBase Table 有效,那就必需再實際驗證才能得知了。 在這邊可以看到 BDE Administrator -> Configuration -> Drivers -> Native -> ParaDox
-> Block Size 說明如下: Paradox driver settings To configure the way Paradox tables are created, sorted, and handled, choose Paradox as the driver name on the Configuration page of the BDE Administrator or create or select a STANDARD alias on the Databases page that uses Paradox as the Default Driver.
To change a setting, highlight the desired configuration parameter. Delete the old value and enter a new one in the appropriate text box. You can only change parameters WITHOUT bold labels.
In the following table, Parameters lists all tracked parameters for the selected driver type, and their current settings. When the driver is first installed, all values are set to their defaults. Description briefly notes the purpose of the highlighted parameter. Parameter Description
NET DIR The directory location of the Paradox network control file PDOXUSRS.NET. The active NET DIR parameter is stored in the Paradox section of the BDE configuration file and has precedence over any other NET DIR parameters that may be stored in older 16-bit configuration files, or in the System Init section of the current configuration file, or in the Registry. These other NET DIR entries will have no effect. To access a Paradox table on a network drive, the active NETDIR parameter in the Paradox section of the BDE configuration file must point to a network drive. VERSION Internal version number of the Paradox driver.
TYPE Type of server to which this driver helps you connect. Can be SERVER (SQL server) or FILE (standard, file-based server).
LANGDRIVER Language driver used to determine table sort order and character set. [available drivers].
US default: 'ascii' ANSI (DBWINUS0)
BLOCK SIZE Size of disk blocks used to store Paradox table records, in multiples of 1024 bytes. Valid settings depend on the table format: Level 5 and 7 1024, 2048, 4096, 16384, and 32768
Level 3 and 4 1024, 2048, and 4096
Default: 2048
FILL FACTOR Percentage of current disk block which must be filled before Paradox will allocate another disk block for index files. Can be any integer ranging from 1 to 100. Default: 95 Note: Smaller values offer better performance but increase the size of indexes. Larger values give smaller index files but increase the time needed to create an index. LEVEL Type of table format used to create temporary Paradox tables.
Level 7 Paradox for Windows 32-bit tables
Level 5 Paradox 5.0 tables
Level 4 STANDARD table format introduced in Paradox 4.0
Level 3 Compatible table format used by Paradox 3.5 and earlier versions.
Default: Level 4. To use Blob fields, secondary indexes, and strict referential integrity, specify either Paradox level 4 or Paradox level 5 tables. You will probably want to use the lowest level possible in order to maximize backward compatibility. Choose Level 7 only If you need the advanced indexing features supported by that table format. STRICTINTEGRTY Specifies whether Paradox tables can be modified using applications that do not support referential integrity (such as, Paradox 4.0). For example, if TRUE you will be unable to change a table with referential integrity using Paradox 4.0; if FALSE, you can change the table, but you risk the integrity of your data. Default: TRUE.
|
tech_state
版主 發表:44 回覆:638 積分:641 註冊:2003-02-10 發送簡訊給我 |
引言: 小弟的需求很簡單,就是讓使用者可以決定他新增資料庫的最大容量,因為如果 BLOCK SIZE 越大,相對的檔案空間也越大,所以目的就是讓客戶決定他新增的這個資料庫容量的上限。 沒有其他工具,就只有用 用 BCB 內建的 BDE Administrator 來改的經驗,目前資料量還不夠多,所以沒有辦法實際驗證資料庫的上限,不過如果用 BDE Administrator 來看,這段程式並沒有作用,另外 BeautyGirl 大大提供的方法,的確可以用,因為改完之後 BDE Administrator 裡面的值也會跟著變,但如同版主大人所說,這段程式可能對特定 DataBase Table 有效,那就必需再實際驗證才能得知了。 在這邊可以看到 BDE Administrator -> Configuration -> Drivers -> Native -> ParaDox -> Block SizeChina Join, 您好 用 BDE Administrator 修改 Block Size 後會出現訊息 請您對所有使用 BDE database 的 table 做 Restructure 所以基本上如果您只修改 BDE Administrator 的設定 對您之前已建立的 table 好像也沒有影響 所以我認為 如果您要使用者自己修改 Block Size 的話 可能已只能針對特定 database 的 table 如同對 table 做 pack 的動作一樣 如果您要針對特定 database 裡所有的 table 都重新設定 Block Size 的話 就只好做迴圈將 table 一個一個找出來修改 Block Size 然後再做 Restructure 記得不是只做 Block Size 的修改 而沒有做 Restructure 這樣是沒有用的喔 ============ 是非終日有 不聽自然無 |
China Join
中階會員 發表:81 回覆:242 積分:89 註冊:2003-03-12 發送簡訊給我 |
|
tech_state
版主 發表:44 回覆:638 積分:641 註冊:2003-02-10 發送簡訊給我 |
引言: 不好意思,版主大人所指的 Restructure 要如何作呢? 這個東西浪費您太多時間,小弟先把答題分數給妳ㄌ >>< face="Verdana, Arial, Helvetica"> China Join, 您好 如果是用 BDE Administrator 我也不知道怎麼做 在程式中可以用這個指令 DbiDoRestructure 做 Restructure 的動作 雖然您已做結案 但還是希望如果其他前輩先進有更好的方法的話 可以不吝指教 ============ 是非終日有 不聽自然無 |
China Join
中階會員 發表:81 回覆:242 積分:89 註冊:2003-03-12 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |