Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is (-inf or +inf) a good choice instead of `[-inf or +inf]` to express range info? #9756

Closed
wjhuang2016 opened this issue Mar 17, 2019 · 4 comments

Comments

@wjhuang2016
Copy link
Member

When excute desc select * from t;
We get

+-------------------+----------+------+------------------------------------------------------------+
| id                | count    | task | operator info                                              |
+-------------------+----------+------+------------------------------------------------------------+
| TableReader_5     | 10000.00 | root | data:TableScan_4                                           |
| └─TableScan_4     | 10000.00 | cop  | table:t, range:[-inf,+inf], keep order:false, stats:pseudo |
+-------------------+----------+------+------------------------------------------------------------+
2 rows in set (0.00 sec)

The range info here is [-inf,+inf], according to #9231 and #8588, we can improve it as [NULL,+inf) or (NULL,+inf) when explain select * from t use index(idx) where a is not null;

It seems that (-inf or +inf) is more reasonable than [-inf or +inf].
Should we use (-inf or +inf) even the scan is not a full range scan?

@eurekaka
Copy link
Contributor

From the code perspective, NULL is "less" than -inf, if we adjust the display like your suggestion, when the range is full range with NULL, it would be like [NULL, +inf), and this implies that -inf is included in the range, which is inconsistent with the implication of (-inf, +inf)?

@wjhuang2016
Copy link
Member Author

I got it. So we should use [NULL,+inf] to express a full range scan with NULL and (NULL,+inf] to express a full range scan without NULL?

@eurekaka
Copy link
Contributor

I prefer [NULL, +inf] for full range, while [-inf, +inf] for full range without null. @zz-jason @winoros what's your opinions?

@winoros
Copy link
Member

winoros commented Mar 18, 2019

Another case is that the inf of some numeric type is an actual number not an unbounded limit.
For bigint type, +inf is 2^63-1 for signed. +inf] is the same with 2^63-1] and +inf) is the same with 2^63-1). There're some reasons that we cannot treat the +inf of some numeric type as an unbounded limit for now. So to not annoy our users, i prefer use [] for all types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants