Uploaded image for project: 'MusicBrainz Server'
  1. MusicBrainz Server
  2. MBS-11463

Add view to easily access medium track lengths

    XMLWordPrintable

    Details

      Description

      In order to avoid loading all track data just to figure out how long a medium (or release) is, we could use a view medium_track_durations.

      SQL: 

      CREATE OR REPLACE VIEW medium_track_durations AS 
      SELECT medium.id AS medium, 
      array_agg(track.length ORDER BY track.position) FILTER (WHERE track.position = 0) AS pregap_length,
      array_agg(track.length ORDER BY track.position) FILTER (WHERE track.position > 0 AND track.is_data_track = false) AS cdtoc_track_lengths,
      array_agg(track.length ORDER BY track.position) FILTER (WHERE track.is_data_track = true) AS data_track_lengths
      FROM medium JOIN track ON track.medium = medium.id
      GROUP BY medium.id;
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              reosarevok Nicolás Tamargo
              Reporter:
              reosarevok Nicolás Tamargo
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:

                  Packages

                  Version Package
                  Schema change, 2021 Q2