To many calculations in the from_db_value function. Need optimizations. And what about query limitations: 1.5b is really needed?
class SYSGUID16Field(models.Field):
default_error_messages = {
'invalid': "'%(value)s' is not a valid SYS_GUID."
}
description = "A connector to the SYS_GUID() fields for Oracle
Backends"
def __init__(self, *args, **kwargs):
kwargs['max_length'] = 16
super(SYSGUID16Field, self).__init__(*args,**kwargs)
def from_db_value(self, value, connection):
#print 'call from_db_value %s' % value
if value is None:
return value
return str(b2a_hex(value)).upper()
четверг, 22 января 2015 г., 18:32:36 UTC+3 пользователь Joris Benschop написал:
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/29682a24-fdb6-4883-882e-58fb53d0a98c%40googlegroups.com.--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/CYIxM8nZl1A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
Do you fetch all the results when running the query directly against Oracle? Many Oracle SQL clients do not fetch all the results, instead they fetch just the top 100 or so rows. markid = models.CharField(unique=True, max_length=20, blank=True)
How many results do you typically get back from that query?
It sounds like the DB is highly optimized if you can gather results from tables that large that quickly running the query outside of Django. If you are returning a large dataset, then it is more likely that Django is furiously coercing every row in the result set to the appropriate model, which takes time. Anything above a couple hundred rows will probably be noticeable, maybe even less.
If a large result set is desired, I would recommend you filter your query a bit more to reduce the number of rows returned and look at using values() which may help slightly.
Installing the Django debug toolbar will also help, as you will be able to see how long each query takes, which will probably lead you to the culprit. It has a sqlshell management command that also may be of use, printing out information about the queries, etc.
You can also slice the query to only retrieve the first 100 rows, etc.
As quick validation, I'm guessing that if you look at your system process manager while the query is running, you'll see a single python process pegged at 100% for the duration of the query run. If the DB is at fault, python should be sitting idle.
TL;DR; I don't think the query itself is at fault, probably too much data being returned to process.
-James
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4fa8d059-6fec-4da7-9f24-9ae761e78327%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0898444F-6539-4191-B766-BFE248586F37%40cederstrand.dk.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20150123135923.25a181aa%40jns42-l.w2k.keypro.fi.