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

Add index on vote (editor)

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Normal Normal
    • NGS - Release Candidate 2
    • NGS - Release Candidate 1
    • None
    • None

      musicbrainz_db_raw_rc1=> explain analyze SELECT vote, count(vote) AS count FROM vote WHERE editor = '95678' GROUP BY vote;
      QUERY PLAN
      ----------------------------------------------------------------------------------------------------------------------
      HashAggregate (cost=150879.93..150879.94 rows=1 width=2) (actual time=1508.100..1508.103 rows=3 loops=1)
      -> Seq Scan on vote (cost=0.00..150614.40 rows=53105 width=2) (actual time=689.430..1443.017 rows=59721 loops=1)
      Filter: (editor = 95678)
      Total runtime: 1508.229 ms
      (4 rows)

      musicbrainz_db_raw_rc1=> \d vote
      Table "musicbrainz.vote"
      Column | Type | Modifiers
      -------------------------------------------------------------------------------------
      id | integer | not null default nextval('vote_id_seq'::regclass)
      editor | integer | not null
      edit | integer | not null
      vote | smallint | not null
      vote_time | timestamp with time zone | default now()
      superseded | boolean | not null default false
      Indexes:
      "vote_pkey" PRIMARY KEY, btree (id)
      "vote_idx_edit" btree (edit)
      Foreign-key constraints:
      "vote_fk_edit" FOREIGN KEY (edit) REFERENCES edit(id)

      musicbrainz_db_raw_rc1=> create index vote_idx_editor on vote (editor);
      CREATE INDEX
      musicbrainz_db_raw_rc1=> explain analyze SELECT vote, count(vote) AS count FROM vote WHERE editor = '95678' GROUP BY vote;
      QUERY PLAN
      ----------------------------------------------------------------------------------------------------------------------------------------
      HashAggregate (cost=59158.15..59158.16 rows=1 width=2) (actual time=145.156..145.159 rows=3 loops=1)
      -> Bitmap Heap Scan on vote (cost=996.65..58892.62 rows=53105 width=2) (actual time=9.651..81.134 rows=59721 loops=1)
      Recheck Cond: (editor = 95678)
      -> Bitmap Index Scan on vote_idx_editor (cost=0.00..983.37 rows=53105 width=0) (actual time=8.524..8.524 rows=59721 loops=1)
      Index Cond: (editor = 95678)
      Total runtime: 145.235 ms
      (6 rows)

            acid2 Oliver Charles
            acid2 Oliver Charles
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                Version Package
                NGS - Release Candidate 2