Re: Postgresql Index & expensive queries [n00bie alert]

2012-10-20 Thread Christophe Pettus
On Oct 20, 2012, at 11:34 PM, Barry Morrison wrote: > Looking further at Postgresql, what's interesting. Is it creates an 'id' > column and appends '_id' to what is assumed to be the id field (if none is > specified). > > Also, it appears the magic may have already created the indexes: It'

Re: Postgresql Index & expensive queries [n00bie alert]

2012-10-20 Thread Barry Morrison
Looking further at Postgresql, what's interesting. Is it creates an 'id' column and appends '_id' to what is assumed to be the id field (if none is specified). Also, it appears the magic may have already created the indexes: django_db=# \d press_page Table

Re: Postgresql Index & expensive queries [n00bie alert]

2012-10-20 Thread Barry Morrison
Here is what exists in Dev re: Query Plan from debug toolbar: QUERY PLAN Sort (cost=8.28..8.28 rows=1 width=740)Sort Key: pgnumber -> Index Scan using press_page_article_id_like on press_page (cost=0.00..8.27 rows=1 width=740)Index Cond: ((article_id)::text = 'Test'::text) On

Re: Postgresql Index & expensive queries [n00bie alert]

2012-10-20 Thread Barry Morrison
prefetch-related is awesome! Thank you for that. Thanks! Barry On Fri, Oct 19, 2012 at 11:54 PM, Xavier Ordoquy wrote: > Hi, > > As Samuel said, the first step is to install Django Debug Toolbar to see > what's going on with your queries. > Then you'll probably be interested in > https://docs.

Re: Postgresql Index & expensive queries [n00bie alert]

2012-10-20 Thread Barry Morrison
I am using Django Debug Toolbar locally for development. That is where I copied & pasted the SQL from. Even if I had a complete set of data for postgresql, my local machine is an 8-core, 16GB of RAM, with solid state hard drives. A LOT different than my 2CPU/1GB RAM/spindle disk VPS. I guess wh

Re: Postgresql Index & expensive queries [n00bie alert]

2012-10-19 Thread Xavier Ordoquy
Hi, As Samuel said, the first step is to install Django Debug Toolbar to see what's going on with your queries. Then you'll probably be interested in https://docs.djangoproject.com/en/1.4/ref/models/querysets/#prefetch-related Regards, Xavier Ordoquy, Linovia. Le 20 oct. 2012 à 05:16, Barry Mo

Re: Postgresql Index & expensive queries [n00bie alert]

2012-10-19 Thread Sam Lai
On 20 October 2012 14:16, Barry Morrison wrote: > I've got a pretty expensive query...Wondering if I can't speed things up in > regards to Postgresql. > > Here is the model: [1] http://dpaste.org/JmEeQ/ > > Here is the sql statement: [2] http://dpaste.org/GbfAJ/ > > Here is the template: [3] http:

Postgresql Index & expensive queries [n00bie alert]

2012-10-19 Thread Barry Morrison
I've got a pretty expensive query...Wondering if I can't speed things up in regards to Postgresql. Here is the model: [1] http://dpaste.org/JmEeQ/ Here is the sql statement: [2] http://dpaste.org/GbfAJ/ Here is the template: [3] http://dpaste.org/vxRs4/ Here is the 'guts' of the view: [4] h