Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pawurb committed Oct 15, 2024
1 parent 6b0d488 commit ef56910
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ Alternative versions:
## Installation

```bash
cargo add pg-extras
cargo install pg-extras
```

`calls` and `outliers` queries require [pg_stat_statements](https://www.postgresql.org/docs/current/pgstatstatements.html) extension.

You can check if it is enabled in your database by running:

```rust
use pg_extras::{render_table, extensions}

render_table(extensions()?);
```bash
pg_extras extensions
```

You should see the similar line in the output:
Expand All @@ -56,7 +54,25 @@ Package expects the `ENV['PG_EXTRAS_DATABASE_URL']` or `ENV['DATABASE_URL']` val
ENV["DATABASE_URL"] = "postgresql://postgres:secret@localhost:5432/database_name"
```

You can run queries using a Rust API to display an ASCCI table with results:
You can use `pg_extras` shell command:

```bash
$ pg_extras cache_hit
+----------------+------------------------+
| /* Index and table hit rate */ |
+================+========================+
| name | ratio |
+----------------+------------------------+
| index hit rate | 0.99138647287107053837 |
+----------------+------------------------+
| table hit rate | 0.99984856854492081787 |
+----------------+------------------------+
```

## Rust API


You can also run queries using a Rust API to display an ASCCI table with results:

```rust
use pg_extras::{render_table, cache_hit}
Expand Down Expand Up @@ -95,22 +111,6 @@ cache_hit(Some("other_schema".to_string)).await?;

You can customize the default `public` schema by setting `ENV['PG_EXTRAS_SCHEMA']` value.

## Command line

After running `cargo install pg-extras` you can use `pg_extras` shell command:

```bash
$ pg_extras cache_hit
+----------------+------------------------+
| /* Index and table hit rate */ |
+================+========================+
| name | ratio |
+----------------+------------------------+
| index hit rate | 0.99138647287107053837 |
+----------------+------------------------+
| table hit rate | 0.99984856854492081787 |
+----------------+------------------------+
``````

## Available methods

Expand Down

0 comments on commit ef56910

Please sign in to comment.