Skip to content

Instantly share code, notes, and snippets.

@daniel-vera-g
Created January 3, 2024 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniel-vera-g/024263e8e062ead729ffb63d88919fef to your computer and use it in GitHub Desktop.
Save daniel-vera-g/024263e8e062ead729ffb63d88919fef to your computer and use it in GitHub Desktop.
import-postgres-dump
  1. (Optional) Create Database: createdb -U musicbrainz musicbrainz
  2. Create Schema in your Table: CREATE SCHEMA musicbrainz;
  3. Import Schema(There are some errors...let's ignore them): psql -U musicbrainz -d musicbrainz -f schema_dump.sql
  4. Import actual dump(Takes a while): psql -U musicbrainz -d musicbrainz -f dump.sql
  5. (Optional) Connect to DB & check data:
  • psql -U musicbrainz -d musicbrainz
  • Something like:
musicbrainz=# select name from artist limit 10;
         name
----------------------
 HEATWAVE
 Maria Robin
 Olivier Bernex
 Jose Montealegre
 ブライアン・ロスコー
 Rumberos Catalans
 Karyn Williams
 Sulfur
 オグ
 Masia One
(10 rows)

musicbrainz=# select count(*) from artist;
  count
---------
 2280863
(1 row)

musicbrainz=# \d+ artist
                                                                  Table "musicbrainz.artist"
      Column      |           Type           | Collation | Nullable |              Default               | Storage  | Compression | Stats target | Description
------------------+--------------------------+-----------+----------+------------------------------------+----------+-------------+--------------+-------------
 id               | integer                  |           | not null | nextval('artist_id_seq'::regclass) | plain    |             |              |
 gid              | uuid                     |           | not null |                                    | plain    |             |              |
 name             | character varying        |           | not null |                                    | extended |             |              |
 sort_name        | character varying        |           | not null |                                    | extended |             |              |
 begin_date_year  | smallint                 |           |          |                                    | plain    |             |              |
 begin_date_month | smallint                 |           |          |                                    | plain    |             |              |
 begin_date_day   | smallint                 |           |          |                                    | plain    |             |              |
 end_date_year    | smallint                 |           |          |                                    | plain    |             |              |
 end_date_month   | smallint                 |           |          |                                    | plain    |             |              |
 end_date_day     | smallint                 |           |          |                                    | plain    |             |              |
 type             | integer                  |           |          |                                    | plain    |             |              |
 area             | integer                  |           |          |                                    | plain    |             |              |
 gender           | integer                  |           |          |                                    | plain    |             |              |
 comment          | character varying(255)   |           | not null | ''::character varying              | extended |             |              |
 edits_pending    | integer                  |           | not null | 0                                  | plain    |             |              |
 last_updated     | timestamp with time zone |           |          | now()                              | plain    |             |              |
 ended            | boolean                  |           | not null | false                              | plain    |             |              |
 begin_area       | integer                  |           |          |                                    | plain    |             |              |
 end_area         | integer                  |           |          |                                    | plain    |             |              |
Indexes:
    "artist_pkey" PRIMARY KEY, btree (id)
    "artist_idx_area" btree (area)
    "artist_idx_begin_area" btree (begin_area)
    "artist_idx_end_area" btree (end_area)
    "artist_idx_gid" UNIQUE, btree (gid)
    "artist_idx_name" btree (name)
    "artist_idx_null_comment" UNIQUE, btree (name) WHERE comment IS NULL
    "artist_idx_sort_name" btree (sort_name)
    "artist_idx_uniq_name_comment" UNIQUE, btree (name, comment) WHERE comment IS NOT NULL
Check constraints:
    "artist_edits_pending_check" CHECK (edits_pending >= 0)
    "artist_ended_check" CHECK ((end_date_year IS NOT NULL OR end_date_month IS NOT NULL OR end_date_day IS NOT NULL) AND ended = true OR end_date_year IS NULL AND end_date_month IS NULL AND end_date_day IS NULL)
Access method: heap

musicbrainz=#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment