FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Temporary Indexes
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Temporary Indexes
Posted: Mon Mar 04, 2013 09: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
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Temporary Indexes
Posted: Mon Mar 04, 2013 11:24 AM

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

EMG

Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Temporary Indexes
Posted: 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 (fw): Select all Collapse
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
Marco Boschi
info@marcoboschi.it
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: Temporary Indexes
Posted: Mon Mar 04, 2013 03:18 PM

Marco

have you tried

INDEX ON ref TAG REF TO TEMP TEMPORARY ?

Maurizio

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Temporary Indexes
Posted: Mon Mar 04, 2013 03: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
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: Temporary Indexes
Posted: Mon Mar 04, 2013 03:24 PM

Enrico

NO , change Marco with TEMP

INDEX ON field->ref TAG REF TO TEMP TEMPORARY ?

Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Temporary Indexes
Posted: Mon Mar 04, 2013 03: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" )

Marco Boschi
info@marcoboschi.it
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: Temporary Indexes
Posted: Mon Mar 04, 2013 04: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

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Temporary Indexes
Posted: Mon Mar 04, 2013 04:38 PM

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

EMG

Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: Temporary Indexes
Posted: Mon Mar 04, 2013 04: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
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Temporary Indexes
Posted: Mon Mar 04, 2013 06: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
Posts: 80
Joined: Tue Mar 25, 2008 09:03 PM
Re: Temporary Indexes
Posted: Mon Mar 04, 2013 09:57 PM
I’ve found an improvement using INDEX TEMP FOR … (xbrowse). Instead of SET FILTER... in LAN

Stefano
FWH 14.11 + xHarbour + bcc582
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Temporary Indexes
Posted: Tue Mar 05, 2013 02: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 (fw): Select all Collapse
// 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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Temporary Indexes
Posted: Tue Mar 05, 2013 02:26 PM

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

EMG

Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: Temporary Indexes
Posted: Tue Mar 05, 2013 03: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
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...