From: Nick Fankhauser <nickf@ontko.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: A plan returned by explain doesn't make sense to me
Date: Fri, 5 Apr 2002 11:27:30 -0500
Message-ID: <NEBBLAAHGLEEPCGOBHDGEEGCELAA.nickf@ontko.com> (raw)
In-Reply-To: <24465.1018022022@sss.pgh.pa.us>
> That seems strange to me also, particularly if the index column ordering
> is indeed actor_id,case_id and not the other way round
Tom-
Actually, it *is* the other way around- I didn't realize that could make a
difference. Here's the line that creates it:
create unique index actor_case_assignment_both on
actor_case_assignment(case_id,actor_id);
I reversed the order, and now the explain looks more like I expected:
develop=# explain SELECT * FROM CRIMINAL_DETAIL WHERE case_id = '102SC01353'
ORDER BY CHARGE_COUNT,CHARGE_NUMBER;
NOTICE: QUERY PLAN:
Sort (cost=9263.85..9263.85 rows=1 width=308)
-> Hash Join (cost=155.06..9263.84 rows=1 width=308)
-> Hash Join (cost=120.53..6034.05 rows=79880 width=260)
-> Seq Scan on charge (cost=0.00..2664.80 rows=79880
width=184)
-> Hash (cost=109.82..109.82 rows=4282 width=76)
-> Seq Scan on criminal_disposition (cost=0.00..109.82
rows=4282 width=76)
-> Hash (cost=34.53..34.53 rows=4 width=48)
-> Nested Loop (cost=0.00..34.53 rows=4 width=48)
-> Index Scan using case_data_case_id on case_data
(cost=0.00..4.01 rows=1 width=24)
-> Index Scan using actor_case_assignment_case_id on
actor_case_assignment (cost=0.00..30.42 rows=7 width=24)
I think this solves my immediate problem, but it seems like even with the
reversed order, the planner shouldn't have chosen the combined index to
drive the query, so I'm happy for now, but I fear that I've added a task to
someone's list in the developer's enclave.
I'll attach a schema dump to an off-list email to to you. Although we're not
incredibly proud of it, I think the company would consider it proprietary &
not to be posted publicly.
I'm running postgresql v7.1.3 on Debian
Thanks for the help, & let me know if there is any other info I can pass
along to help figure out what is happening.
-Nick
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: nickf@ontko.com, tgl@sss.pgh.pa.us
Subject: Re: A plan returned by explain doesn't make sense to me
In-Reply-To: <NEBBLAAHGLEEPCGOBHDGEEGCELAA.nickf@ontko.com>
References: <24465.1018022022@sss.pgh.pa.us> <NEBBLAAHGLEEPCGOBHDGEEGCELAA.nickf@ontko.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox