From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Different plan for very similar queries |
Date: | 2015-05-31 15:50:55 |
Message-ID: | 32282.1433087455@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
"Peter J. Holzer" <hjp-pgsql(at)hjp(dot)at> writes:
>>> Merge Semi Join (cost=316864.57..319975.79 rows=1 width=81) (actual time=7703.917..30948.271 rows=2 loops=1)
>>> Merge Cond: ((t.term)::text = (f.berechnungsart)::text)
>>> -> Index Scan using term_term_idx on term t (cost=0.00..319880.73 rows=636 width=81) (actual time=7703.809..7703.938 rows=3 loops=1)
>>> Filter: (((facttablename)::text = 'facttable_stat_fta4'::text) AND ((columnname)::text = 'berechnungsart'::text))
> Just noticed that this is a bit strange, too:
> This scans the whole index term_term_idx and for every row found it
> checks the table for the filter condition. So it has to read the whole
> index and the whole table, right? But the planner estimates that it will
> return only 636 rows (out of 6.1E6), so using
> term_facttablename_columnname_idx to extract those 636 and then sorting
> them should be quite a bit faster (even just a plain full table scan
> and then sorting should be faster).
Hm. I do not see that here with Tomas' sample data, neither on HEAD nor
9.1: I always get a scan using term_facttablename_columnname_idx. I agree
your plan looks strange. Can you create some sample data that reproduces
that particular misbehavior?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tomas Vondra | 2015-05-31 16:05:52 | Re: Different plan for very similar queries |
Previous Message | Yves Dorfsman | 2015-05-31 14:23:10 | Re: Postgres is using 100% CPU |