Subject Re: SLOW OPENING MDX FILE
From Mervyn Bick <invalid@invalid.invalid>
Date Fri, 23 Feb 2018 17:09:49 +0200
Newsgroups dbase.getting-started

On 2018-02-23 3:17 PM, Ed Furche wrote:

> Sorry about the caps. I have been chastised before about this.
> Answers:
> I haven't packed in a while.
> See the mdx's below:
> Production MDX file: WO.MDX
......
>            Index TAG: WO  Key: WONO......
>            Index TAG: WONAME  Key: RTRIM(TECH)+WONO
>            Index TAG: WOOPENTECH  Key: OPEN+RTRIM(TECH)
......
>            Index TAG: WOOPENNAME  Key: OPEN+RTRIM(TECH)+CUSTNAME1

>
> i am trying to use the WO mdx whjich is on one field only (9 chars).
> Windows 7    dbase 2.8  16000 recs
> If i just go to command prompt and say:
>    Use WO
>    Set order to WO
> The prompt comes back immediately.
> It is just in this one WFM that it is slow.  I ran a debug
> and it literally stops for 15-20 seconds when i address the WO MDX.


Using RTRIM() or LTRIM() in an index expression is an absolute NO-NO.

All the entries in the index must be the same length otherwise there is
a very real danger of corrupting the index.  I wouldn't expect the
WONAME index to upset the WO index but as they both use the WONO field
it is not beyond the bounds of possibility.  Mysterious things happen
when you get into the BDE. :-)

If you are using the indexes only to order the rowsets simply get rid of
the RTRIM() functions.  The rows will still be in the same order.

If you are using the indexes to implement SEEKs then use - instead of +
to link the fields.   Using - moves all trailing spaces to the righthand
end of the index expression.  Your existing search strings should,
therefore, still work provided OPEN is a single Y/N character.  If OPEN
is more than a single character I'm afraid you're going to have to find
all your SEEKs and fix the search strings.

For the WOOPENTECH index simply removing the RTRIM() should do the trick.

Rather than simply changing the index expression it would probably be
better to delete the .mdx file and rebuild it from scratch.

First off, backup both the .dbf amd .mdx files and the .dbt file if
there is a memo field in your table.

If you don't have a program which creates your indexes from scratch (i.e
rather than just reindexing) then you need to build one.  In the Command
Panel run the following command

do :duflp:cretable7 with 'wo.dbf'

This will create a file cretable.txt   Open this in the sourcecode
editor and get rid of the code which creates the table.  Not strictly
necessary as the code won't run if the table exists but it's just
cluttering up the file so delete it anyway.

Fix the dodgy index expressions and use "Save As" to save the code as a
.prg file.


Delete wo.mdx   As the index files don't show in the Navigator use the
underlying operating system command  in the Command Panel   !del wo.mdx
(This is much quicker than using the Windows File Explorer. :-) )

Open wo.dbf.  dBASE will complain that the .mdx is missing.  Select
"Open and Detach" from the options.  Close the table and run the
indexing program.

If the problem persists after all that I really don't know what else you
can try.

Mervyn.