dbt-labs / dbt-labs/docs.getdbt.com
Code example for creating custom postgres indexes via post-hook
- Dominant language
- JavaScript
- Stars
- 215
- Forks
- 1.2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 130
Description
### Contributions
- [X] I have read the contribution docs, and understand what's expected of me.
### Link to the page on docs.getdbt.com requiring updates
https://docs.getdbt.com/reference/resource-configs/postgres-configs#indexes
### What part(s) of the page would you like to see updated?
Would be good to put the following advanced example from https://github.com/dbt-labs/dbt-core/issues/9185 in an example box or put in a Discourse post and link to the Index section within the Postgres page.
In https://github.com/dbt-labs/dbt-core/issues/9185 the poster gave this code example for using the `gin` or `gist` index types from the [`pg_trgm`](https://www.postgresql.org/docs/current/pgtrgm.html) extension module using the `gin_trgm_ops` operator class (opclass):
```sql
{{
config(
indexes=[
{"columns": ["my_regular_column"], "type": "btree"},
],
post_hook=[
"create index my_1st_ext_index on {{ this }} using gin (my_1st_ext_column gin_trgm_ops);",
"create index my_2nd_ext_index on {{ this }} using gist (my_2nd_ext_column gist_trgm_ops);",
"create index my_3rd_ext_index on {{ this }} using gist (my_3rd_ext_column gist_trgm_ops(siglen=32));",
]
)
}}
```
> [!WARNING]
> I didn't actually test out the code example above. I also didn't give much thought to the name of the example columns and indexes. The cde should be tested for correctness and the names should be aligned with relevant style guides.
### Additional information
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.