Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Slow Append From
Message
From
21/08/2000 05:33:19
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00406836
Message ID:
00407223
Views:
33
>>>Hi all
>>>
>>>I got 2 .txt file with information delimited with ";" to append in 2 table.
>>>I use append from to append the information but it's not to fast I think
>>>
>>>For the fisrt table 492 record are append and for the second one 3635 record are append it take arround 26 second for both tables.
>>>
>>>Is it me or it's not very fast.
>>>How can I speed or what can slow done the "append from "
>>>
>>>
>>>Thanks and have a nice week end
>>>
>>>
>>>Benoit
>>
>>
Benoit,
>>Append from is fast and 26 seconds is not acceptable for such little reccounts (-unless it's a pentium-kidding:).
>>If there are too many indexes it slows down the append for they should be updated. Create a routine that would remove indexes and put back after append.
>>Cetin
>
>Hi Cetin
>When you say remove index do you mean somting like
>select("client")
>set order to 0
>or open my table without index make the append from end reopen teh table with index.
>
>Thanks
>
>Benoit


Benoit,
What I meant is to delete tags. If index is structural, no filter on primary key and primary key is not descending than a routine like this works (test in a copy dir) :
USE myTable excl
SaveIndexes('crsTagInfo') && Current index info is saved to a cursor
SET safe off
Delete tag all    && All tags removed
SET safe on
* Append from ....
RestoreIndexes('crsTagInfo') && Restore indexes from cursor
USE in 'crsTagInfo'

FUNCTION SaveIndexes
LPARAMETERS tcTagInfoCursor
LOCAL lcAlias,ix
lcAlias = alias()
CREATE cursor (tcTagInfoCursor) (tagname c(10), ndxexpr m, filterexpr m, descending l, type c(1))
SELECT (lcAlias)
FOR ix = 1 to tagcount()
  INSERT into (tcTagInfoCursor) values ;
    (tag(ix,lcAlias), ;
    key(ix,lcAlias),;
    sys(2021,ix,lcAlias),;
    descending(ix,lcAlias),;
    iif(primary(ix,lcAlias),'P',;
    iif(candidate(ix,lcAlias),'C',;
    iif(unique(ix,lcAlias),'U','R'))) )
ENDFOR

FUNCTION RestoreIndexes
LPARAMETERS tcTagInfoCursor
LOCAL lcAlias,ix
lcAlias = alias()
SELECT * from (tcTagInfoCursor) into array arrTagInfo
SELECT (lcAlias)
FOR ix = 1 to alen(arrTagInfo,1)
  IF arrTagInfo[ix,5] = 'P'
    ALTER table (lcAlias) ;
      add primary key &arrTagInfo[ix,2] tag (trim(arrTagInfo[ix,1]))
  ELSE
    lcFilter = iif(!empty(arrTagInfo[ix,3]),' for ','')+arrTagInfo[ix,3]
    lcDesc = iif(arrTagInfo[ix,4],' DESCENDING ','')
    lcUnique = iif(arrTagInfo[ix,5] = 'U', 'Unique', ;
      iif(arrTagInfo[ix,5] = 'C', 'Candidate', ''))
    INDEX on &arrTagInfo[ix,2] tag (trim(arrTagInfo[ix,1])) ;
      &lcFilter &lcDesc &lcUnique
  ENDIF
ENDFOR
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