View Single Post
Old 12-08-2011, 11:57 AM   #1
photon
The new goggles also do nothing.
 
photon's Avatar
 
Join Date: Oct 2001
Location: Calgary
Exp:
Default Database question..

Does it make sense for an index to be larger than the database itself? Since an index is used to make queries faster, it seems kind of counter-intuitive that it should take up more space than the table itself.

I've got a table with only 3 columns, each is an 8 byte integer.

id, version, and other_id.

id is the primary key, so I assume that gets indexed.

other_id is the other column that's indexed, and currently all are set to null.

The table is populated with lots of rows, and the size of the index on disk is larger than the size of the table itself.

Is it because all the values are null (meaning a selectivity of zero basically)?

ETA: Not sure about the null thing now, the other table I have is two columns (for a many to many relationship), and the index size was more than double. The primary key was a composite key of the two columns, and each column was also indexed because I have to be able to search both ways.
__________________
Uncertainty is an uncomfortable position.
But certainty is an absurd one.
photon is offline   Reply With Quote