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
On Jan 22, 2015 10:56 PM, "Anssi Kääriäinen" <[email protected]> wrote:

>
>
> 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)
>>
> I missed the part where you said you are using cx_oracle directly. Still,
> make sure you fetch all the results (use list(cursor.fetchall() after
> execution).
>
> If you don't want to return all the results, you can use the .iterator()
> method in Django.
>
>  - Anssi
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> 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
> <https://groups.google.com/d/msgid/django-users/4fa8d059-6fec-4da7-9f24-9ae761e78327%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/CA%2Be%2BciXdsbt93aEV-rGKQww27V5bmsPJSw74--5V31qQAzxb1g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to