List:General Discussion« Previous MessageNext Message »
From:Jigal van Hemert Date:November 11 2005 8:43am
Subject:Re: PK or simple key?
View as plain text  
Eamon Daly wrote:
> I don't know why I have so much trouble visualizing indexes,
> but such is life. Imagine a simple table with only two
> columns: user_id and foo_id. I will only ever be looking up
> records in this table by user_id, but I will always retrieve
> both fields. Figure a million rows and maybe 5 or so rows
> per user_id.
> 
> Should the table be defined with a PK across all columns:
> or should the table have no PK and a key on user_id:

Eamon,

With only two integer fields and MyISAM it might be a solution to use a 
PK on both fields. In that case MySQL only needs to access the index to 
retrieve the data also. The actual table data will not be used, but as 
long as the entire index fits in memory it will be super fast.

Kind regards, Jigal.

Attachment: [application/x-pkcs7-signature] S/MIME Cryptographic Signature smime.p7s
Thread
PK or simple key?Eamon Daly10 Nov
  • Re: PK or simple key?Gleb Paharenko11 Nov
  • Re: PK or simple key?Jigal van Hemert11 Nov
  • Re: PK or simple key?Martijn Tonies11 Nov
  • Re: PK or simple key?Eamon Daly11 Nov