Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Expose whether a room is a space in the Admin API #11934

Closed
wants to merge 4 commits into from
Closed

Expose whether a room is a space in the Admin API #11934

wants to merge 4 commits into from

Conversation

lukasdenk
Copy link
Contributor

@lukasdenk lukasdenk commented Feb 8, 2022

Closes #11904.

Signed-off by: Lukas Denk, [email protected]

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Pull request includes a sign off
  • Code style is correct
    (run the linters)

@lukasdenk lukasdenk requested a review from a team as a code owner February 8, 2022 09:51
@lukasdenk lukasdenk marked this pull request as draft February 8, 2022 09:51
Comment on lines +573 to +574
INNER JOIN event_json json USING (room_id)
INNER JOIN state_events events USING (event_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a comparison of costs on my small database for get_rooms_paginate.
It seems to be a big growth. I think we need some discussion to this: #11904 (comment)

explain
SELECT state.room_id, state.name, state.canonical_alias, curr.joined_members,
  curr.local_users_in_room, rooms.room_version, rooms.creator,
  state.encryption, state.is_federatable, rooms.is_public, state.join_rules,
  state.guest_access, state.history_visibility, curr.current_state_events
FROM room_stats_state state
INNER JOIN room_stats_current curr USING (room_id)
INNER JOIN rooms USING (room_id);
                                      QUERY PLAN
--------------------------------------------------------------------------------------
 Hash Join  (cost=11.31..16.20 rows=112 width=218)
   Hash Cond: (state.room_id = curr.room_id)
   ->  Hash Join  (cost=5.57..10.14 rows=114 width=262)
         Hash Cond: (state.room_id = rooms.room_id)
         ->  Seq Scan on room_stats_state state  (cost=0.00..4.24 rows=124 width=159)
         ->  Hash  (cost=4.14..4.14 rows=114 width=103)
               ->  Seq Scan on rooms  (cost=0.00..4.14 rows=114 width=103)
   ->  Hash  (cost=4.22..4.22 rows=122 width=67)
         ->  Seq Scan on room_stats_current curr  (cost=0.00..4.22 rows=122 width=67)
explain
SELECT state.room_id, state.name, state.canonical_alias, curr.joined_members,
  curr.local_users_in_room, rooms.room_version, rooms.creator,
  state.encryption, state.is_federatable, rooms.is_public, state.join_rules,
  state.guest_access, state.history_visibility, curr.current_state_events,
  json.json
FROM room_stats_state state
INNER JOIN room_stats_current curr USING (room_id)
INNER JOIN rooms USING (room_id)
INNER JOIN event_json json USING (room_id)
INNER JOIN state_events events USING (event_id);
                                              QUERY PLAN
-------------------------------------------------------------------------------------------------------
 Hash Join  (cost=639.49..5749.86 rows=8125 width=1289)
   Hash Cond: (state.room_id = curr.room_id)
   ->  Hash Join  (cost=633.74..5721.66 rows=8270 width=1389)
         Hash Cond: (state.room_id = rooms.room_id)
         ->  Hash Join  (cost=628.18..5691.67 rows=8995 width=1286)
               Hash Cond: (json.room_id = state.room_id)
               ->  Hash Join  (cost=622.39..5661.45 rows=8995 width=1127)
                     Hash Cond: (json.event_id = events.event_id)
                     ->  Seq Scan on event_json json  (cost=0.00..4982.49 rows=21549 width=1172)
                     ->  Hash  (cost=509.95..509.95 rows=8995 width=45)
                           ->  Seq Scan on state_events events  (cost=0.00..509.95 rows=8995 width=45)
               ->  Hash  (cost=4.24..4.24 rows=124 width=159)
                     ->  Seq Scan on room_stats_state state  (cost=0.00..4.24 rows=124 width=159)
         ->  Hash  (cost=4.14..4.14 rows=114 width=103)
               ->  Seq Scan on rooms  (cost=0.00..4.14 rows=114 width=103)
   ->  Hash  (cost=4.22..4.22 rows=122 width=67)
         ->  Seq Scan on room_stats_current curr  (cost=0.00..4.22 rows=122 width=67)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dklimpel I guess, one should more efficiently store the room type when the room is created. However, I did not dare such a big change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this would not be downwards compatible

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it is possible to do this downwards compatible. But then it is not a "good first issue".
You need:

  • a database update to extend the table with a new column
  • update the function, which writes new rooms to database
  • a background job to update database for all existing / old rooms

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, maybe I will do so in a month or so. I am a student and currently we have exam phase.

@lukasdenk
Copy link
Contributor Author

I think I won't have time to work on this.

@lukasdenk lukasdenk closed this Mar 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose whether a room is a space in the Admin API
3 participants