| Subject |
Re: unable to create index on .dbf having 30 fields and 100000 |
| From |
Mervyn Bick <invalid@invalid.invalid> |
| Date |
Thu, 2 Sep 2021 08:32:24 +0200 |
| Newsgroups |
dbase.getting-started |
On 2021/09/02 05:31, Milind Nighojkar wrote:
> Hi Mevink,
> Thanks
>
> I used your hint
> use tablename exclusive
> index on .... tag tagname
>
> it worked.....
>
>
> Just to mention expression used is ltrim(rtrim(field1))+ltrim(rtrim(INV(field2)) which has length of around 40 chracters.
>
No! No! No! :-) NEVER use trim in an index expression unless you then
pad the index key to a fixed length. Using unequal key lengths is
asking for trouble. There is a warning in the help file against doing
this.
If you simply want to order the records use field1+field2 provided the
total length of field1+field2 is <= 100.
If you are going to use the index to locate specific records there is an
alternative.
Let's assume field1 is firstname and field2 is lastname. If you want to
use oRef.findKey() or SEEK to find the record for John Smith then you
will need something like the following if you've used field1+field2
cSearch = "John Smith "
seek cSearch or oRef.findKey(cSearch)
If you index on field1-field2 dBASE moves all the spaces to the right
hand end of the index key which becomes "JohnSmith
"
Now you can use cSearch = "JohnSmith" to find the record.
There are ways to shorten the index key and thereby reduce the size of
the index file but they neither speed up making the index nor searching
the table. They do, however, open up the possibility of problems so,
quite frankly, they are not worth considering UNLESS they are used to
keep the index key to less than the allowable 100 characters.
> YOu asked how much time did I wait...Actually I waited for 10 minutes when Dbase stopped its response. Then I have to kill the Dbase session . After restarting Dbase suprisingly index was available.
10 minutes probably means that dBASE somehow managed to get into a loop.
This could quite possibly have been caused by using unequal key
lengths. The index that was available when dBASE was restarted should
definitely not be used.
Even though index on .... tag tagname worked you should not rely on the
index until you have remade it using either field1+field2 or field1-field2.
Mervyn.
|
|