FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour ADS Índice Composto ( SOLUCIONADO )
Posts: 1286
Joined: Mon Feb 25, 2008 02:54 PM
ADS Índice Composto ( SOLUCIONADO )
Posted: Mon Jun 06, 2016 04:52 PM

Amigos,

referente:
INDEX ON str(filial,2)+str(cliente,6) to ...

Exemplo:

Utilizando ADS - Funciona perfeitamente :)
nContaRegistros := 0
clientes->( dbsetorder(1), dbseek( str(nFilial,2)+str(nCliente,6) ) )
do while clientes->filial = nFilial .and. clientes->codigo = nCliente .and. clientes->(!eof())
nContaRegistros ++
clientes->(dbskip())
enddo
? nContaRegistros // total 423 :)


Utilizando ADS - Não funciona :(
nContaRegistros := 0
clientes->( dbsetorder(1), dbseek( str(nFilial,2) ) )
do while clientes->filial = nFilial .and. clientes->(!eof())
nContaRegistros ++
clientes->(dbskip())
enddo
? nContaRegistros // total 5 :(

O ADS só permite trabalhar com índice composto integral ???
Existe alguma saída para isso?

obrigado

ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: ADS Índice Composto
Posted: Mon Jun 06, 2016 06:22 PM
No caso do ADS, não seria:

Code (fw): Select all Collapse
CREATE INDEX ??
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 694
Joined: Fri Oct 07, 2005 06:58 AM
Re: ADS Índice Composto
Posted: Tue Jun 07, 2016 04:20 PM
Falta en el Dbseek un ".T."


Code (fw): Select all Collapse
Utilizando ADS - Não funciona :( 
nContaRegistros := 0
clientes->( dbsetorder(1), dbseek( str(nFilial,2), .T. ) )
do while clientes->filial = nFilial .and. clientes->(!eof())
nContaRegistros ++
clientes->(dbskip())
enddo
? nContaRegistros // total 5  :(
Un saludo

Fernando González Diez

ALSIS Sistemas Informáticos
Posts: 1286
Joined: Mon Feb 25, 2008 02:54 PM
Re: ADS Índice Composto
Posted: Tue Jun 07, 2016 07:32 PM

Obrigado a todos,

segue a solução:

http://devzone.advantagedatabase.com/dz ... 31204-1609

Title:
Slow Performance, Unexpected Sort Order, Incorrect SQL Results After Converting From DBF to ADT Tables
Problem Description:
With DBF format tables creating a multi-segmented index is done with the plus ( + ) operator. A multi-segmented index expression would look like this: Field1 + Field2 + Field3. If this type of index expression is used in an ADT table there are potential performance issues, as well as a possibility for unexpected sort order results.

In version 6.x the performance issue is a result of the Advantage Server incorrectly using the multi-segmented index which contains the plus operator. In version 7.0 the Advantage Server was changed such that indexes with the plus operator were ignored. In either case performance is adversely affected.

The incorrect sort order problem is due to the fact that if one field in a multi-segmented index is NULL, the entire index key will evaluate to null. The null key can also cause problems for queries as the index would be used to to optimize a search.
Solution:
The solution to these problems is to change the operator used to create the multi-segmented index from the plus ( + ) operator to the semicolon ( ; ) operator. Using the semicolon operator will avoid all the problems mentioned above.

ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin

Continue the discussion