Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select speed question
Message
From
25/12/2004 04:39:29
 
 
To
24/12/2004 20:11:45
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00971916
Message ID:
00972126
Views:
20
>Hi Robert,
>
>As Sergey pointed out, the query is not optimized when SET ANSI is OFF. It is a BUG, the STR() function is mistakenly treated as a function returning result of variable length. VFP9 doesn't use indexes on variable length expressions to optimize inexact equal conditions (SET ANSI OFF). They were used in previous versions and the result could be wrong.
>
>To make query optimizable, you can SET ANSI ON or use PADR function.
>
>
>select Lit_LosFK, Lit_Date ;
>   from LOSSITEM ;
>   where str(Lit_LosFK, 6) + dtos(Lit_Date) in ;
>      (select PADR(str(Lit_LosFK, 6),6) + min(dtos(Lit_Date)) from LOSSITEM group by Lit_LosFK) ;
>   group by 1, 2 ;
>   into cursor curFIRSTLOSSPAYMENT1 nofilter
>
>
>
>Thanks,
>Aleksey.
>

Hi Aleksey,

if VFP9 don't optimize STR(), it is not a bug, it is correct.
Of course, with current index routines, VFP8 and VFP9b can return wrong results when you use a STR().

On next example, STR() blank zero numbers.
CREATE CURSOR CONTDB (cField C(10),iField I,lField L, dField D)

INSERT INTO CONTDB VALUES ('',1,.t.,DATE())
INSERT INTO CONTDB VALUES ('',0,.f.,DATE())
INSERT INTO CONTDB VALUES ('VOSS',3,.t.,DATE())
INSERT INTO CONTDB VALUES ('VOSS1',2,.f.,DATE())
INDEX ON STR(iField,iField) TAG TT

SET EXACT OFF
CLEAR

COUNT FOR STR(iField,iField)='VOSS'
? _TALLY

SET ORDER TO 
   COUNT FOR STR(iField,iField)='VOSS'

? _TALLY
COUNT NOOPTIMIZE FOR 'VOSS'=STR(iField,iField)
? _TALLY

SET ANSI OFF

=SYS(3054,11)
SELECT COUNT(*) FROM CONTDB WHERE 'VOSS' =  STR(iField,iField) INTO ARRAY xxx
? xxx
SELECT COUNT(*) FROM CONTDB WHERE STR(iField,iField)  = 'VOSS' INTO ARRAY xxx
? xxx
Fabio
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform