Commit 8ee5220
committed
Collaboration: Add (room, type, date_gmt) index to the collaboration table.
Add a composite KEY room_type_date (room, type, date_gmt) so the
awareness read path in get_awareness_state() can seek directly to a
room's live awareness rows instead of relying on the KEY room (room,
id) prefix and post-filtering by type and date_gmt.
In the single-table design where awareness and update rows share
$wpdb->collaboration and are distinguished only by the type column,
the previous indexes left no covering path for the hot-path query
WHERE room = %s AND type = 'awareness' AND date_gmt >= %s, which runs
on every cache-miss awareness poll (~0.5-1s per active editor).
EXPLAIN on a populated table (11k rows) confirms MySQL switches from
KEY room (rows=55, Using where) to KEY room_type_date (rows=3, Using
index condition), with the full WHERE clause pushed down into the
index lookup.
The set_awareness_state() existence check (WHERE room = %s AND type
= 'awareness' AND client_id = %s) also picks up the new index as a
side benefit: its plan switches from an index_merge intersection of
type_client_id and room to a single-index seek on room_type_date.
The old intersection plan wasn't pathological, but a single composite
seek is simpler and more predictable.
Bump $wp_db_version to 61842 so dbDelta picks up the new index on
upgrade.1 parent 8371c5c commit 8ee5220
2 files changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| 201 | + | |
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
0 commit comments