Hello, I'm using this gem : [login to view URL]
to generate my datatables, but queries are not optimized, for example :
I have a list with evaluations, each evaluation has 50+ questions inside
then in my datatables I list evaluations, but any time I filter or load list this loads all questions inside each evaluations and its very slow when I only need evaluations data
I need to load only relevant data to speed up the loading times in many datatables.
This is the query :
def get_raw_records
[login to view URL](
:evaluation => [:assignature,:level, :evaluation_type])
.references(
:evaluation => [:assignature,:level,:evaluation_type]
).distinct
end
Instrument belongs_to Evaluation
Evaluation has_many questions
console shows :
"."id" = $1 LIMIT 1 [["id", 959]]
Question Load (0.3ms) SELECT "questions".* FROM "questions" WHERE "questions"."id" = $1 LIMIT 1 [["id", 934]]
Question Load (0.3ms) SELECT "questions".* FROM "questions" WHERE "questions"."id" = $1 LIMIT 1 [["id", 950]]
(1000000 times the same)...
Thanks