Hi Niels, I have just updated my stable branch with your backport. It's fixed. Thanks! Jennie On Jul 04, 2010, at 18:42 , Niels Nes wrote:
On Sun, Jul 04, 2010 at 02:49:11PM +0200, Ying Zhang wrote:
Dear all,
I have a table "a" as the following:
sql>select * from a; +------+------+ | x | y | +======+======+ | 1 | 1 | | 1 | 2 | | 1 | 3 | | 2 | 1 | | 2 | 2 | | 2 | 3 | | 2 | 1 | | 1 | 2 | | 2 | 3 | +------+------+ 9 tuples
I want to count the number of distinct tuples in the table, so I did the following:
sql>select count(*) from (select distinct x,y from a) as b; +------+ | L17 | +======+ | 2 | +------+ 1 tuple sql>select count(x) from (select distinct x,y from a) as b; +------+ | L20 | +======+ | 2 | +------+ 1 tuple sql>select count(y) from (select distinct x,y from a) as b; +------+ | L21 | +======+ | 3 | +------+ 1 tuple
It looks like that count() automatically counts the distinct values of x and y, while "select distinct x,y from b" does give me what I want:
sql>select distinct x, y from b; +------+------+ | x | y | +======+======+ | 1 | 1 | | 1 | 2 | | 1 | 3 | | 2 | 1 | | 2 | 2 | | 2 | 3 | +------+------+ 6 tuples
Is this an expected behaviour of count()? If yes, how can I get the #tuples of "select distinct x,y from b"?
Thanks in advance!
Jennie
PS> info about mserver5: Jenny it seems one of the m5 optimizers breaks the count (select distinct) case. In current this seems fixed again.
Niels
$ mserver5 # MonetDB server v5.18.6, based on kernel v1.36.6 # Serving database 'demo', using 4 threads # Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically linked # Found 7.751 GiB available main-memory. # Copyright (c) 1993-July 2008 CWI. # Copyright (c) August 2008-2010 MonetDB B.V., all rights reserved # Visit http://monetdb.cwi.nl/ for further information #warning: please don't forget to set your vault key! #(see [prefix]/stable/debug/etc/monetdb5.conf) # Listening for connection requests on mapi:monetdb://127.0.0.1:50000/
include sql; # MonetDB/SQL module v2.36.6 loaded
------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
-- Niels Nes, Centrum Wiskunde & Informatica (CWI) Science Park 123, 1098 XG Amsterdam, The Netherlands room L3.14, phone ++31 20 592-4098 sip:4098@sip.cwi.nl url: http://www.cwi.nl/~niels e-mail: Niels.Nes@cwi.nl