Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rushmore & BROWSE vs SQL SELECT

Status
Not open for further replies.

StewartUK

Programmer
Feb 19, 2001
860
0
0
GB
Using VFP9 SP1

I'm confused. I have an index on a table where the expression is
Code:
TRIM(AREA)+TRIM(DISTRICT)+" "+TRIM(SECTOR)+TRIM(GROUPING)

When I execute browse statement as follows:
Code:
BROWSE LAST FOR TRIM(AREA)+TRIM(DISTRICT)+" "+TRIM(SECTOR)+TRIM(GROUPING) = [BN12 6AY]
the data appears instantly.

When I run a SQL SELECT like this:
Code:
SELECT PKEY,LINE1 FROM ADDRESS WHERE TRIM(AREA)+TRIM(DISTRICT)+" "+TRIM(SECTOR)+TRIM(GROUPING) = [BN12 6AY]
it takes over 2½ seconds.

Why the difference? Is there some way I can use the index with a SQL statement?

Thanks,

Stewart
 
Geoff,

Er, if we're looking at the same thing, the first query is actually a BROWSE.

Stewart
 
Hi Geoff,

Thanks. Well the BROWSE & SELECT above only shows/finds 3 records, but FWIW the cursor moves down instantly in the BROWSE.

I have the same issue using index expression TRIM(AREA)+DISTRICT which shows/finds 202 results. In the browse window, Ctrl+End gets me the last record almost instantly.

Stewart
 
One other thing: index expressions must evaluate to a consistent length so VFP will pad any expression using Trim(). That index may not be getting you what you think.

It's not a good idea to use Trim() in index expressions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top