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 results_idx_examyear_examtype ON "results" ("examYear","examType");
SELECT
COUNT(*)
FROM
results
WHERE
EXISTS (
SELECT
1
FROM
jsonb_array_elements(subjects) AS j(data)
WHERE
(
data# >> '{subject}'
) LIKE '%MATH%'
AND (
data# >> '{grade}'
) IN (
'A', 'B', 'C'
)
)
AND results."examYear" = '2010'
AND results."examType" = 'CSEE'