[sqlalchemy] Re: Optimizing a slow query

2008-06-09 Thread EricHolmberg
On Jun 8, 5:09 am, beewee [EMAIL PROTECTED] wrote: Hi, thanks for your answers. Other improvements would include (as previously stated by Michael) would be to make sure you have indexed all of the items in your WHERE, ORDER BY, and ON clauses. I created this index: create index

[sqlalchemy] Re: Optimizing a slow query

2008-06-08 Thread beewee
Hi, thanks for your answers. Other improvements would include (as previously stated by Michael) would be to make sure you have indexed all of the items in your WHERE, ORDER BY, and ON clauses. I created this index: create index viewforum on forum_post (topic_id, id); Is this right? As a

[sqlalchemy] Re: Optimizing a slow query

2008-06-08 Thread Paul Johnston
Hi, create index viewforum on forum_post (topic_id, id); You probably want: create index forum_post_topic_id on forum_post (topic_id); Paul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group.

[sqlalchemy] Re: Optimizing a slow query

2008-06-08 Thread beewee
create index viewforum on forum_post (topic_id, id); You probably want: create index forum_post_topic_id on forum_post (topic_id); are you sure? A key on topic_id and id makes my query much faster for low offsets, while without it the query takes even for low offsets 10 seconds. Benjamin

[sqlalchemy] Re: Optimizing a slow query

2008-06-08 Thread Paul Johnston
Hi, create index forum_post_topic_id on forum_post (topic_id); are you sure? A key on topic_id and id makes my query much faster for low offsets, while without it the query takes even for low offsets 10 seconds. I didn't follow the beginning of this thread, so I'm not sure exactly

[sqlalchemy] Re: Optimizing a slow query

2008-06-07 Thread EricHolmberg
It looks like your sub-select (before the joins) is processing up to 140,015 records, so that will slow things down since the database may not optimize that sub-selection based upon your outer joins. As a quick check, try reducing the 140,000 offset to 0 (I know this won't work for your

[sqlalchemy] Re: Optimizing a slow query

2008-06-06 Thread beewee
Hi, I merged the two tables into a single one, changed the mapping but the query still needs more than 10 seconds :/ That's how EXPLAIN looks like now: http://paste.pocoo.org/show/63542/ I think the problem is this one: | 2 | DERIVED | forum_post | ALL| forum_post_topic_id

[sqlalchemy] Re: Optimizing a slow query

2008-06-05 Thread Michael Bayer
for starters I'd combine post_table and post_text_table into onenot much is accomplished there by having two tables. Also make sure forum_post.topic_id is indexed. On Jun 5, 2008, at 1:37 PM, beewee wrote: Hi, we're writing a bulleting board using sqlalchemy at the moment, but we