ADS Índice Composto ( SOLUCIONADO )

Post Reply
MGA
Posts: 1219
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá
Contact:

ADS Índice Composto ( SOLUCIONADO )

Post by MGA »

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
Last edited by MGA on Tue Jun 07, 2016 9:16 pm, edited 1 time in total.
ubiratanmga@gmail.com

FWH17.04
FWPPC
Harbour/xHarbour
xMate
Pelles´C
TDolphin
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: ADS Índice Composto

Post by karinha »

No caso do ADS, não seria:

Code: Select all

CREATE INDEX ??
 
João Santos - São Paulo - Brasil
User avatar
fgondi
Posts: 636
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España
Contact:

Re: ADS Índice Composto

Post by fgondi »

Falta en el Dbseek un ".T."

Code: Select all

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 GHE Sistemas Informáticos
MGA
Posts: 1219
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá
Contact:

Re: ADS Índice Composto

Post by MGA »

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

FWH17.04
FWPPC
Harbour/xHarbour
xMate
Pelles´C
TDolphin
Post Reply