On Wed, Apr 1, 2009 at 5:34 PM, Miguel <migue...@gmail.com> wrote:

> Hi Karen,
> i didn't want to bother you too much (because of that I dindnt send too
> much code).
>

But without specifics on the model involved here there's nothing more I can
think to tell you that might help.  raw_id_admin on any (all) related object
fields (ForeignKey, ManyToMany, OneToOne) should get rid of all the
expensive 'select everything form this related table' queries when you
construct the ChangeManipulator.  From what you include below it is looking
like you've got lots of such queries...getting rid of just one or two by
adding a couple of raw_id_admin=True params isn't likely to be noticeable.
Or maybe your model has some entirely different issue, it's really hard for
me to guess in the absence of information.


> I think these model are bad implemented. I have put the raw_id_admin
> parameter to true but the point is that I have too many queries:
>
> >>> len(connection.queries)
> 53
>

That's a lot of queries for simply constructing a ChangeManipulator.  How
many related fields does this model have?  On how many of those have you
tried adding raw_id_admin=True?


>
> and some of them, all that goes to sportsound_plantilla_metodo_embebido,
> are really slow (around 1.7 seconds):
>
> {'time': '1.788', 'sql': u'SELECT
> `sportsound_plantilla_metodo_embebido`.`id`,`sportsound_plantilla_metodo_embebido`.`orden`,`sportsound_plantilla_metodo_embebido`.`ejercicio_id`,`sportsound_plantilla_metodo_embebido`.`numero_repeticiones`,`sportsound_plantilla_metodo_embebido`.`repeticiones_maximas`,`sportsound_plantilla_metodo_embebido`.`hasta_extenuacion`,`sportsound_plantilla_metodo_embebido`.`distancia`,`sportsound_plantilla_metodo_embebido`.`tiempo_ejecucion_m`,`sportsound_plantilla_metodo_embebido`.`tiempo_ejecucion_sg`,`sportsound_plantilla_metodo_embebido`.`altura`,`sportsound_plantilla_metodo_embebido`.`velocidad_excentrica`,`sportsound_plantilla_metodo_embebido`.`velocidad_concentrica`,`sportsound_plantilla_metodo_embebido`.`tipo_contraccion`,`sportsound_plantilla_metodo_embebido`.`ritmo_carrera`,`sportsound_plantilla_metodo_embebido`.`unidad_ritmo_carrera`,`sportsound_plantilla_metodo_embebido`.`frecuencia_cardiaca`,`sportsound_plantilla_metodo_embebido`.`frecuencia_cardiaca_1m`,`sportsound_plantilla_metodo_embebido`.`frecuencia_cardiaca_3m`,`sportsound_plantilla_metodo_embebido`.`porcentaje_carga`,`sportsound_plantilla_metodo_embebido`.`intensidad_subjetiva`,`sportsound_plantilla_metodo_embebido`.`peso`,`sportsound_plantilla_metodo_embebido`.`evaluar_numero_repeticiones`,`sportsound_plantilla_metodo_embebido`.`evaluar_distancia`,`sportsound_plantilla_metodo_embebido`.`evaluar_tiempo_ejecucion`,`sportsound_plantilla_metodo_embebido`.`evaluar_altura`,`sportsound_plantilla_metodo_embebido`.`evaluar_peso`,`sportsound_plantilla_metodo_embebido`.`evaluar_ritmo_carrera`,`sportsound_plantilla_metodo_embebido`.`evaluar_frecuencia_cardiaca`,`sportsound_plantilla_metodo_embebido`.`evaluar_frecuencia_cardiaca_1m`,`sportsound_plantilla_metodo_embebido`.`evaluar_frecuencia_cardiaca_3m`,`sportsound_plantilla_metodo_embebido`.`evaluar_intensidad`
> FROM `sportsound_plantilla_metodo_embebido`'}
>
> Actually these queries select all the parameters, that doesnt make any
> sense ( maybe is  the behaviour of manytomanyfield)
>
>
Django always selects all fields from the model.  Recently support has been
added to allow you to specify that only a subset of the fields should be
retrieved from the DB (see
http://docs.djangoproject.com/en/dev/ref/models/querysets/#defer-fields and
the following doc on only()) but that enhancement went in for Django 1.1,
and isn't available in any Django version where you are still using
ChangeManipulator.

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to