
On Wed, Jan 28, 2009 at 02:21:37PM -0500, Chris Curvey wrote:
On Wed, Jan 28, 2009 at 11:47 AM, dariuszs
wrote: Hi, If I rewrite this query like this
select * from (select gender,count(*) from table1 group by gender) as t1 where t1.gender in ('F','M');
It takes about 2 seconds which is wonderful however how do I apply this to very complicated queries? Thanks. Dariusz.
I might suggest that it will be cleaner to do it this way.
select gender, count(*) from table1 group by gender having gender in ('F','M');
(In the past, I've found that the construct "select ... from (select ....)" ends up creating SQL that's really hard to debug. YMMV.)
indeed a good idea --- [cs]hould have been mine ... ;-) dariuszs, feel free to test/trace this one on your data, too. Stefan
------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |