Temporary Indexes

Temporary Indexes

Postby Bayron » Mon Mar 04, 2013 9:49 am

Hi everyone,
I have never used CDX indexes, and I want to use them now...

How good will it be to use the TEMPORARY ( or MEMORY ) clause, on this indexes, since some say that there are problems with index file corruption some times???

Will this clause prevent this problems???

I am sure It may give me more speed if they are run in memory... Are they???
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: Temporary Indexes

Postby Enrico Maria Giordano » Mon Mar 04, 2013 11:24 am

I made some test in the past with TEMPORARY clause without noticed any speed differences.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Temporary Indexes

Postby MarcoBoschi » Mon Mar 04, 2013 12:36 pm

Read this
TEMPORARY
If this option is specified, a temporary index is created which is automatically destroyed when the index is closed. The temporary index may be created in memory only or in a temporary file. This lies in the responsibility of the RDD used for index creation.

My test in a LAN : non differences in elap time

Code: Select all  Expand view

ANNOUNCE RDDSYS

FUNCTION MAIN

USE i_201003
? seconds()
INDEX ON field->ref TAG REF TO marco
? seconds()

? seconds()
INDEX ON ref TAG REF TO marco temporary
? seconds()

RETURN NIL


               
INIT PROCEDURE RddInit
REQUEST DBFFPT
REQUEST DBFCDX
rddSetDefault( "DBFCDX" )
 

exactly the same time!
bye
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Temporary Indexes

Postby Maurizio » Mon Mar 04, 2013 3:18 pm

Marco

have you tried

INDEX ON ref TAG REF TO TEMP TEMPORARY ?



Maurizio
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Re: Temporary Indexes

Postby Enrico Maria Giordano » Mon Mar 04, 2013 3:20 pm

Maurizio wrote:Marco

have you tried

INDEX ON ref TAG REF TO TEMP TEMPORARY ?



Maurizio


Do you mean to remove FIELD from the key? I don't think it will make any difference.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Temporary Indexes

Postby Maurizio » Mon Mar 04, 2013 3:24 pm

Enrico

NO , change Marco with TEMP


INDEX ON field->ref TAG REF TO TEMP TEMPORARY ?
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Re: Temporary Indexes

Postby MarcoBoschi » Mon Mar 04, 2013 3:31 pm

Maurizio?
This test?

ANNOUNCE RDDSYS

FUNCTION MAIN


USE i_201003

GO TOP
? seconds()
INDEX ON ref TAG REF TO TEMP TEMPORARY
? seconds()


GO TOP
? seconds()
INDEX ON field->ref TAG REF TO marco
? seconds()


RETURN NIL



INIT PROCEDURE RddInit
REQUEST DBFFPT
REQUEST DBFCDX
rddSetDefault( "DBFCDX" )
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Temporary Indexes

Postby Maurizio » Mon Mar 04, 2013 4:23 pm

Marco

I remember reading that :

GO TOP
? seconds()
INDEX ON field->ref TAG REF TO TEMP TEMPORARY
? seconds()

This writes the file in PC memory

-----------------------------------------------------------------------

GO TOP
? seconds()
INDEX ON field->ref TAG REF TO marco TEMPORARY
? seconds()

This writes the file to hard disk
---------------------------------------------------------------------
Maurizio
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Re: Temporary Indexes

Postby Enrico Maria Giordano » Mon Mar 04, 2013 4:38 pm

TEMP or marco for the index filename does not make any difference. The TEMPORARY clause only makes the difference.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Temporary Indexes

Postby Bayron » Mon Mar 04, 2013 4:54 pm

I can imagine not making any difference in time, and even making everything a little slower, because of having to create indexes every time, but,

Can it make any difference in data consistency, and prevent data corruption????
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: Temporary Indexes

Postby Enrico Maria Giordano » Mon Mar 04, 2013 6:59 pm

Probably yes, but keep in mind that they are temporary indexes so you can't use them for the normal persistent indexes.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Temporary Indexes

Postby stefano » Mon Mar 04, 2013 9:57 pm

I’ve found an improvement using INDEX TEMP FOR … (xbrowse). Instead of SET FILTER... in LAN

Stefano
FWH 14.11 + xHarbour + bcc582
stefano
 
Posts: 80
Joined: Tue Mar 25, 2008 9:03 pm
Location: ITALIA

Re: Temporary Indexes

Postby Rick Lipkin » Tue Mar 05, 2013 2:20 pm

Bayron

I have never used the TEMP option .. I kinda like to know where my files are being created, their names either .idx or .cdx.

Please consider this code ..

Code: Select all  Expand view


// this needs to be in your main.prg
REQUEST DBFCDX
rddsetdefault( "DBFCDX" )


Local FundDbf,dbf_stru

// create a temp file name off the root of the Default Folder

xVol := set(7)

DO WHILE .T.

   FundDbf := "TEMP"+(SUBSTR(TIME(),7,2)+SUBSTR(TIME(),4,2))+".DBF"
   IF .not. FILE( xVOL+"\DBTMP\"+FUNDDBF )
      EXIT
   ENDIF

ENDDO

DBF_STRU := { }
AADD( DBF_STRU, { "
DESC",     "C",  40, 0 } )
AADD( DBF_STRU, { "
AMOUNT",   "N",  8,  2 } )
AADD( DBF_STRU, { "
FUNDED",   "N",  8,  2 } )
AADD( DBF_STRU, { "
BOX",      "N",  2,  0 } )
AADD( DBF_STRU, { "
CLASCODE", "C",  10, 0 } )

DBCREATE( xVOL+"
\DBTMP\"+FUNDDBF, DBF_STRU )

SELECT 9
Use ( xVOL+"
\DBTMP\"+FUNDDBF ) via "DBFCDX" EXCL
      Index on ClasCode Tag ClasCode        // creates .cdx of the same database name
ELSE
   CLose Databases
   RETURN(.F.)
ENDIF

..
do your own data processing here
..

Close Databases
Ferase( "
Tempxxxx.Dbf" )
Ferase( "
Tempxxxx.Cdx" )

 


Note that if you use .cdx the name of the file is created for you ( same name as the .dbf) with a .cdx extention. If you use .Idx .. you have to create a separate index name for each index .. .cdx is the way to go because you can build multiple ( tags ) indexes into the same .cdx.

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Temporary Indexes

Postby Enrico Maria Giordano » Tue Mar 05, 2013 2:26 pm

TEMP is not an option, it's a filename.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Temporary Indexes

Postby Bayron » Tue Mar 05, 2013 3:44 pm

Thanks all for your comments...

I think that as Enrico said, Temporary indexes are good, but not for all situations...

My program does not use quite extensive Indexed databases... so I think I will go with creating permanent Indexes once per day, per week or so...

This kind of threads help us all to understand some attributes of FiveWin//(x)Harbour...

Thanks again...
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests