#787 closed defect (bug) (fixed)
Bad PRIMARY key for the table wp_post2cat
| Reported by: | michel v | Owned by: | rob1n |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.3 |
| Component: | Optimization | Version: | 2.1 |
| Severity: | normal | Keywords: | has-patch on-hold |
| Cc: | Focuses: |
Description
Using a rel_id field as a PRIMARY key to ensure relationships are unique is rather useless. We never use rel_id in the code.
A better approach would be to get rid of rel_id, and set the PRIMARY key on the tuple post_id and category_id.
Attachments (2)
Change History (20)
@
20 years ago
A quick patch: removes the rel_id columns from link2cat and post2cat, replaces the primary keys with a tuple, and bumps the database version by 1.
#4
@
20 years ago
- Component General → Optimization
- Owner changed from to
- Status assigned → new
- Version → 2.0.4
#7
@
19 years ago
- Keywords dev-feedback 2nd-opinion added
- Priority low → normal
- Severity minor → normal
- Summary bad PRIMARY key for the table wp_post2cat → Bad PRIMARY key for the table wp_post2cat
- Version 2.0.4 → 2.1
Wouldn't setting both post_id and category_id as PRIMARY's force them to be unique? Neither will be unique, eventually...
#8
@
19 years ago
Wouldn't setting both post_id and category_id as PRIMARY's force them to be unique?
Not if they're added as a tuple, ie a pair. The primary key would be a combination of post_id AND category_id.
I'm not sure myself if it'd be more optimized that way, or if it was a single index on either.
#9
@
19 years ago
- Owner changed from to
- Status new → assigned
I'd say a simple INDEX on both category_ID and post_ID would be nice. Any devs have feedback?
#12
@
19 years ago
I like the new primary key. I think it's worth also having an index on category_id re #3900.
#13
@
19 years ago
http://trac.wordpress.org/ticket/3900#comment:4
Should we merge tickets?
#14
@
19 years ago
- Keywords on-hold added; dev-feedback removed
I'll take another look when #3900 is committed.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
still worth fixing?