Re: pls help with a m2m sql

2006-07-26 Thread Maciej Bliziński
Hello Malcolm, I've decided to take a closer look at the performance of both types of queries. I've made a benchmark and tested combinations of two tags of two different frequencies. A statistical tool (R-project) was used to find a mathematical model of the query execution time. Conclusions ar

Re: pls help with a m2m sql

2006-07-23 Thread nkeric
Maciej Blizinski wrote: > I'd like to suggest alternative SQL solution which performs better. > With my example database Malcolm's query takes 214ms to execute, while > my query does the same job in 5.8ms, which is 36 times faster. > > My solution is described here: > http://groups.google.com/grou

Re: pls help with a m2m sql

2006-07-23 Thread nkeric
Malcolm Tredinnick wrote: > At the moment, you need to write some custom SQL to implement this. One > possible solution is here: > http://www.pointy-stick.com/blog/2006/06/14/custom-sql-django/ hi Malcolm, sorry I missed your link, I just look into your doc & code, pretty much the same as my fri

Re: pls help with a m2m sql

2006-07-23 Thread Maciej Bliziński
On Sun, 2006-07-23 at 22:09 +1000, Malcolm Tredinnick wrote: > Whilst your suggestion is slightly faster for smaller cases, the problem > is that it doesn't scale quite as well: there is an upper limit for the > number of joins a database can do, for example. For list-wise scaling, yes. I've once

Re: pls help with a m2m sql

2006-07-23 Thread Malcolm Tredinnick
On Sun, 2006-07-23 at 13:03 +0200, Maciej Bliziński wrote: > Hi Eric and Malcolm, > > On Sun, 2006-07-23 at 17:53 +1000, Malcolm Tredinnick wrote: > > At the moment, you need to write some custom SQL to implement this. One > > possible solution is here: > > http://www.pointy-stick.com/blog/2006/0

Re: pls help with a m2m sql

2006-07-23 Thread Maciej Bliziński
Hi Eric and Malcolm, On Sun, 2006-07-23 at 17:53 +1000, Malcolm Tredinnick wrote: > At the moment, you need to write some custom SQL to implement this. One > possible solution is here: > http://www.pointy-stick.com/blog/2006/06/14/custom-sql-django/ I'd like to suggest alternative SQL solution w

Re: pls help with a m2m sql

2006-07-23 Thread nkeric
o, the count(*) is unnecessary, select object_id from tagging_object_tag where tag_id in (15, 16) group by object_id having count(*)=2; ;) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: pls help with a m2m sql

2006-07-23 Thread nkeric
hi Malcolm, thank you very much for your quick reply! I knew I need to build my custom SQL, my friend (who is a db master :) just came back and suggests me to do this: select object_id, count(*) from tagging_object_tag where tag_id in (15, 16) group by object_id having count(*)=2; pretty cool

Re: pls help with a m2m sql

2006-07-23 Thread Malcolm Tredinnick
Hi Eric, On Sun, 2006-07-23 at 07:26 +, nkeric wrote: > hi all, > > I have a m2m table recording object & it's tags, here is part of the > table data: > > object_idtag_id > 115 > 116 > 215 > 316 > 415 > 4

pls help with a m2m sql

2006-07-23 Thread nkeric
hi all, I have a m2m table recording object & it's tags, here is part of the table data: object_idtag_id 115 116 215 316 415 416 417 I would like to select object_ids where tag_id