aboutsummaryrefslogtreecommitdiff
path: root/roomserver/storage/tables
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-12-16 10:33:28 +0000
committerGitHub <noreply@github.com>2020-12-16 10:33:28 +0000
commit90571430330afa887912f55fa6a3b329299d927e (patch)
tree742d7346f09f76d0cdeb7d2227b199561f5f0a30 /roomserver/storage/tables
parentd2bcc5f746f52f5537c23898ce9edde3583614fb (diff)
Hit the database far less in Events to find room NIDs and room versions (#1643)
* Hit the database far less to find room NIDs for event NIDs * Close the rows * Fix SQLite selectRoomNIDsForEventNIDsSQL * Give same treatment to room version lookups
Diffstat (limited to 'roomserver/storage/tables')
-rw-r--r--roomserver/storage/tables/interface.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/roomserver/storage/tables/interface.go b/roomserver/storage/tables/interface.go
index d7344584..26bf5cf0 100644
--- a/roomserver/storage/tables/interface.go
+++ b/roomserver/storage/tables/interface.go
@@ -10,8 +10,9 @@ import (
)
type EventJSONPair struct {
- EventNID types.EventNID
- EventJSON []byte
+ EventNID types.EventNID
+ RoomVersion gomatrixserverlib.RoomVersion
+ EventJSON []byte
}
type EventJSON interface {
@@ -58,7 +59,7 @@ type Events interface {
// If an event ID is not in the database then it is omitted from the map.
BulkSelectEventNID(ctx context.Context, eventIDs []string) (map[string]types.EventNID, error)
SelectMaxEventDepth(ctx context.Context, txn *sql.Tx, eventNIDs []types.EventNID) (int64, error)
- SelectRoomNIDForEventNID(ctx context.Context, eventNID types.EventNID) (roomNID types.RoomNID, err error)
+ SelectRoomNIDsForEventNIDs(ctx context.Context, eventNIDs []types.EventNID) (roomNIDs map[types.EventNID]types.RoomNID, err error)
}
type Rooms interface {
@@ -67,7 +68,7 @@ type Rooms interface {
SelectLatestEventNIDs(ctx context.Context, txn *sql.Tx, roomNID types.RoomNID) ([]types.EventNID, types.StateSnapshotNID, error)
SelectLatestEventsNIDsForUpdate(ctx context.Context, txn *sql.Tx, roomNID types.RoomNID) ([]types.EventNID, types.EventNID, types.StateSnapshotNID, error)
UpdateLatestEventNIDs(ctx context.Context, txn *sql.Tx, roomNID types.RoomNID, eventNIDs []types.EventNID, lastEventSentNID types.EventNID, stateSnapshotNID types.StateSnapshotNID) error
- SelectRoomVersionForRoomNID(ctx context.Context, roomNID types.RoomNID) (gomatrixserverlib.RoomVersion, error)
+ SelectRoomVersionsForRoomNIDs(ctx context.Context, roomNID []types.RoomNID) (map[types.RoomNID]gomatrixserverlib.RoomVersion, error)
SelectRoomInfo(ctx context.Context, roomID string) (*types.RoomInfo, error)
SelectRoomIDs(ctx context.Context) ([]string, error)
BulkSelectRoomIDs(ctx context.Context, roomNIDs []types.RoomNID) ([]string, error)