mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 19:12:03 +00:00
Merge pull request #6380 from 4ertus2/perf
Hotfix for Decimal comparison
This commit is contained in:
commit
b06bb0a9df
@ -26,10 +26,12 @@ namespace ErrorCodes
|
||||
template <typename T>
|
||||
int ColumnDecimal<T>::compareAt(size_t n, size_t m, const IColumn & rhs_, int) const
|
||||
{
|
||||
auto other = static_cast<const Self &>(rhs_);
|
||||
auto & other = static_cast<const Self &>(rhs_);
|
||||
const T & a = data[n];
|
||||
const T & b = other.data[m];
|
||||
|
||||
if (scale == other.scale)
|
||||
return a > b ? 1 : (a < b ? -1 : 0);
|
||||
return decimalLess<T>(b, a, other.scale, scale) ? 1 : (decimalLess<T>(a, b, scale, other.scale) ? -1 : 0);
|
||||
}
|
||||
|
||||
|
30
dbms/tests/performance/order_by_decimals.xml
Normal file
30
dbms/tests/performance/order_by_decimals.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<test>
|
||||
<tags>
|
||||
<tag>sorting</tag>
|
||||
<tag>comparison</tag>
|
||||
</tags>
|
||||
|
||||
<type>loop</type>
|
||||
|
||||
<stop_conditions>
|
||||
<all_of>
|
||||
<iterations>5</iterations>
|
||||
<min_time_not_changing_for_ms>10000</min_time_not_changing_for_ms>
|
||||
</all_of>
|
||||
<any_of>
|
||||
<iterations>50</iterations>
|
||||
<total_time_ms>60000</total_time_ms>
|
||||
</any_of>
|
||||
</stop_conditions>
|
||||
|
||||
<query>SELECT toInt32(number) AS n FROM numbers(1000000) ORDER BY n DESC</query>
|
||||
<query>SELECT toDecimal32(number, 0) AS n FROM numbers(1000000) ORDER BY n</query>
|
||||
|
||||
<query>SELECT toDecimal32(number, 0) AS n FROM numbers(1000000) ORDER BY n DESC</query>
|
||||
<query>SELECT toDecimal64(number, 8) AS n FROM numbers(1000000) ORDER BY n DESC</query>
|
||||
<query>SELECT toDecimal128(number, 10) AS n FROM numbers(1000000) ORDER BY n DESC</query>
|
||||
|
||||
<main_metric>
|
||||
<min_time/>
|
||||
</main_metric>
|
||||
</test>
|
@ -0,0 +1,2 @@
|
||||
1000000
|
||||
1000000
|
14
dbms/tests/queries/0_stateless/00880_decimal_in_key.sql
Normal file
14
dbms/tests/queries/0_stateless/00880_decimal_in_key.sql
Normal file
@ -0,0 +1,14 @@
|
||||
DROP TABLE IF EXISTS t1;
|
||||
DROP TABLE IF EXISTS t2;
|
||||
|
||||
CREATE TABLE t1 (str String, dec Decimal64(8)) ENGINE = MergeTree ORDER BY str;
|
||||
CREATE TABLE t2 (str String, dec Decimal64(8)) ENGINE = MergeTree ORDER BY dec;
|
||||
|
||||
INSERT INTO t1 SELECT toString(number), toDecimal64(number, 8) FROM system.numbers LIMIT 1000000;
|
||||
SELECT count() FROM t1;
|
||||
|
||||
INSERT INTO t2 SELECT toString(number), toDecimal64(number, 8) FROM system.numbers LIMIT 1000000;
|
||||
SELECT count() FROM t2;
|
||||
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
Loading…
Reference in New Issue
Block a user