Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Verify whether Locate is optimized
Tue, Dec 5 2006 12:38 PMPermanent Link

"Bill Root"
What's the best way to verify, in code, whether a Locate call will be or  
was optimized?  By optimized I mean whether an index was used or whether a  
brute-force search was performed.

I have a function used in many locations for many tables and I would like  
to verify that the Locate used is as fast as possible.

Finest regards,
Bill Root
Tue, Dec 5 2006 4:07 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Bill,

<< What's the best way to verify, in code, whether a Locate call will be or
was optimized?  By optimized I mean whether an index was used or whether a
brute-force search was performed. >>

There really is no way currently.  You simply have to ensure that you have
an index available that can perform the search.  If you don't, then the
search will most likely be slow enough that it is noticeable that it isn't
using an index.

The alternative is to simply use FindKey to always ensure that you're using
an index.

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Dec 6 2006 9:11 AMPermanent Link

"Bill Root"
Tim,

<< There really is no way currently.  You simply have to ensure that you  
have an index available that can perform the search.  If you don't, then  
the search will most likely be slow enough that it is noticeable that it  
isn't using an index.

The alternative is to simply use FindKey to always ensure that you're  
using an index.>>


Thank you for the quick answer.  Using FindKey requires knowing which  
index(es) to use.  Since Locate already knows how to choose the  
appropriate index(es), it's easier to use.  I think the ability to  
determine whether a Locate call was optimized would be a good defensive  
programming tool.  It may be worth considering for future releases.

Finest regards,
Bill Root
Wed, Dec 6 2006 4:07 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Bill,

<< Thank you for the quick answer.  Using FindKey requires knowing which
index(es) to use.  Since Locate already knows how to choose the
appropriate index(es), it's easier to use. >>

I understand, but my point was that you've got a chicken and egg issue when
it comes to ad-hoc searching.  If you know what the Locate will be searching
on, then you know which indexes need to be available.  However, if you don't
know what the Locate will be searching on, then you can't possibly know
which indexes will be needed, and having DBISAM tell you is a bit too late
at that point.

<< I think the ability to determine whether a Locate call was optimized
would be a good defensive programming tool.  It may be worth considering for
future releases. >>

I agree.  I'll add it to the list.

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Dec 7 2006 10:06 AMPermanent Link

"Robert"

"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message
news:0676E9E0-A0A6-43FA-B303-E11CEFC6AED3@news.elevatesoft.com...
>
> I understand, but my point was that you've got a chicken and egg issue
> when it comes to ad-hoc searching.  If you know what the Locate will be
> searching on, then you know which indexes need to be available.

On a multi-field index, will locate use as much of the index as possible the
if not all key fields are used in the locate? IOW, if the index is F1 + f2 +
f3 and I do a locate using F1 and F2, will it go directly to the lowest F3?

Robert

Thu, Dec 7 2006 4:11 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Robert,

<< On a multi-field index, will locate use as much of the index as possible
the if not all key fields are used in the locate? IOW, if the index is F1 +
f2 + f3 and I do a locate using F1 and F2, will it go directly to the lowest
F3? >>

Yes.  It behaves just like a FindKey on a partial set of fields if it can
use an index.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image