@staticmethod
def get_knobs_for_session(session):
// Returns a dict of the knob
knobs = KnobCatalog.objects.filter(dbms=session.dbms)
knob_dicts = list(knobs.values())
for i, _ in enumerate(knob_dicts):
if SessionKnob.objects.filter(session=session, knob=knobs[i]).exists():
new_knob = SessionKnob.objects.filter(session=session, knob=knobs[i])[0]
After Change
@staticmethod
def get_knobs_for_session(session):
// Returns a dict of the knob
session_knobs = SessionKnob.objects.filter(
session=session, tunable=True).prefetch_related("knob")
session_knobs = {s.knob.pk: s for s in session_knobs}
knob_dicts = list(KnobCatalog.objects.filter(id__in=session_knobs.keys()).values())
for knob_dict in knob_dicts:
sess_knob = session_knobs[knob_dict["id"]]