Make WordPress Core

Opened 22 years ago

Closed 19 years ago

Last modified 12 years ago

#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)

ticket787patch.diff​ (1.4 KB ) - added by ketsugi 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.
787.diff​ (1.5 KB ) - added by rob1n 20 years ago.

Download all attachments as: .zip

Change History (20)

#1 @michel v
22 years ago

  • Patch → No

#2 @matt
22 years ago

  • Status new → assigned

#3 @markjaquith
21 years ago

still worth fixing?

@ketsugi
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 @ketsugi
20 years ago

  • Component General → Optimization
  • Owner changed from anonymous to ketsugi
  • Status assigned → new
  • Version → 2.0.4

#5 @foolswisdom
20 years ago

  • Milestone → 2.1

#6 @matt
20 years ago

  • Milestone 2.1 → 2.2

#7 @rob1n
20 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 @DD32
20 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 @rob1n
20 years ago

  • Owner changed from ketsugi to rob1n
  • Status new → assigned

I'd say a simple INDEX on both category_ID and post_ID would be nice. Any devs have feedback?

#10 @rob1n
20 years ago

Oh, and taking out rel_id too.

#11 @rob1n
20 years ago

  • Keywords has-patch added; 2nd-opinion removed

#12 @matt
20 years ago

I like the new primary key. I think it's worth also having an index on category_id re #3900.

#14 @rob1n
20 years ago

  • Keywords on-hold added; dev-feedback removed

I'll take another look when #3900 is committed.

#15 @rob1n
20 years ago

  • Milestone 2.2 → 2.3

#16 @rob1n
20 years ago

  • Status assigned → new

#17 @ryan
19 years ago

  • Resolution → fixed
  • Status new → closed

post2cat is gone in 2.3.

This ticket was mentioned in ​Slack in #cli by voldemortensen. ​View the logs.


12 years ago

Note: See TracTickets for help on using tickets.