Skip to content

Commit 8ee5220

Browse files
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

File tree

src/wp-admin/includes/schema.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
198198
PRIMARY KEY (id),
199199
KEY type_client_id (type,client_id),
200200
KEY room (room,id),
201+
KEY room_type_date (room,type,date_gmt),
201202
KEY date_gmt (date_gmt)
202203
) $charset_collate;\n";
203204

src/wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* @global int $wp_db_version
2525
*/
26-
$wp_db_version = 61841;
26+
$wp_db_version = 61842;
2727

2828
/**
2929
* Holds the TinyMCE version.

0 commit comments

Comments
 (0)