Re: [PERFORM] Different plan for very similar queries

2015-07-19 Thread Peter J. Holzer
On 2015-05-29 10:55:44 +0200, Peter J. Holzer wrote: > wdsah=> explain analyze select facttablename, columnname, term, concept_id, > t.hidden, language, register > from term t where facttablename='facttable_stat_fta4' and > columnname='einheit' and exists (select 1 from facttable_stat_ft

Re: [PERFORM] Different plan for very similar queries

2015-05-31 Thread Tomas Vondra
On 05/31/15 18:22, Tom Lane wrote: Tomas Vondra writes: On 05/31/15 13:00, Peter J. Holzer wrote: (There was no analyze on facttable_stat_fta4 (automatic or manual) on facttable_stat_fta4 between those two tests, so the statistics on facttable_stat_fta4 shouldn't have changed - only those fo

Re: [PERFORM] Different plan for very similar queries

2015-05-31 Thread Tom Lane
Tomas Vondra writes: > On 05/31/15 13:00, Peter J. Holzer wrote: >> (There was no analyze on facttable_stat_fta4 (automatic or manual) on >> facttable_stat_fta4 between those two tests, so the statistics on >> facttable_stat_fta4 shouldn't have changed - only those for term.) > So maybe there was

Re: [PERFORM] Different plan for very similar queries

2015-05-31 Thread Tomas Vondra
On 05/31/15 13:00, Peter J. Holzer wrote: [I've seen in -hackers that you already seem to have a fix] On 2015-05-30 15:04:34 -0400, Tom Lane wrote: Tomas Vondra writes: Why exactly does the second query use a much slower plan I'm not sure. I believe I've found an issue in planning semi joins

Re: [PERFORM] Different plan for very similar queries

2015-05-31 Thread Tom Lane
"Peter J. Holzer" 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 wid

Re: [PERFORM] Different plan for very similar queries

2015-05-31 Thread Peter J. Holzer
[I've seen in -hackers that you already seem to have a fix] On 2015-05-30 15:04:34 -0400, Tom Lane wrote: > Tomas Vondra writes: > > Why exactly does the second query use a much slower plan I'm not sure. I > > believe I've found an issue in planning semi joins (reported to > > pgsql-hackers a f

Re: [PERFORM] Different plan for very similar queries

2015-05-30 Thread Tom Lane
Tomas Vondra writes: > Why exactly does the second query use a much slower plan I'm not sure. I > believe I've found an issue in planning semi joins (reported to > pgsql-hackers a few minutes ago), but may be wrong and the code is OK. I think you are probably right that there's a bug there: the

Re: [PERFORM] Different plan for very similar queries

2015-05-29 Thread Tomas Vondra
Hi, On 05/29/15 11:51, Peter J. Holzer wrote: A couple of additional observations: The total cost of both queries is quite similar, so random variations might push into one direction or the other. Indeed, after dropping and recreating indexes (I tried GIN indexes as suggested by Heikki on [1])

Re: [PERFORM] Different plan for very similar queries

2015-05-29 Thread Peter J. Holzer
On 2015-05-29 10:55:44 +0200, Peter J. Holzer wrote: > wdsah=> explain analyze select facttablename, columnname, term, concept_id, > t.hidden, language, register > from term t where facttablename='facttable_stat_fta4' and > columnname='einheit' and exists (select 1 from facttable_stat_ft