On May 14, 2008, at 9:26, "Adrian R." <ilikeg...@googlemail.com>
wrote:
> the problem is as faras I understood it, that the view is first
> processed completely in the
> database before it returns the result-slice. So it takes as long as it
> takes without a LIMIT or WHERE. That's the reason why I try to use raw
> SQL because then the execution of the statement is stopped when the
> LIMIT is reached as far as I'm understanding
In this 'raw SQL', are you still calling the view? If so, your theory
of limiting being the cause doesn't make sense. If not, you could
just do raw SQL through django.db.connection.cursor().
See if that's still slow.
First off: support for GROUP BY, SUM and other aggregation functions
is a work in progress. The new QS-RF code contains placeholders to
hold GROUP BY statements, but there isn't a public API to get a GROUP
BY into your queries at present. There is a GSOC code aiming to
implement aggregates in the Django ORM, which will obviously involve
introducing GROUP BY statements into the generated SQL.
However, other than that point, I'm afraid I don't understand what
you're proposing. You seem to be suggesting a new kind of model/query
base class that will have all the capabilities of QuerySet/Model, but
will be "raw SQL". You are evidently having some sort of performance
problem, but I'm not sure how this new "raw SQL Model" will fix this
problem.
At the end of the day, a QuerySet is just a mechanism for producing
SQL statements. If that SQL is inefficient for some reason, we're open
to suggestions. However, I'd be highly surprised if reimplementing
QuerySet turned out to be the right solution to your problem.
Can you give a concrete example of something that doesn't work the way
you expect? What exactly are you proposing to implement? How would
this address the problem you are having? We're not opposed to
considering any idea - but first, we need to understand what the idea
is :-)
Yours,
Russ Magee %-)
I don't mean to be rude, but this isn't particularly helpful. A
pageful of SQL doesn't really help me determine the problem you are
having, or how a 'Raw SQL model' will solve the problem.
Can you reduce your problem to a simple (or, at least, simplified) case?
Yours,
Russ Magee %-)