15000 件の結果を検索していますが、処理速度を最適化する方法はありますか?
私のビューでは、次のように検索をフィルタリングしています。
if form.is_valid():
results = Screening.objects.filter(
screening_date__range(form.cleaned_data['start_date'],form.cleaned_data['end_date']))
if form.cleaned_data['company']:
results = results.filter(company=form.cleaned_data['company'])
if form.cleaned_data['company_job']:
results = results.filter(company_job__in=form.cleaned_data['company_job'])
if form.cleaned_data['company_job_type']:
results = results.filter(company_job_type=form.cleaned_data['company_job_type'])
if form.cleaned_data['reason']:
results = results.filter(reason_for_testing__in=form.cleaned_data['reason'])`
そして TEMPLATE では、渡された結果は次のように使用されます。
{% for result in results %}
<td>{{ result.company.name}}</td>
<td>{{ result.first_name }} {{ result.last_name }}</td>
<td>{{ result.company_job.job_number }}</td>
<td>{{ result.id }}</td>
<td>{{ result.screening_date|date}}</td></tr>
処理を最適化する方法はありますか、この場合キャッシュまたは sth を使用する必要がありますか?