Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: tushar Kanvinde
  Where is tushar Kanvinde?
 Kolhapur, Maharastra
 India
 tushar Kanvinde
 To: Samir H.
  Where is Samir H.?
 Yogyakarta
 Indonesia
 Samir H.
 Tags
Subject: RE: Composed Index as primary key?
Thread ID: 268913 Message ID: 268955 # Views: 28 # Ratings: 0
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Thursday, July 15, 2010 4:02:29 PM         
   


> >
> > Composite indexes' usefulness in VFP is debatable. In specific cases yes they are useful but for the case you presented I don't see a usefulness especially if you create the key with that subject+student+semester order. Probably to benefit from it you would have combinations like student+subject+semester, student+semester+subject ... ending in 6 different indexes maybe.
> >
> > What does help mean there is you could reduce the size of integer used. An integer is an 32 bits/4 bytes value. If say your student ID would be a maximum of 32767 then it fits into 2 bytes you can use 2 as size flag (bintoc(studentID,'2RS')). Or subject with a maximum of 127 would fit to a 1 byte and you could use bintoc(subjectID,'1S'). R and S are not of much important here, but note that VFP only uses unsigned portion (single byte is up to 127 not 255, it is actually -128 to 127). But before doing such space savings think twice. You may be good with 127 subjects today but if you need the 128th then you are in trouble (reminds me space saving for year 2000).
> >
> > Cetin Basoz
> >
> > .Net has got better.Think about moving - check my blog:
> > Blog (main)
> > Blog (mirror)
>
> Thank you for taking time to explain.
> Why should I use all possible combinations? I always have those 3 values, which I then would (did already) put in a expression:
>
> nSubj=cursor1.subj_id 
> nStud=cursor2.stud_id
> nSemester=combo.value
> cIndexExpr=bintoc(nSubj)+ bintoc(nStud)+ bintoc(nSemester)  && I do define the order here, isn't it?
> =seek(cIndexExpr)

> Without this composite index, I'll have to get back to my SCAN & LOCATE...
>
> Regards
> Samir

As Cetin says, remembering composite indexes can be a pain. To help you, you can check out https://www.foxite.com/downloads/default.aspx?id=160. Actually I have decreased the usage of composite indexes to a large extent.

Regards
Tushar

ENTIRE THREAD

Composed Index as primary key? Posted by Samir H. @ 7/15/2010 11:26:26 AM
RE: Composed Index as primary key? Posted by Cetin Basoz @ 7/15/2010 12:34:34 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/15/2010 1:21:52 PM
RE: Composed Index as primary key? Posted by Cetin Basoz @ 7/15/2010 2:19:09 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/15/2010 2:40:10 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/15/2010 2:03:14 PM
RE: Composed Index as primary key? Posted by tushar @ 7/15/2010 2:16:13 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/15/2010 2:38:39 PM
RE: Composed Index as primary key? Posted by tushar @ 7/15/2010 3:44:03 PM
RE: Composed Index as primary key? Posted by Cetin Basoz @ 7/15/2010 2:35:00 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/15/2010 2:49:40 PM
RE: Composed Index as primary key? Posted by Cetin Basoz @ 7/15/2010 3:45:23 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/15/2010 4:01:37 PM
RE: Composed Index as primary key? Posted by Mike Yearwood @ 7/15/2010 8:21:47 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/16/2010 4:48:41 AM
RE: Composed Index as primary key? Posted by Mike Yearwood @ 7/16/2010 6:07:24 AM
RE: Composed Index as primary key? Posted by Samir H. @ 7/16/2010 6:16:14 AM
RE: Composed Index as primary key? Posted by Cetin Basoz @ 7/16/2010 1:12:42 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/16/2010 1:23:51 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/16/2010 1:46:54 PM
RE: Composed Index as primary key? Posted by tushar @ 7/15/2010 4:02:29 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/15/2010 4:12:41 PM
RE: Composed Index as primary key? Posted by Anders Altberg @ 7/16/2010 1:20:32 PM
RE: Composed Index as primary key? Posted by Samir H. @ 7/16/2010 1:31:56 PM