Uploaded image for project: 'ListenBrainz'
  1. ListenBrainz
  2. LB-1114

GET /listen-count is very slow for users who haven't submitted listens in a while

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • None
    • None

      The sql query to fetch listen counts, retrieves the count  and max_listened_at from listen_user_metadata table. Using the max_listened_at, another query counts number of listens submitted since then. The sum of the two counts gives us the total listen count of the user.

      However if the user hasn't submitted listens in a while, say a year, the max_listened_at will far back in time and accordingly a large part of the table will be searched in the second query. Thus the query and subsequently the request will execute slowly. This leads to suboptimal UI/UX on the frontend where a this user has no listens message will displayed.

       

      See also: https://community.metabrainz.org/t/ui-bug-has-not-listened-to-any-songs-so-far/591240

            Unassigned Unassigned
            kartik1712 amCap1712
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                Version Package