Mike Yearwood
Toronto, Ontario, Canada
General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Hi Alan
Actually, It's been proven that it's much faster to append 10,000 records and then index them than it is to append the 10,000 records with the indexes in place.
LOCAL m.lcSetSafety
m.lcSetSafety = SET("SAFETY")
SET SAFETY OFF
LOCAL ;
m.lnA,;
m.lnI
CREATE CURSOR test4 (cField1 c(10))
m.lnA=SECONDS()
FOR m.lnI = 1 TO 10000
INSERT INTO test4 FROM MEMVAR
ENDFOR
INDEX ON cField1 TAG cField1
?SECONDS()-m.lnA
CREATE CURSOR test4 (cField1 c(10))
INDEX ON cField1 TAG cField1
m.lnA=SECONDS()
FOR m.lnI = 1 TO 10000
INSERT INTO test4 FROM MEMVAR
ENDFOR
?SECONDS()-m.lnA
SET SAFETY &lcSetSafety
However, since we're talking views here, the problem is more one of when to build the indexes. For one, if the buffers have been dirtied, you'd have to clean them before you could index.
>>>I always just make sure I open them with NODATAONLOAD = .T., index them empty, and then requery after the indexing is complete.
>>>
>>>Alan
>>
>>Could you explain why this approach is better?
>>Thanks
>>Kamil
>
>Only because it's a lot faster to index 0 items than to index 10,000 items.
>
>Alan
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only