Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rushmore, don't get it
Message
From
22/04/2005 03:35:31
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
21/04/2005 10:45:43
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01006860
Message ID:
01007377
Views:
12
>>>I've come across something peculiar re RushMore.
>>>
>>>Basically, it's as if it were not seeing some index entries
>>>
>>>I've nailed it down to a simple test, but in real life, a select would return eg 64 records where it should return eg 108
>>>
>>>The only way around I've found so far is to not use the index expression, use (j_ref = 0) instead of (bintoc(j_ref) == bintoc(0))
>>>
>>>Disabling Rushmore gives correct results in both locate and scan, but not in select sql
>>>
>>>I'd like to (1) understand what is going on and (2) find a way around it and use the index expr
>>>
>>>
>>>function Do_It()
>>>	
>>>	
>>>	set ansi on
>>>	set exact on
>>>	set collate to 'machine'
>>>	set optimize on
>>>	
>>>	create cursor CursorTest ;
>>>		( 	j_ref		I ;
>>>		)
>>>	
>>>	insert into CursorTest values(44 )
>>>	insert into CursorTest values( 0 )
>>>	insert into CursorTest values(44 )
>>>
>>>	index on bintoc(j_ref) tag j_ref
>>>
>>>	?'-------------------------------------'
>>>	
>>>	locate for (bintoc(j_ref) == bintoc(0))
>>>	?'optimize locate 0 (TRUE)', found(), '  ERROR'
>>>
>>>	locate for (bintoc(j_ref) == bintoc(0)) NOOPTIMIZE
>>>	?'no optimize locate 0 (TRUE)', found(), ' OK'
>>>	
>>>	local aa[1]
>>>	aa[1] = 0
>>>	
>>>	select count(*) ;
>>>		from CursorTest ;
>>>		into array aa ;
>>>		where (bintoc(j_ref) == bintoc(0))
>>>	
>>>	?'optimize count 0 (1):', aa[1], ' ERROR'
>>>	
>>>	set optimize off
>>>	select count(*) ;
>>>		from CursorTest ;
>>>		into array aa ;
>>>		where (bintoc(j_ref) == bintoc(0))
>>>	set optimize on
>>>	
>>>	?'no optimize count 0 (1):', aa[1], aa[1], ' ERROR'
>>>	
>>>	
>>>	locate for (bintoc(j_ref) == bintoc(44))
>>>	?'optimize locate 44 (TRUE), recno 1:', found(), 'OK ', recno()
>>>	
>>>	insert into CursorTest  values( 0 )
>>>	locate for (bintoc(j_ref) == bintoc(0))
>>>	?'optimize locate 0 (TRUE), recno 2:', found(), recno(), 'ERROR'
>>>	
>>>
>>>endfunc
>>>
>>
>>Gregory,
>>I think this is a known issue. Try testing moving index creation before inserts.
>>Cetin
>
>Cetin,
>
>I moved the index on ... before the inserts and all was well .... until I tested with views where I moved the creation to the front as well
>
>The following code excerpt still gives problems, and I cannot move the index creation further to the front
>
>
>JournaalSubsetLaLike_year	= m._year
>JournaalSubsetLaLike_DateFrom	= {^0001/01/01}
>JournaalSubsetLaLike_DateTo	= {^9999/12/31}
>JournaalSubsetLaLike_la		= m._la_like
>
>if( !used(m.CursorName) )
>	use JournaalSubsetLaLike in 0 alias (m.CursorName) NODATA
>	select (m.CursorName)
>	index on bintoc(j_ref) tag j_ref && optimze bug (bintoc(j_ref) == bintoc(0))
>	index on dtos(j_date) tag j_date
>	index on j_la_id tag j_la_id
>	set order to
>endif
>
>select(m.CursorName)
>=requery()
>
>
>but this modified code works
>
>JournaalSubsetLaLike_year	= m._year
>JournaalSubsetLaLike_DateFrom	= {^0001/01/01}
>JournaalSubsetLaLike_DateTo	= {^9999/12/31}
>JournaalSubsetLaLike_la		= m._la_like
>
>CursorTmp = NewCursorName()
>use JournaalSubsetLaLike in 0 alias (m.CursorTmp)
>if( !used(m.CursorName) )
>	select (m.CursorTmp)
>	=CreateCursor(m.CursorName)  && routine to create a cursor based on the selected alias
>	select (m.CursorName)
>	index on bintoc(j_ref) tag j_ref && optimze bug (bintoc(j_ref) == bintoc(0))
>	index on dtos(j_date) tag j_date
>	index on j_la_id tag j_la_id
>	set order to
>endif
>=ZapCursor(m.CursorName)  && zapz
>=CopyAlias(m.CursorTmp, m.CursorName)  && something like append from dbf(m.AliasFrom) for !deleted()
>
Gregory,
Views:) This solution is similar to the one I sent to Fabio. There I also said I wouldn't use bintoc() alone to index a cursor. David also suggested not to do.
Whereever I have bintoc() it's a composite index, otherwise I prefer directly indexing on integer and never had a problem.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform