Re: [SQL] slow group by query

2002-11-19 Thread Ellen Cyran
That's a whole lot faster. The query on 40 msa_codes that took 7 minutes, now only takes 10 seconds. Thanks a lot. At 11:54 AM 11/19/2002 -0500, Tom Lane wrote: Ellen Cyran <[EMAIL PROTECTED]> writes: > Here is the explain analyze: > Group (cost=637.18..696.52 rows=593

Re: [SQL] slow group by query

2002-11-19 Thread Ellen Cyran
I had to modify your query somewhat, but the one below that is pretty much the same took about 12 seconds so once I run it on five years it will take just as long. Thanks for the suggestion though. select distinct on (b.msa_code, b.sic, b.own, b.ind_div) b.msa_code, b.sic, b.own, b.ind_div, y19

Re: [SQL] slow group by query

2002-11-19 Thread Ellen Cyran
tal runtime: 67589.69 msec EXPLAIN Thanks for the help. At 10:21 AM 11/19/2002 -0500, Tom Lane wrote: Ellen Cyran <[EMAIL PROTECTED]> writes: > Is there any way to make this query faster? I have indexes on year, > msa_code, and sic. I've also tried it with > an index on the c

[SQL] slow group by query

2002-11-19 Thread Ellen Cyran
Is there any way to make this query faster? I have indexes on year, msa_code, and sic. I've also tried it with an index on the combined group by columns. I've made both sort_mem and shared_buffers bigger, but still this query takes 40 seconds when I select 4 msa_codes and 7 minutes when I sele