DB Sync best practices

This section outlines some best practices for using the Cardano DB Sync component.

Having all software on the same machine

The recommended configuration is to have node, DB Sync, and PostgreSQL servers on the same machine. During syncing (getting historical data from the blockchain), there is a large amount of data traffic between db-sync and the database. Traffic to a local database is significantly faster than traffic to a database on the LAN or other remote location.

Disk requirements

It is highly recommended that you use a Solid State Disk (SSD). Also, make sure you use a high-grade SSD that has more than 60,000 IOPS.

Tuning PostgreSQL

By default, PostgreSQL is not optimized for running in a high-performance environment. For a better DB Sync experience, it is mandatory that you fine-tune your PostgreSQL instance when running a production-grade application.

You can use PGTune to generate a configuration file, which you can use to fine-tune your PostgreSQL instance. For this:

  1. Go to the PGTune website.
  2. Provide basic information about your hardware configuration which works with the PostgreSQL database.
  3. Click ‘Generate’. The system will calculate optimal results.
  4. Finally, replace your configuration with suggested numbers.

Using snapshots

Blockchain size constantly increases with the number of new transactions and data added to the chain. The time to sync the whole blockchain increases accordingly. Every protocol upgrade presumes that database schemas are updated, which means that the database needs to be synced from genesis.

IOHK provides new DB Sync database snapshots with each new epoch so that you can quickly sync your DB Sync instance in a few hours instead of days. You can find the latest snapshots here.

These snapshots are compatible with both cardano-db-sync and cardano-db-sync with --no-epoch-table.

See how to efficiently use snapshots here:

Using a --disable-ledger flag for faster syncing times

A beta-version --disable-ledger parameter feature has been added to DB Sync. The upcoming DB Sync version will be compatible with node v.1.35.0-rc4, bringing an option to disable the ledger state. This means that users who don’t require syncing reward details, historical stake data, epoch parameters, etc. will be able to run a much lighter version of DB Sync. This will dramatically decrease DB Sync syncing times and RAM requirements, reducing memory usage by up to 9GB on mainnet.

See the configuration:

DB Sync maintenance

Example queries

IOHK provides a list of queries to query the PostgreSQL database for commonly required information. You can find some example queries here.

© IOHK 2015 - 2022

Cardano Logo

Cardano is an open-source project.

Cardano is a software platform ONLY and does not conduct any independent diligence on, or substantive review of, any blockchain asset, digital currency, cryptocurrency or associated funds. You are fully and solely responsible for evaluating your investments, for determining whether you will exchange blockchain assets based on your own judgement, and for all your decisions as to whether to exchange blockchain assets with Cardano. In many cases, blockchain assets you exchange on the basis of your research may not increase in value, and may decrease in value. Similarly, blockchain assets you exchange on the basis of your research may fall or rise in value after your exchange.

Past performance is not indicative of future results. Any investment in blockchain assets involves the risk of loss of part or all of your investment. The value of the blockchain assets you exchange is subject to market and other investment risks