Re: Slow query. Any way to speed things up?

2011-03-29 Thread Fabian Büchler
Hello Matthias, 2011/3/29 Matthias Kestenholz > On Tue, Mar 29, 2011 at 2:27 PM, Fabian Büchler > wrote: > > I've analyzed the query using pgAdmin and it seems the most time is being > > spent with a the GroupAggregate. > > This is because of so many columns being listed in the GROUP BY clause.

Re: Slow query. Any way to speed things up?

2011-03-29 Thread Matthias Kestenholz
On Tue, Mar 29, 2011 at 2:27 PM, Fabian Büchler wrote: > I've analyzed the query using pgAdmin and it seems the most time is being > spent with a the GroupAggregate. > This is because of so many columns being listed in the GROUP BY clause. > Creating two-column indexes over event_id and date or so

Re: Slow query. Any way to speed things up?

2011-03-29 Thread Fabian Büchler
I've analyzed the query using pgAdmin and it seems the most time is being spent with a the GroupAggregate. This is because of so many columns being listed in the GROUP BY clause. Creating two-column indexes over event_id and date or some other combinations I've tried did not gain any perforamance.

Re: Slow query. Any way to speed things up?

2011-03-29 Thread bruno desthuilliers
On 29 mar, 12:26, Fabian Büchler wrote: (snip part about the generated query) > As Javier suggested, an index on the "events_eventdate" over table over > "event_id" and "date" could help, but I don't know how to create one using > Django's model techniques This is something you can do directly

Re: Slow query. Any way to speed things up?

2011-03-29 Thread Fabian Büchler
Hello Anssi, also thanks for your answer! I also believe that the generated query is more than suboptimal. Here it is. I've not deleted any columns, since there is something strange about the GROUP BY clause: all columns are listed there twice: SELECT "events_event"."id", >"events_event"

Re: Slow query. Any way to speed things up?

2011-03-29 Thread Fabian Büchler
Hello Javier, thanks for your answer! The reason for one Event having multiple EventDates is simple: an event like a theatre can have multiple shows/screenings. Is there a way to add an index on event+date other than unique-together? ( http://docs.djangoproject.com/en/dev/ref/models/options/#uniq

Re: Slow query. Any way to speed things up?

2011-03-28 Thread akaariai
On Mar 28, 3:52 pm, Fabian Büchler wrote: > Now this query takes about 15 seconds to run on a database with about 5,000 > Events and 50,000 EventDates. > I'm running Django 1.3 (trunk) and PostgreSQL 9.0 on a relatively recent > quadcore machine. > > Is there any way to do a more efficient query

Re: Slow query. Any way to speed things up?

2011-03-28 Thread Javier Guerra Giraldez
On Mon, Mar 28, 2011 at 7:52 AM, Fabian Büchler wrote: > > Events have an EventOnlineManager with a "to_expire" method which should > select all Events with status=online and EventDates associated which date < > today. > >> class EventOnlineManager(models.Manager): >> >>     def get_query_set(se

Slow query. Any way to speed things up?

2011-03-28 Thread Fabian Büchler
Hello everyone, maybe someone can help me to speed up a quite slow query: I've got two models (only the important stuff outlined here): Events and EventDates class Event(models.Model): > status = models.SmallIntegerField(verbose_name=_(u"status"), > choices=STATUS_CHOICES, default=ST