REQUEST DBFCDX
FUNCTION MAIN()
LOCAL nSec, nKey
RDDSETDEFAULT( "DBFCDX" )
IF !FILE( "CORSE.CDX" )
USE CORSE
INDEX ON DTOS( FIELD -> data ) + UPPER( FIELD -> cliente ) TO CORSE
CLOSE
ENDIF
USE CORSE INDEX CORSE
SET FILTER TO FIELD -> cliente = "A"
nSec = SECONDS()
nKey = ORDKEYCOUNT()
? SECONDS() - nSec, nKey
CLOSE
RETURN NIL
0.00 910404
2.20 58776
SET FILTER TO FIELD -> cliente = "A"
nageswaragunupudi wrote:If there is an index on CLIENTE then SET FILTER TO CLIENTE = "A" can be fully optimized.
If there is an index on UPPER(CLIENTE) then SET FILTER TO UPPER(CLIENTE) = 'A' can be fully optimized.
nageswaragunupudi wrote:If there is an index on CLIENTE then SET FILTER TO CLIENTE = "A" can be fully optimized.
If there is an index on UPPER(CLIENTE) then SET FILTER TO UPPER(CLIENTE) = 'A' can be fully optimized.
REQUEST DBFCDX
FUNCTION MAIN()
LOCAL nSec, nKey
RDDSETDEFAULT( "DBFCDX" )
IF !FILE( "CORSE.CDX" )
USE CORSE
INDEX ON UPPER( FIELD -> cliente ) TO CORSE
CLOSE
ENDIF
USE CORSE INDEX CORSE
nSec = SECONDS()
SET FILTER TO UPPER( FIELD -> cliente ) = "A"
nKey = ORDKEYCOUNT()
? SECONDS() - nSec, nKey
CLOSE
RETURN NIL
James Bott wrote:Consider:
Assuming there is an index on client, then this should be optimized:
set filter to client ="A" .or. client="M"
And I don't think you can do this with scopes.
You want your user to search on any fields and combinations.
REQUEST DBFCDX
FUNCTION MAIN()
FIELD CLIENTE
LOCAL nSec, nKey
RDDSETDEFAULT( "DBFCDX" )
FERASE( "CORSE.CDX" )
USE CORSE EXCLUSIVE
INDEX ON UPPER(CLIENTE) TAG CLIENTE
INDEX ON DELETED() TAG DELETED
CLOSE
USE CORSE SHARED
nSec = SECONDS()
SET FILTER TO UPPER(CLIENTE) = "A" .AND. !DELETED()
nKey = ORDKEYCOUNT()
? SECONDS() - nSec, nKey
CLOSE
RETURN NIL
James Bott wrote:Agreed, but I don't see any logical way you can search for any combination of fields in a filter without reading all the records for at least some of the combinations.
nageswaragunupudi wrote:Will you kindly try this sample as it is without changes?
2.20 58776
1.84 58776
REQUEST DBFCDX
FUNCTION MAIN()
LOCAL nSec, nKey
RDDSETDEFAULT( "DBFCDX" )
IF !FILE( "CORSE.CDX" )
USE CORSE
INDEX ON UPPER( FIELD -> cliente ) TO CORSE
CLOSE
ENDIF
USE CORSE INDEX CORSE
SET ORDER TO 0
nSec = SECONDS()
SET FILTER TO UPPER( FIELD -> cliente ) = "A"
nKey = ORDKEYCOUNT()
? SECONDS() - nSec, nKey
CLOSE
RETURN NIL
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 53 guests