On Fri, 2008-12-12 at 10:29 -0800, erikcw wrote:
> Thanks for all of the responses. Just wanted to share where I'm at at
> this point:
[... *argh* my eyes!...ok, snipped...]
> This seems to work. If you know of any performance tweaks I'd love to
> hear about them (however it is incredibly fas
Thanks for all of the responses. Just wanted to share where I'm at at
this point:
self.profilekeyword_set.select_related().all().extra(select={
'rank_url': 'SELECT url FROM rankreport_keywordrank WHERE
rankreport_keywordrank.keyword_id =
rankreport_profilekeyword.keyword_id AND
rankrepor
On Mon, 2008-12-08 at 07:43 -0800, DavidA wrote:
> If I undestand the problem correctly, in MySQL you could do this in
> one query as:
>
> select
> m.*,
> (select min(created) from model2 where id = m.model2_id) as
> first_created,
> (select max(created) from model2 where id = m.mode
I think you are on something here.
Below is what concerns me most in the example:
data[o.name].append(o.model3_set.all().order_by('created')[0])
This will sort the entire model3 table just to get the min value.
And if the db is doing this 6000 times, that is a bit useless.
Have you tried using
If I undestand the problem correctly, in MySQL you could do this in
one query as:
select
m.*,
(select min(created) from model2 where id = m.model2_id) as
first_created,
(select max(created) from model2 where id = m.model2_id) as
last_created
from model1 m
;
I don't know how that tran
On Sat, 2008-12-06 at 20:56 -0800, erikcw wrote:
> Hi all,
>
> I'm trying to write a model query that will return a queryset along
> with the latest (and earliest) data from 2 related models.
>
> Right now I'm doing something like this:
>
> objects = Model1.objects.filter(user=3).select_relate
On Sun, 2008-12-07 at 18:09 -0800, Dave Dash wrote:
> Without knowing too much about your code, the only thing I can say,
> having had a similar issue, was that select_related witha specified
> depth generally made for more efficient queries.
This is quite true. Also remember that if you know w
Without knowing too much about your code, the only thing I can say,
having had a similar issue, was that select_related witha specified
depth generally made for more efficient queries.
For fun, I started on some code to output database queries on all my
pages while I'm debugging:
Queries
8 matches
Mail list logo