Performance 调整FoxPro数据

Performance 调整FoxPro数据,performance,foxpro,Performance,Foxpro,我们通过索引碎片整理、重新索引或删除并重建索引来优化SQL server数据库。Foxpro有没有这样的数据调整技术 谢谢, Chak.重新编制索引和打包表格会有所帮助。甚至类库(.vcx)也是可以打包的表。但不幸的是,我不记得确切的命令。重新编制索引和打包表有帮助。甚至类库(.vcx)也是可以打包的表。但不幸的是,我不记得确切的命令。用于对表进行碎片整理的命令 USE YourTable EXCLUSIVE PACK 如果您的表有任何备注字段,请执行以下操作: PACK MEMO 如果表有

我们通过索引碎片整理、重新索引或删除并重建索引来优化SQL server数据库。Foxpro有没有这样的数据调整技术

谢谢,
Chak.

重新编制索引和打包表格会有所帮助。甚至类库(.vcx)也是可以打包的表。但不幸的是,我不记得确切的命令。

重新编制索引和打包表有帮助。甚至类库(.vcx)也是可以打包的表。但不幸的是,我不记得确切的命令。

用于对表进行碎片整理的命令

USE YourTable EXCLUSIVE
PACK
如果您的表有任何备注字段,请执行以下操作:

PACK MEMO
如果表有索引,包将自动重新为它们编制索引

正如Arnis提到的,VFP中的大多数内容都基于表。。。表单、类和报表,尽管它们具有不同的扩展名。所以你可以

use YourForm.scx exclusive
pack memo 

use YourClassLib.vcx exclusive
pack memo

use YourReport.frx exclusive
pack memo

use YourProject.pjx exclusive
pack memo
此外,如果您想删除常规.dbf表中的单个索引

use YourTable exclusive
delete tag MyIndexTag
或者,删除所有索引

delete tag all

用于对表进行碎片整理

USE YourTable EXCLUSIVE
PACK
如果您的表有任何备注字段,请执行以下操作:

PACK MEMO
如果表有索引,包将自动重新为它们编制索引

正如Arnis提到的,VFP中的大多数内容都基于表。。。表单、类和报表,尽管它们具有不同的扩展名。所以你可以

use YourForm.scx exclusive
pack memo 

use YourClassLib.vcx exclusive
pack memo

use YourReport.frx exclusive
pack memo

use YourProject.pjx exclusive
pack memo
此外,如果您想删除常规.dbf表中的单个索引

use YourTable exclusive
delete tag MyIndexTag
或者,删除所有索引

delete tag all

要记住的另一件事是,FoxPro数据库只是服务器上文件的集合。因此,服务器磁盘碎片以及确保从这些文件中排除杀毒软件也会产生很大的影响。

另一件需要记住的事情是,FoxPro数据库只是服务器上文件的集合。因此,服务器磁盘碎片和确保从这些文件中排除反病毒等措施也会产生很大的影响。

对于重新编制索引,您最好自己这样做:重新编制索引有时无法修复索引损坏

procedure reindextable

lparameters cTable
local cDBC, nTagCount, cTag, nTag
local array arrTags[1]

if pcount() = 0
    ? "No parameter"
    return -1
endif

close tables all

use (cTable) exclusive

? "Reindexing " + alltrim(alias())

nTagCount = tagcount()
if nTagCount = 0
    ? "No tags found"
    return -1
endif

dimension arrTags[nTagCount, 7]
for nTag = 1 to nTagCount
    arrTags[nTag, 1] = tag(nTag)
    arrTags[nTag, 2] = key(nTag)
    arrTags[nTag, 3] = for(nTag)
    arrTags[nTag, 4] = unique(nTag)
    arrTags[nTag, 5] = primary(nTag)
    arrTags[nTag, 6] = candidate(nTag)
    arrTags[nTag, 7] = descending(nTag)
endfor

* OK, we have the info to re-create the tags. Now delete the existing tags.

delete tag all

* Now re-create the tags
for nTag = 1 to nTagCount
    if arrTags[nTag, 5]
        * Primary key; need to use ALTER TABLE
        cTag = "ALTER TABLE " + cTable + " ADD PRIMARY KEY " + arrTags[nTag, 2]

        * Thanks to Anders Altberg for the info that you can add a filter to a PK, as long
        * as the TAG appears *after* the filter.
        if not empty (arrTags[nTag, 3])
            cTag = cTag + " FOR " + arrTags[nTag, 3]
        endif

        cTag = cTag + " TAG " + arrTags[nTag, 1]
    else
        * Regular index (or possibly a Candidate)
        cTag = "INDEX ON " + arrTags[nTag, 2] + " TAG " + arrTags[nTag, 1]
        if not empty (arrTags[nTag, 3])
            cTag = cTag + " FOR " + arrTags[nTag, 3]
        endif

        if arrTags[nTag, 4]
            cTag = cTag + " UNIQUE "
        endif

        if arrTags[nTag, 6]
            cTag = cTag + " CANDIDATE "
        endif

        if arrTags[nTag, 7]
            cTag = cTag + " DESC "
        endif

    endif

    * This will create the tag
    &cTag

    ? cTag


endfor

? "Success."

return 0

对于重新编制索引,您最好自己执行这样的过程:REINDEX有时无法修复索引损坏

procedure reindextable

lparameters cTable
local cDBC, nTagCount, cTag, nTag
local array arrTags[1]

if pcount() = 0
    ? "No parameter"
    return -1
endif

close tables all

use (cTable) exclusive

? "Reindexing " + alltrim(alias())

nTagCount = tagcount()
if nTagCount = 0
    ? "No tags found"
    return -1
endif

dimension arrTags[nTagCount, 7]
for nTag = 1 to nTagCount
    arrTags[nTag, 1] = tag(nTag)
    arrTags[nTag, 2] = key(nTag)
    arrTags[nTag, 3] = for(nTag)
    arrTags[nTag, 4] = unique(nTag)
    arrTags[nTag, 5] = primary(nTag)
    arrTags[nTag, 6] = candidate(nTag)
    arrTags[nTag, 7] = descending(nTag)
endfor

* OK, we have the info to re-create the tags. Now delete the existing tags.

delete tag all

* Now re-create the tags
for nTag = 1 to nTagCount
    if arrTags[nTag, 5]
        * Primary key; need to use ALTER TABLE
        cTag = "ALTER TABLE " + cTable + " ADD PRIMARY KEY " + arrTags[nTag, 2]

        * Thanks to Anders Altberg for the info that you can add a filter to a PK, as long
        * as the TAG appears *after* the filter.
        if not empty (arrTags[nTag, 3])
            cTag = cTag + " FOR " + arrTags[nTag, 3]
        endif

        cTag = cTag + " TAG " + arrTags[nTag, 1]
    else
        * Regular index (or possibly a Candidate)
        cTag = "INDEX ON " + arrTags[nTag, 2] + " TAG " + arrTags[nTag, 1]
        if not empty (arrTags[nTag, 3])
            cTag = cTag + " FOR " + arrTags[nTag, 3]
        endif

        if arrTags[nTag, 4]
            cTag = cTag + " UNIQUE "
        endif

        if arrTags[nTag, 6]
            cTag = cTag + " CANDIDATE "
        endif

        if arrTags[nTag, 7]
            cTag = cTag + " DESC "
        endif

    endif

    * This will create the tag
    &cTag

    ? cTag


endfor

? "Success."

return 0

如果未创建重新索引过程,请运行并获取Stonefield数据库工具包:

它所做的一件事是构建关于索引的元数据。它有一个命令来重新索引所有表,或者一次一个表。您可以添加或删除索引,无需跟踪它或更改您的重新索引例程。验证元数据(内置功能),并将更新的元数据与DBC文件和更新一起发送出去。生产表(结构和索引)将更新,以匹配您在开发中拥有的内容

大多数使用包含数据库的dbf的VFP开发人员都认为这个工具不可或缺

至于打包您的源代码(SCX、VCX、FRX、LBX、MNX、PJX),您所要做的就是在构建项目时重新构建所有代码。VFP将在构建之后打包所有源代码。这将减少生成的可执行文件的大小,而不是优化或调优数据库


Rick

如果没有创建重新索引过程,请运行并获取Stonefield数据库工具包:

它所做的一件事是构建关于索引的元数据。它有一个命令来重新索引所有表,或者一次一个表。您可以添加或删除索引,无需跟踪它或更改您的重新索引例程。验证元数据(内置功能),并将更新的元数据与DBC文件和更新一起发送出去。生产表(结构和索引)将更新,以匹配您在开发中拥有的内容

大多数使用包含数据库的dbf的VFP开发人员都认为这个工具不可或缺

至于打包您的源代码(SCX、VCX、FRX、LBX、MNX、PJX),您所要做的就是在构建项目时重新构建所有代码。VFP将在构建之后打包所有源代码。这将减少生成的可执行文件的大小,而不是优化或调优数据库


Rick

磁盘组可能很危险-如果在命令执行过程中发生某种情况(崩溃、断电等),则该表可能已损坏。在打包桌子之前,一定要备份

在我的办公室,我们很少使用PACK,因为除了临时表中的记录之外,我们很少删除任何内容——其他所有内容都是出于历史目的而保留的


不过,一定要每隔一段时间使用REINDEX一次。

PACK可能很危险-如果在命令执行过程中发生某种情况(崩溃、断电等),则表可能会损坏。在打包桌子之前,一定要备份

在我的办公室,我们很少使用PACK,因为除了临时表中的记录之外,我们很少删除任何内容——其他所有内容都是出于历史目的而保留的


不过,一定要每隔一段时间使用REINDEX。

顺便说一句,如果您进行了打包,备注字段仍将打包,并删除标记为删除的行。“打包备注”仅清除备注字段中的空格,但不会删除标记为删除的行。顺便说一句,如果进行打包,则备注字段仍将打包,并删除标记为删除的行。“打包备忘”仅清除备忘字段中的空格,但不删除标记为删除的行。