# Untitled

**#Postgres**

### PostgreSQL index advisor

- 쿼리에 인덱스가 있어야 하는지 여부를 결정할 수 있는 PostgreSQL extension

- [Supabase](https://supabase.com/)에서 제공

- 예를 들어, 아래 테이블의 경우

```
    create table book(
      id int primary key,
      title text not null
    );
```

- 'index_advisor()'를 실행하여 select 문에 인덱스가 있어야 하는지 확인할 수 있음

```
select *
from index_advisor('select book.id from book where title = $1');
```

- 출력 예는 다음과 같음

```
{"CREATE INDEX ON public.book USING btree (title)"}
```

- Postgres 데이터베이스에서 실행된 모든 SQL 문의 실행 통계를 추적하는 [pg_stat_statements](https://www.postgresql.org/docs/current/pgstatstatements.html)와 잘 연동됨

- 본 기능은 리소스를 사용하지 않고도 PostgreSQL이 주어진 인덱스를 사용할지 여부를 결정하는 데 탁월한 extension인 [HypoPG](https://github.com/HypoPG/hypopg)에 크게 의존함

🔗 [https://github.com/supabase/index_advisor](https://github.com/supabase/index_advisor) 

[GitHub - supabase/index_advisor: PostgreSQL Index Advisor](https://github.com/supabase/index_advisor)

For the site tree, see the [root Markdown](https://slashpage.com/ai-newsbits.md).
