Team,
We are using full text search functionality of Prisma with Postgresql. If I have a table like below
CREATE TABLE Configs (
id serial4 NOT NULL primary key,
config text NULL
);
It has a text index like below.
CREATE INDEX ix1 ON Configs USING GIN (to_tsvector(‘simple’::regconfig, config));
And when using GraphQL query on this table below
query {
findManyConfigs(take:100, where:
{
config: {
search: “xxxxx”
}
})
{
id
}
}
It is executing query something like below on database.
SELECT “schemaname”.“Configs”.“id”, “schemaname”.“Configs”.“config”
FROM “schemaname”.“Configs”
WHERE to_tsvector(concat_ws(' ’, “schemaname”.“Configs”.“config”)) @@ to_tsquery(‘xxxxx’)
ORDER BY “schemaname”.“Configs”.“id” ASC LIMIT 100 OFFSET 0;
But it is not able to use the index that was created on table. And we could not create a function based index to_tsvector(concat_ws(' ’, “schemaname”.“Configs”.“config”)) because the functions are not IMMUTABLE.
Is there a way that we can make prisma generated queries to use the text based index on the table? Or suggestions on what index need to be created to have optimized execution of prisma generated query.
Thank you for the help.