重建FoxPro索引 [英] Rebuilding FoxPro indexes

查看:162
本文介绍了重建FoxPro索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在上个月举行的SW Fox会议上,提出了定期删除和重建foxpro索引的好主意。 我不时会得到一些索引错误,所以我想也许我可以设置一个例程来遍历我的
数据库并每周重建索引。 但这会带来一个问题,即如果从文件中删除索引然后尝试重新索引,则重新索引可能会因某种原因失败,从而使系统处于无法运行状态。 
将它放在事务中并在失败时回滚可能是一个想法,但看起来DELETE TAG和INDEX不能在事务中使用。 所以,我想知道重建索引的人是如何定期克服这个问题的。

解决方案

最简单的解决方案:处理副本,用重新索引替换生产数据一旦重建索引成功复制。


事实上,在使用stonefield的重建索引功能的客户,我们确实对生产数据进行了重新索引。我不记得任何导致应用程序因缺少索引而失败的日子。 Stonefield使用建议的元数据标准
DBCX,其中有关索引的信息存储为额外数据,因此关于哪些索引应该存在的知识永远不会丢失。


那里是一个更简单的解决方案,当您担心CDX标头数据和有关索引本身丢失的DBC数据时:备份DBC / DCT / DCX以恢复DBC本身并备份空表CDX文件,恢复它们并执行REINDEX就像重新创建
也可以通过DELETE TAG和所有必需的INDEX命令进行索引,因为空表CDX是尚未填充的索引文件。


编辑:如果没有空表(作为项目源的一部分,例如,您可以通过GENDBC(或GENDBCX)工具重新创建空DBF,以创建用于生成空数据库的sql脚本,或者当您只有空闲表时COPY TO some.DBF
与CDX FOR .F。


总是在表的健康状态下执行此操作,并且您应该知道应该存在哪些索引。


Bye,Olaf。


At the SW Fox conference last month, it was brought up that it's a good idea to delete and rebuild foxpro indexes periodically.  I do get some index errors from time to time, so I was thinking that perhaps I could set up a routine to go through my database and rebuild the indexes every week or so.  But this brings up the problem that if you delete the indexes from a file and then try to reindex, it's possible that the reindex will fail for some reason, leaving the system in a non-functioning state.  It might be an idea to put this in a transaction and rollback on failure, but it looks like DELETE TAG and INDEX are not able to be used in transactions.  So, I'm wondering how anyone who rebuilds indexes periodically overcomes this problem.

解决方案

Simplest solution: Working on a copy, replacing production data with the reindexed copy once the reindexing succeeds.

In fact at a customer using the reindexing capabilities of stonefield we did run a reindexing on production data. I don't remember any day that cause the application to fail due to missing indexes. Stonefield makes use of the proposed meta data standard DBCX, where info about the indexes is stored as extra data, so the knowledge about which indexes should exist is never lost.

There is a simpler solution, when you fear CDX header data and DBC data about indexes themselves getting lost: Have backups of DBC/DCT/DCX to restore the DBC itself and have backups of empty tables CDX files, restoring them and doing REINDEX is like recreating indexes via DELETE TAG and all necessary INDEX commands, too, because the empty tables CDX is the yet unpopulated index file.

Edit: If you don't have empty tables (as part of your project sources, for example) you can always recreate empty DBFs via GENDBC (or GENDBCX) tool to create a sql script for generating an empty database, or when you only have free table COPY TO some.DBF WITH CDX FOR .F.

Always do that in a healthy state of the tables and you have good info of what indexes should exist.

Bye, Olaf.


这篇关于重建FoxPro索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆