Re: Index usage

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Scott Matseas <smatseas(at)intrusic(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Index usage
Date: 2006-08-21 18:26:19
Message-ID: 5599.1156184779@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Scott Matseas <smatseas(at)intrusic(dot)com> writes:
> If I enable sequential scan the Index Cond in
> question gets replaced with a Seq scan.

What other planner parameters have you been fooling with?

With no data in the tables, I get a reasonably sane-looking plan,
so I'm thinking you've chosen bad values for something or other
(starting with enable_seqscan = off ;-))

explain
SELECT * FROM
last_summarized ls
JOIN tableA s ON s.table_idA > ls.summarized_id AND s.table_idA
<= ls.max_session_id
LEFT JOIN tableB sf ON s.table_idA = sf.table_idA AND sf.direction = 'a'::char
LEFT JOIN tableB sfb ON s.table_idA = sfb.table_idA AND sfb.direction = 'b'::char
WHERE ls.summary_name::text = 'summary'::text ;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------
Nested Loop Left Join (cost=6.16..54.51 rows=216 width=116)
-> Nested Loop Left Join (cost=6.16..42.05 rows=216 width=95)
-> Nested Loop (cost=6.16..29.58 rows=216 width=74)
-> Index Scan using last_summarized_pk on last_summarized ls (cost=0.00..8.02 rows=1 width=66)
Index Cond: ((summary_name)::text = 'summary'::text)
-> Bitmap Heap Scan on tablea s (cost=6.16..18.32 rows=216 width=8)
Recheck Cond: ((s.table_ida > ls.summarized_id) AND (s.table_ida <= ls.max_session_id))
-> Bitmap Index Scan on table_ida_pk (cost=0.00..6.16 rows=216 width=0)
Index Cond: ((s.table_ida > ls.summarized_id) AND (s.table_ida <= ls.max_session_id))
-> Index Scan using tableb_unq on tableb sfb (cost=0.00..0.05 rows=1 width=21)
Index Cond: ((s.table_ida = sfb.table_ida) AND (sfb.direction = 'b'::bpchar))
-> Index Scan using tableb_unq on tableb sf (cost=0.00..0.05 rows=1 width=21)
Index Cond: ((s.table_ida = sf.table_ida) AND (sf.direction = 'a'::bpchar))
(13 rows)

regards, tom lane

In response to

  • Index usage at 2006-08-21 17:35:53 from Scott Matseas

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Eamonn Kent 2006-08-21 18:50:02 Vacuum not identifying rows for removal..
Previous Message Scott Matseas 2006-08-21 17:35:53 Index usage