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

Add view to easily access medium track lengths

XMLWordPrintable

      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;
      

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

              Created:
              Updated:

                Version Package
                Schema change, 2021 Q2