Re: Django ManyToMany performance?

2013-10-29 Thread Tom Evans
On Mon, Oct 28, 2013 at 8:23 PM, Ruturaj Dhekane wrote: > Thanks Daniel and Robin. > > Have we seen the scales where Many-to-many DBs through Django work well? > Like 50K articles in 5K publications. Numbers are really meaningless. One of our legacy products has a database with 300 million rows i

Re: Django ManyToMany performance?

2013-10-28 Thread Ruturaj Dhekane
Thanks Daniel and Robin. Have we seen the scales where Many-to-many DBs through Django work well? Like 50K articles in 5K publications. The aim of this question was to make a design choice too - whether I should use Django constructs/calls directly or should i write my own SQL to make queries - as

Re: Django ManyToMany performance?

2013-10-27 Thread Robin St.Clair
First of all , any DBMS that is misused by design or in operation will give poor performance.. There is an excellent mature database available for Django developers, PostgreSQL. It works fine on the same machine as you are developing on. MongoDB is NOT a suitable DB for general purposes. It is

Re: Django ManyToMany performance?

2013-10-27 Thread Daniel Roseman
On Sunday, 27 October 2013 00:46:17 UTC+1, Ruturaj Dhekane wrote: > Hi all, > > I have a particular datastructure where there are two objects > 1. A document - and a lot of its properties - like content, version, > timestamp etc. > 2. Contributors - basically people represented by unique IDs > >

Django ManyToMany performance?

2013-10-26 Thread Ruturaj Dhekane
Hi all, I have a particular datastructure where there are two objects 1. A document - and a lot of its properties - like content, version, timestamp etc. 2. Contributors - basically people represented by unique IDs A document can have many contributors and a contributor can author many documents.

Re: ManyToMany Performance

2010-01-30 Thread Russell Keith-Magee
On Sun, Jan 31, 2010 at 1:38 AM, chefsmart wrote: > Let's say I have two models -  Article and Publication. Article has a > field > > publications = models.ManyToManyField(Publication) > > Let's say I present the user with a series of checkboxes representing > publications (much like the ModelMult

ManyToMany Performance

2010-01-30 Thread chefsmart
Let's say I have two models - Article and Publication. Article has a field publications = models.ManyToManyField(Publication) Let's say I present the user with a series of checkboxes representing publications (much like the ModelMultipleChoiceField, but I am not using ModelForms here) and gettin

Re: ManyToMany performance

2008-10-01 Thread [EMAIL PROTECTED]
What you could do is create the intermediary table explicitly using the through keyword: http://docs.djangoproject.com/en/dev//topics/db/models/#extra-fields-on-many-to-many-relationships then you can do queries on the table. Alex On Oct 1, 7:17 pm, "Dan W." <[EMAIL PROTECTED]> wrote: > This is

ManyToMany performance

2008-10-01 Thread Dan W.
This is my first time building an app with django and so far I've been more than happy with it. However, I can't seem to figure out how to sufficiently optimize queries for ManyToMany relationships. Here is a model to illustrate my problem: class Book(models.Model): name = models.CharField(m

Re: ManyToMany performance..

2008-09-04 Thread krylatij
sorry, you need story = Story.objects.filter(pk=1).extra(select={'main_section': sub_select }).values('main_section', 'other_field1', 'other_field2' ) [0] because we get here list of dictionaries Good luck! --~--~-~--~~~---~--~~ You received this message because

Re: ManyToMany performance..

2008-09-04 Thread krylatij
You can use an extra select to get additional parameter 'main_section' This is for MySQL and it's only sample you need to test it in your DB to make sure, that it works sub_select = """SELECT section_name FROM %(table_section)s as sc, % (table_section_story)s as st

Re: ManyToMany performance..

2008-09-04 Thread [EMAIL PROTECTED]
I modified the 'get_main_section' method in this way.. def get_main_section(self): try: sections = list(self.id_section.all().order_by('order')) if (len(sections) > 1): section_name = sections[1] else: section_name =

Re: ManyToMany performance..

2008-09-03 Thread krylatij
I still think you need second query. as i understand from your code get_main_section will return list of Sections in Story? I mean this string: (section_name = self.id_section.all().order_by('order') ) bad: if (len(self.id_section.all()) > 1):#hits DB section_name = self.id_section.

Re: ManyToMany performance..

2008-09-03 Thread [EMAIL PROTECTED]
I was not enough precise.. 'Story' object has a method get_main_section... def get_main_section(self): try: if (len(self.id_section.all()) > 1): section_name = self.id_section.all().order_by('order') [1] else: section_name = self.i

Re: ManyToMany performance..

2008-09-03 Thread krylatij
it seems you need extra select anyway or use .extra(...) to add additional args to db query (http://www.djangoproject.com/documentation/db-api/#extra-select-none- where-none-params-none-tables-none-order-by-none-select-params-none) But i don't understand. Imagine we have Story with 3 Sections And

Re: ManyToMany performance..

2008-09-03 Thread krylatij
Solution #1: use select_related() method when you get your Story from db: Story.objects.get(pk=3).select_related() Solution #2: add to your Section class definition method: def __unicode__(self): return self.section_name and change your template to: {{ story.id_

Re: ManyToMany performance..

2008-09-03 Thread [EMAIL PROTECTED]
I tried with select_related, but it read only foreignKey and not ManyToMany relations.. The section object already has __unicode__ method.. def __unicode__(self): return u'%s - %s' % (self.id_site.domain, self.section_name) Thanks Davide On 3 Set, 15:40, krylatij <[EMAIL PROTECTED]

ManyToMany performance..

2008-09-03 Thread [EMAIL PROTECTED]
Hi All.. I've a performance problem with manyToMany relations.. I've a model like this: class Story(models.Model): title = models.TextField(verbose_name = "titolo" ,max_length=200,core=True) abstract = models.TextField('sommario',max_length=400,core=True) text = models.TextField(v