Jump to content

Table Without Primary Key


neoform

Recommended Posts

Well, for example a table that contains logs.

 

I never need to uniquely identify any one particular row, however I want to access the data based on fields such as date, so I have the date field indexed, but no primary key since that key would never be used, and therefore cause wasted cycles and ram.

Link to comment
Share on other sites

hmmmm, ARCHIVE looked cool till I read the part that says "No indexing is allowed".. I can't imagine this would work well in on an analytics table where i need to count hits based on date.

Really depends how much of your data your analyze at one time... if it's about 30% of the table, mysql won't use an index regardless, archive or not

Link to comment
Share on other sites

Hard to imagine how you're working with a table without a PK... unless you truly have another unique identifier across multiple columns...

 

If it is merely logs, and you don't have to work with individual rows, it actually makes sense to have no primary key. Uniqueness must be checked during insert with a primary key, but with a simple index, no.

 

If one needs to update or delete individual records, you need a primary key, or uniqueness, otherwise, not really. For example, you can delete all records for a range of dates.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.