sqldelight
sqldelight copied to clipboard
PostgreSql Dialect add USING GIN to CREATE INDEX statement
Description
Currently JSON and JSONB types and operators are supported - these work with GIN
“Generalized Inverted indexes” - GIN is designed for handling cases where the items to be indexed are composite values, and the queries to be handled by the index need to search for element values that appear within the composite items. For example, the items could be documents, and the queries could be searches for documents containing specific words.
https://www.postgresql.org/docs/15/sql-createindex.html
e.g the most basic GIN can be supported
CREATE INDEX metadataGin ON books USING GIN (meta_data);
Add here: https://github.com/cashapp/sqldelight/blob/007a784f99d914767de2fb76da142cbd99e1ed30/dialects/postgresql/src/main/kotlin/app/cash/sqldelight/dialects/postgresql/grammar/PostgreSql.bnf#L170
It must support multiple-key-column indexes same as the default B-TREE index
Also used to support datatypes like TSVECTOR - currently not implemented
Adding GIN is a first step before adding more features like TSVECTOR type