Here is the query plan:
NOTICE: QUERY PLAN:
Index Scan using forums_messages_pk on forums_messages (cost=0.00..3.92 rows=1 width=108)
SubPlan
-> Seq Scan on forums_messages fm2 (cost=0.00..2141.01 rows=1 width=12)
EXPLAIN
I also tried explain verbose, but it have way too much information I think.
Here is the table description. It looks like the tree_sortkey has an index.
openacs.org-dev=# d forums_messages
Table "forums_messages"
Attribute | Type | Modifier
-------------------+--------------------------+------------------------
message_id | integer | not null
forum_id | integer |
subject | character varying(200) |
content | text |
html_p | character(1) | not null default 'f'
user_id | integer | not null
posting_date | timestamptz | not null default now()
state | character varying(100) |
parent_id | integer |
open_p | character(1) | not null default 't'
tree_sortkey | bit varying |
max_child_sortkey | bit varying |
Indices: forums_mess_sk_forum_un,
forums_messages_pk
Constraints: ((open_p = 't'::bpchar) OR (open_p = 'f'::bpchar))
(((state = 'pending'::"varchar") OR (state = 'approved'::"varchar")) OR (state = 'rejected'::"varchar"))
((html_p = 't'::bpchar) OR (html_p = 'f'::bpchar))