Re: Postgresql Index & expensive queries [n00bie alert]
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 "public.press_page"
Column | Type | Modifiers
------------+------------------------+---------------------------------------------------------
id | integer | not null default nextval('press_page_id_seq'::regclass)
article_id | character varying(255) | not null
page | character varying(100) |
pgnumber | smallint | not null
Indexes:
"press_page_pkey" PRIMARY KEY, btree (id)
"press_page_article_id" btree (article_id)
"press_page_article_id_like" btree (article_id varchar_pattern_ops)
Check constraints:
"press_page_pgnumber_check" CHECK (pgnumber >= 0)
Foreign-key constraints:
"press_page_article_id_fkey" FOREIGN KEY (article_id) REFERENCES press_article(publication) DEFERRABLE INITIALLY DEFERRED
On Friday, October 19, 2012 8:16:25 PM UTC-7, 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://dpaste.org/vxRs4/
Here is the 'guts' of the view: [4] http://dpaste.org/w0b2z/
Total Postgresql/SQL n00b, so this may be a stupid statement. I'm wondering if an index on '"press_page"."article_id"' wouldn't speed things up a bit?
In dev, I don't have the amount of data that exists in production, so I can't easily/realistically recreate this scenario.
FWIW, I'm running:
- Django 12.04
- Postgresql 9.1.5
- Django 1.4.1
I'm using memcache on the view to cache it, it helped take page load down significantly, but I was wondering if there wasn't something I could do from the DB side of things since I know it's this query that is taking the page so long to load.
Thanks!
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/_3B-jlev3KsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home