简体   繁体   中英

Orient distinct incorrect

I have the following output

orientdb {db=dict}> select count(distinct(pos)) from Synset;

----+------+-----
#   |@CLASS|count
----+------+-----
0   |null  |4    
----+------+-----

1 item(s) found. Query executed in 2.514 sec(s).
orientdb {db=dict}> select distinct(pos) from Synset;       

----+------+--------
#   |@CLASS|distinct
----+------+--------
0   |null  |n       
----+------+--------

1 item(s) found. Query executed in 0.012 sec(s).

What am I doing wrong? (the count of distinct values does not matches the select of this values. Actually there are 4 distinct values in db)

UPDATE [WTF]

orientdb {db=dict}> select * from (select distinct(pos) from Synset)

----+------+--------
#   |@CLASS|distinct
----+------+--------
0   |null  |n       
1   |null  |v       
2   |null  |a       
3   |null  |r       
----+------+--------

4 item(s) found. Query executed in 2.722 sec(s).

Try this: select distinct(pos) from Synset limit-1

The console and the studio adds the limit 20 automatically. So when you execute select distinct(pos) from Synset you actually returning the distinct values from the first 20 rows.

Now this select * from (select distinct(pos) from Synset) returns the expected result because the inner query doesn't have a limit, only the parent query have a limit of 20 but only have 4 results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM