In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
CREATE INDEX pulledtexts_idx_id ON "PulledTexts" ("Id");
CREATE INDEX uniquewords_idx_id ON "UniqueWords" ("Id");
CREATE INDEX uniquewords_idx_wordtext ON "UniqueWords" ("WordText");
CREATE INDEX wordtexts_idx_wordidid ON "WordTexts" ("WordIdId");
SELECT
*
FROM
"PulledTexts"
WHERE
"PulledTexts"."Id" IN (
SELECT
textidid
FROM
((SELECT
"TextIdId" AS textidid
FROM
"WordTexts" AS "wordTexts"
LEFT JOIN
"UniqueWords" AS "wordTexts.WordId"
ON "wordTexts"."WordIdId" = "wordTexts.WordId"."Id"
WHERE
"TextIdId" IN (
SELECT
"TextIdId" and1
FROM
"WordTexts" AS "wordTexts"
INNER JOIN
"UniqueWords" AS "wordTexts.WordId"
ON "wordTexts"."WordIdId" = "wordTexts.WordId"."Id"
WHERE
"wordTexts.WordId"."WordText" = 'audit' INTERSECT SELECT
"TextIdId" and2
FROM
"WordTexts" AS "wordTexts"
INNER JOIN
"UniqueWords" AS "wordTexts.WordId"
ON "wordTexts"."WordIdId" = "wordTexts.WordId"."Id"
WHERE
"wordTexts.WordId"."WordText" = 'trial'
)
)
UNION
DISTINCT (SELECT
"TextIdId" AS textidid
FROM
"WordTexts" AS "wordTexts"
INNER JOIN
"UniqueWords" AS "wordTexts.WordId"
ON "wordTexts"."WordIdId" = "wordTexts.WordId"."Id"
WHERE
"wordTexts.WordId"."WordText" = 'automate')
) AS union1
)