Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Collate - Index on Deleted() Tag DeletedTag Binary
Message
De
26/08/2005 14:11:43
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9
Database:
Visual FoxPro
Divers
Thread ID:
01044347
Message ID:
01044393
Vues:
16
>Fabio,
>
>Thanks for your attention...
>
>I agree with you (about a binary index does not have collated), but something is wrong with VFP (or with me :-) hehehe)...
>
>So, I created a little program to show what is happen here:
>
>
>Clear
>SYS(3054, 1)
>Set Deleted On
>
>Set Collate To "GENERAL"
>
>?
>? "I'm using a binary index - Collate: General"
>Create Table MyTest (MyId I, Name C (50))
>? Cpdbf(), CpCurrent()
>Index On Deleted() Tag DeletedTag Binary
>Index On MyId Tag MyIdTag
>Index On Name Tag NameTag
>Insert Into MyTest Values (1,"Joao Bernardo")
>Insert Into MyTest Values (2,"João Alberto")
>Insert Into MyTest Values (3,"Joao Gustavo")
>Select * From MyTest Where Name Like "J%" Order By Name
>Close Databases All
>Erase MyTest.dbf
>Erase MyTest.cdx
>
>?
>? "I'm not using a binary index - Collate: General"
>Create Table MyTest (MyId I, Name C (50))
>? Cpdbf(), CpCurrent()
>Index On MyId Tag MyIdTag
>Index On Name Tag NameTag
>Insert Into MyTest Values (1,"Joao Bernardo")
>Insert Into MyTest Values (2,"João Alberto")
>Insert Into MyTest Values (3,"Joao Gustavo")
>Select * From MyTest Where Name Like "J%" Order By Name
>Close Databases All
>Erase MyTest.dbf
>Erase MyTest.cdx
>
>
>Set Collate To "MACHINE"
>
>?
>? "I'm using a binary index - Collate: Machine"
>Create Table MyTest (MyId I, Name C (50))
>? Cpdbf(), CpCurrent()
>Index On Deleted() Tag DeletedTag Binary
>Index On MyId Tag MyIdTag
>Index On Name Tag NameTag
>Insert Into MyTest Values (1,"Joao Bernardo")
>Insert Into MyTest Values (2,"João Alberto")
>Insert Into MyTest Values (3,"Joao Gustavo")
>Select * From MyTest Where Name Like "J%" Order By Name
>Close Databases All
>Erase MyTest.dbf
>Erase MyTest.cdx
>
>?
>? "I'm not using a binary index - Collate: Machine"
>Create Table MyTest (MyId I, Name C (50))
>? Cpdbf(), CpCurrent()
>Index On MyId Tag MyIdTag
>Index On Name Tag NameTag
>Insert Into MyTest Values (1,"Joao Bernardo")
>Insert Into MyTest Values (2,"João Alberto")
>Insert Into MyTest Values (3,"Joao Gustavo")
>Select * From MyTest Where Name Like "J%" Order By Name
>Close Databases All
>Erase MyTest.dbf
>Erase MyTest.cdx
>
>
>If you run this code, you will see that just the third Select is FULL optimizated. The others is just PARCIAL.
>
>In my example, I have just 3 records, but in my real application I have a lot of them. And, beliave me, the time of my queries is up to 20 times slower if I add a BINARY index.
>
>Something is wrong... Because BINARY index is just MACHINE, but I need to add some GERERAL indexes in my app. Notice that the first and second results, I have the names ordered correctly (João Alberto, Joao Bernardo and Joao Gustavo), but if I use MACHINE collate (third and fourth selects), I get (Joao Bernardo, Joao Gustavo and João Alberto). In this case (3 records) it is ok, but in a real situation where a lot of users add informations, I need to put it in the right order.
>
>So, I concluded that a BINARY index has a collate too. For my bad luck, it is MACHINE! :-)
>
>Any suggestions?
>
>Thanks again!

Well:
1. CPXXX it points out the code page (the graphic symbol of the byte)
and it is not the COLLATE (order of the byte)
2. LIKE use COLLATE "MACHINE" only
Clear
SYS(3054, 1)

Set Deleted On
Close Databases All
CLOSE TABLES ALL

Set Collate To "GENERAL"

?
? "I'm using a binary index - Collate: General"
Create Table MyTest (MyId I, Name C (50))

Index On Deleted() Tag DeletedTag
Index On MyId Tag MyIdTag
Index On Name Tag NameMac COLLATE "Machine"
Index On Name Tag NameGen COLLATE "GENERAL"

Insert Into MyTest Values (1,"Joao Bernardo")
Insert Into MyTest Values (2,"João Alberto")
Insert Into MyTest Values (3,"Joao Gustavo")

Select * From MyTest Where Name Like "J%" AND myId=2 Order By Name

Select * From MyTest Where Name=="Joao Gustavo" AND myId=2 Order By Name

CLOSE TABLES ALL
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform