-
-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Performance issue when using pagination #1297
Comments
Hi @tschale could you provide some examples - like you model partially and operation code ? |
Hi @vitalik, thanks for your response! Do you mean by operation code, how the django app is run in Kubernetes? Here is the model:
Representation of the vectors in the schema:
We use a custom filter schema, to support filtering with conjunctive normal form principles. E.g. a GET with params The filter schema supports all fields except the
|
Hi @tschale still hard to tell.. I assume you are using postgres... what you can try is check
# myapp/middleware.py
import time
import logging
from django.db import connection, reset_queries
logger = logging.getLogger(__name__)
class SQLDebugMiddleware:
# ... __init__ method remains the same ...
def __call__(self, request):
reset_queries()
start_time = time.time()
response = self.get_response(request)
total_time = time.time() - start_time
queries = connection.queries
query_time = sum(float(q['time']) for q in queries)
print(f"Total Request Time: {total_time:.3f}s")
print(f"Total DB Query Time: {query_time:.3f}s")
print(f"Number of Queries: {len(queries)}")
for query in queries:
sql = query['sql']
time_taken = query['time']
print(f"({time_taken}s) {sql}")
return response or use django debug toolbar |
Hi @vitalik, thanks for your response! We are using postgres, yes. I will try your suggestions. However it probably will take some days, or even weeks. I will get in contact again, once I had the opportunity to try them. |
Describe the bug
I have a GET endpoint of a model, that returns 872 instances in total. However when using pagination with
limit=1000
, the Kubernetes pod crashes due to OOMKilled, i.e. because it uses too much memory. Whenlimit
is omitted in the request, the endpoint returns the response of the 872 instances. Thelimit
parameter can be used to around 750, atlimit=800
, the issue occurs.One thing that might be of interest, the model of the GET endpoint uses 12 VectorFields from pgvector, with 768 and 1024 dimensions. The response contains them as lists. Each instance therefore contains quite some data, in comparison to "vanilla" models with basic fields. Could this be problematic?
I looked at the
paginate
decorator, but that code is a little bit too abstract to quickly find out whats going on exactly... Has somebody experienced similar issues? Or does somebody has knowledge about the pagination, to figure out whether the model/pgvector-fields might be causing the issue?Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: