# configuring

Expansion is configured using command line flags or environment variables. To see the list of command line flags that are available (and their default values) for your version of Horizon, run:

`expansion --help`

When you run the command above, you'll see that Horizon defines a large number of flags; however, only three are required:

| flag                  | envvar                    | example                                  |
| --------------------- | ------------------------- | ---------------------------------------- |
| `--db-url`            | `DATABASE_URL`            | postgres\://localhost/expansion\_testnet |
| `--bantu-core-db-url` | `BANTU_CORE_DATABASE_URL` | postgres\://localhost/core\_testnet      |
| `--bantu-core-url`    | `BANTU_CORE_URL`          | <http://localhost:11626>                 |

`--db-url` specifies the Horizon database, and its value should be a valid [PostgreSQL Connection URI](http://www.postgresql.org/docs/9.2/static/libpq-connect.html#AEN38419). `--bantu-core-db-url` specifies a Stellar Core database which will be used to load data from the Stellar ledger. Finally, `--bantu-core-url` specifies the HTTP control port for an instance of Stellar Core. This URL should be associated with the Stellar Core server that is writing to the database at `--bantu-core-db-url`.

Additionally, if you are running a single Expansion instance you should start ingestion using the following flags:

| flag                     | envvar                 | example                                                         |
| ------------------------ | ---------------------- | --------------------------------------------------------------- |
| `--history-archive-urls` | `HISTORY_ARCHIVE_URLS` | <http://history.stellar.org/prd/core-testnet/core_testnet_001/> |
| `--ingest`               | `INGEST`               | true                                                            |

Specifying command line flags every time you invoke Expansion can be cumbersome, and so we recommend using environment variables. There are many tools you can use to manage environment variables: we recommend either [direnv](http://direnv.net/) or [dotenv](https://github.com/bkeepers/dotenv).

## Preparing the Database

Before running the Expansion server, you must first prepare the Horizon database. This database will be used for all of the information produced by Horizon, notably historical information about successful transactions that have occurred on the stellar network.

To prepare a database for Horizon's use, you must first ensure the database is blank. It's easiest to simply create a new database on your postgres server specifically for Horizon's use. Next you must install the schema by running `horizon db init`. Remember to use the appropriate command line flags or environment variables to configure Horizon as explained in [Configuring ](/run-api-server/configuring.md). This command will log any errors that occur.

### Postgres Configuration

It is recommended to set `random_page_cost=1` in Postgres configuration if you are using SSD storage. With this setting Query Planner will make a better use of indexes, expecially for `JOIN` queries. We've noticed a huge speed improvement for some queries.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.docs.bantufoundation.org/run-api-server/configuring.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
