On Sat, 13 Feb 2010, Matt Kettler wrote:

On 2/13/2010 11:33 AM, David Morton wrote:

So token was both a primary key, and an index, which is redundant.

How is that redundant?  If you search for only a token, it would not be
indexed, and would perform very poorly.

Because it is the primary key, which is by definition, an index!!! (it
is the fastest index too, so any other index on the same column will
just be slower (if used at all))

  PRIMARY KEY  (id, token),

"token" is _not_ the primary key. It is a primary key _member_, but it is not the entire primary key.

David's comment is precisely correct. The PK index would not help a search on token by itself, as it is not the first member of the PK.

The fact that token is never queried by itself means an index on token is not needed, but such an index is _not_ redundant.

--
 John Hardin KA7OHZ                    http://www.impsec.org/~jhardin/
 jhar...@impsec.org    FALaholic #11174     pgpk -a jhar...@impsec.org
 key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C  AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
  End users want eye candy and the "ooo's and aaaahhh's" experience
  when reading mail. To them email isn't a tool, but an entertainment
  form.                                                 -- Steve Lake
-----------------------------------------------------------------------
 9 days until George Washington's 278th Birthday

Reply via email to