This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ Add index to improve performance of the `/timestamp_to_event` endpoint used for jumping to a specific date in the timeline of a room.
Original file line number Diff line number Diff line change @@ -69,6 +69,8 @@ class _BackgroundUpdates:
6969
7070 EVENTS_POPULATE_STATE_KEY_REJECTIONS = "events_populate_state_key_rejections"
7171
72+ EVENTS_JUMP_TO_DATE_INDEX = "events_jump_to_date_index"
73+
7274
7375@attr .s (slots = True , frozen = True , auto_attribs = True )
7476class _CalculateChainCover :
@@ -260,6 +262,16 @@ def __init__(
260262 self ._background_events_populate_state_key_rejections ,
261263 )
262264
265+ # Add an index that would be useful for jumping to date using
266+ # get_event_id_for_timestamp.
267+ self .db_pool .updates .register_background_index_update (
268+ _BackgroundUpdates .EVENTS_JUMP_TO_DATE_INDEX ,
269+ index_name = "events_jump_to_date_idx" ,
270+ table = "events" ,
271+ columns = ["room_id" , "origin_server_ts" ],
272+ where_clause = "NOT outlier" ,
273+ )
274+
263275 async def _background_reindex_fields_sender (
264276 self , progress : JsonDict , batch_size : int
265277 ) -> int :
Original file line number Diff line number Diff line change 1+ /* Copyright 2023 The Matrix.org Foundation C.I.C
2+ *
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+
16+ INSERT INTO background_updates (ordering, update_name, progress_json) VALUES
17+ (7324 , ' events_jump_to_date_index' , ' {}' );
You can’t perform that action at this time.
0 commit comments