Re: [PERFORM] Benchmarking tools, methods

2011-11-28 Thread CSS
On Nov 19, 2011, at 11:21 AM, Greg Smith wrote: > On 11/18/2011 04:55 AM, CSS wrote: >> I'm also curious about benchmarking using my own data. I tried something >> long ago that at least gave the illusion of working, but didn't seem quite >> right to me. I enabled basic query logging on one of

Re: [PERFORM] PostgreSQL 9.1 : why is this query slow?

2011-11-28 Thread Tomas Vondra
On 28.11.2011 17:42, Joost Kraaijeveld wrote: > - Why does explain say it takes "7876150720 rows"? Any idea where this number came from? No matter what I do, the nested loop row estimates are alway very close to the product of the two estimates (outer rows * inner rows). Tomas -- Sent via pgsq

Re: [PERFORM] PostgreSQL 9.1 : why is this query slow?

2011-11-28 Thread Kevin Grittner
"Kevin Grittner" wrote: > If you really want the intersection, perhaps: Or maybe closer: with x as ( select word, count(*) as countall, count(case when filetype = 'f' then 1 else null end) as countf, count(case when filetype = 's' then 1 else n

Re: [PERFORM] PostgreSQL 9.1 : why is this query slow?

2011-11-28 Thread Kevin Grittner
Joost Kraaijeveld wrote: > I would like the answer to be "the number of times the word > appears in all three the queries", the intersection of the three > queries. That's still not entirely clear to me. If there are two 'f' rows, three 's' rows, and four 'n' rows, do you want to see an answ

Re: [PERFORM] PostgreSQL 9.1 : why is this query slow?

2011-11-28 Thread Joost Kraaijeveld
On Mon, 2011-11-28 at 11:05 -0600, Kevin Grittner wrote: > Joost Kraaijeveld wrote: > > > This query goes faster (6224 ms, but I am not sure it gives the > > correct answer as the result differs from my Java program): > > It seems clear that you want to see words which appear with all > three

Re: [PERFORM] PostgreSQL 9.1 : why is this query slow?

2011-11-28 Thread Kevin Grittner
Joost Kraaijeveld wrote: > This query goes faster (6224 ms, but I am not sure it gives the > correct answer as the result differs from my Java program): It seems clear that you want to see words which appear with all three types of files, but it's not clear what you want the count to represent

Re: [PERFORM] PostgreSQL 9.1 : why is this query slow?

2011-11-28 Thread Joost Kraaijeveld
On Mon, 2011-11-28 at 17:42 +0100, Joost Kraaijeveld wrote: > - Is there a way to rephrase the query that makes it faster? This query goes faster (6224 ms, but I am not sure it gives the correct answer as the result differs from my Java program): select word, count (word) from unique_words where

[PERFORM] PostgreSQL 9.1 : why is this query slow?

2011-11-28 Thread Joost Kraaijeveld
Hi All, I have a table with 665605 rows (counted, vacuum-ed): CREATE TABLE unique_words ( filename text NOT NULL, filetype text NOT NULL, word text NOT NULL, count integer,) The query is: select f.word , count(f.word) from unique_words as f, unique_words as s , unique_words as n where (f