How do indexes work on non-unique values ?

From: rhian <williams.rhian_at_freenet.de>
Date: 23 Jan 2003 12:42:44 -0800
Message-ID: <a0310e5c.0301231242.1a8c1512_at_posting.google.com>



i have been told that creating an index on a field which can only contain 2 possible values (i.e male/female) is a bad idea be because order(n/2) is still order(n) and you get no benefit from doing a binary search on the index file.

I think i understand how an index works and is beneficial when created on a unique value, such as primary key. e.g

primary key values page number

1                      1
101                    2
201                    3
301                    4

so if i were searching for 250 i would find the relevant page in minimal number of goes, then the page would be load into memory and scanned sequentially until the relevant record was found

I don't understand how this works for indexes on foreign keys, which i understand to be beneficial or how it would work for my initial example Received on Thu Jan 23 2003 - 21:42:44 CET

Original text of this message