Let me show you some data in database, you will understand it.

mysql> select * from plans where plan_id = 184;
+---------+-------------------+---------------------+-----------+
| plan_id | name              | create_date         | author_id |
+---------+-------------------+---------------------+-----------+
|     184 | It's a test plan  | 2008-06-04 21:37:10 |       754 |
+---------+-------------------+---------------------+-----------+
1 row in set (0.00 sec)

mysql> select * from plan_texts where plan_id = 184;
+---------+-------------------+-----------+---------------------
+-----------+
| plan_id | plan_text_version | editor_id | modify_date         |
plan_text |
+---------+-------------------+-----------+---------------------
+-----------+
|     184 |                 1 |    754    | 2008-06-04 21:37:10 |
foo       |
+---------+-------------------+-----------+---------------------
+-----------+
|     184 |                 2 |    754    | 2008-06-04 21:37:10 |
bar       |
+---------+-------------------+-----------+---------------------
+-----------+
1 row in set (0.00 sec)

The most important thing is there are a lot of plans with the same
plan_id but different plan_text_version in table plan_texts.

But I have no idea how to model the two tables with relationshi, and
there's no relationship field can connect between them.

I have no idea how to handle it with Django ORM so far.

So I need your help.


On Mar 10, 11:01 am, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Mon, 2009-03-09 at 19:22 -0700, K*K wrote:
> > Are there some other solution of it ?
>
> I still don't understand the problem.
>
>
>
> > The more than 2000 queries is from the get_latest_text() function, it
> > will be generate one query each plan. I have more than 2000 plans so
> > it will generate more than 2000 queries.
>
> Why is this method being called once for Plan object. You haven't
> described what triggers this call.
>
> If you have know the Plan objects in advance, then retrieving all the
> associated PlanTexts should be possible in a single query. However, that
> requires knowing how this is called. So please explain the data flow a
> bit more.
>
> Regards,
> Malcolm
--~--~---------~--~----~------------~-------~--~----~
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