#787 closed defect (bug) (fixed)
Bad PRIMARY key for the table wp_post2cat
Reported by: | michel v | Owned by: | rob1n |
---|---|---|---|
Milestone: | 2.3 | Priority: | normal |
Severity: | normal | Version: | 2.1 |
Component: | Optimization | Keywords: | has-patch on-hold |
Focuses: | Cc: |
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)
@
18 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
@
18 years ago
- Component changed from General to Optimization
- Owner changed from anonymous to ketsugi
- Status changed from assigned to new
- Version set to 2.0.4
#7
@
18 years ago
- Keywords dev-feedback 2nd-opinion added
- Priority changed from low to normal
- Severity changed from minor to normal
- Summary changed from bad PRIMARY key for the table wp_post2cat to Bad PRIMARY key for the table wp_post2cat
- Version changed from 2.0.4 to 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
@
18 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
@
18 years ago
- Owner changed from ketsugi to rob1n
- Status changed from new to assigned
I'd say a simple INDEX on both category_ID and post_ID would be nice. Any devs have feedback?
#12
@
18 years ago
I like the new primary key. I think it's worth also having an index on category_id re #3900.
#13
@
18 years ago
http://trac.wordpress.org/ticket/3900#comment:4
Should we merge tickets?
#14
@
18 years ago
- Keywords on-hold added; dev-feedback removed
I'll take another look when #3900 is committed.
#17
@
17 years ago
- Resolution set to fixed
- Status changed from new to closed
post2cat is gone in 2.3.
still worth fixing?