Re: [GENERAL] small table, huge table, and a join = slow and tough query. cake inside!

2008-05-30 Thread Ed Fialkowski
Hey guys, thanks so much for all the help. I had never seen the HAVING clause anywhere. That solved so many problems. As for speed, I do not have indexing (most of my sql experience so far has been on fairly 'small' tables, which I guess would be considered tiny for everyone else). test=# VACUU

Re: [GENERAL] small table, huge table, and a join = slow and tough query. cake inside!

2008-05-28 Thread Alban Hertroys
On May 28, 2008, at 9:27 PM, edfialk wrote: example rows from huge table (almost 900,000 rows): fips, pollutant, value That's not really huge in comparison with other pgsql databases. There are terabyte installations out there ;) SELECT small.fips, small.geom, small.name, SUM(huge.value)

Re: [GENERAL] small table, huge table, and a join = slow and tough query. cake inside!

2008-05-28 Thread Klint Gore
edfialk wrote: So, what I need is all kinds of things, but to start (pseudo-query): SELECT small.fips, small.geom, small.name, SUM(huge.value) from small JOIN huge on huge.fips = small.fips WHERE (SUM(huge.value)) > 500 AND huge.pollutant='co'; wonder if that makes sense. Obviously, can't have

Re: [GENERAL] small table, huge table, and a join = slow and tough query. cake inside!

2008-05-28 Thread Gregory Stark
"edfialk" <[EMAIL PROTECTED]> writes: > So, what I need is all kinds of things, but to start (pseudo-query): > > SELECT small.fips, small.geom, small.name, SUM(huge.value) from small > JOIN huge on huge.fips = small.fips WHERE (SUM(huge.value)) > 500 AND > huge.pollutant='co'; > > wonder if that m

Re: [GENERAL] small table, huge table, and a join = slow and tough query. cake inside!

2008-05-28 Thread Stephen Denne
edfialk wrote: > SELECT small.fips, small.geom, small.name, SUM(huge.value) from small > JOIN huge on huge.fips = small.fips WHERE (SUM(huge.value)) > 500 AND > huge.pollutant='co'; > > wonder if that makes sense. Obviously, can't have an aggregate in > where clause, so I've tried a couple WHERE

[GENERAL] small table, huge table, and a join = slow and tough query. cake inside!

2008-05-28 Thread edfialk
Hey everybody, I'm having an issue executing the query I want. I've let a couple queries run a good 20 minutes and it still hasn't finished. For my app, this is way too long to be useful, and I'm not real sure what else I can do, let alone if my query is even what I want. So I'm really hoping th