Shame. My bad code are very slow. But logic is very easy.
First, let me test nltk parse token speed.
It is very fast so must sql slow.
Try to filter and find value by my self.
We parse database record to dict. Only 2 sql left and faster but we not satisfied!
ChatGpt tell me a better plan to implement:
First time request it waste me 6s.
Second time request it is very fast but it show no cache was used.Why ?
Let us learn ChatGpt's code.
Word.objects.filter(word__in=tokens)
This code used in to generate a sql IN str list. Why SQL is so fast?
Ok. We use what we learned to refactor old code:
Much better but ChatGpt's code is more faster.
Thanks for reading!