【问题标题】:ClickHouse , Issue with select top n and order by primary keyClickHouse ,选择 top n 并按主键排序的问题
【发布时间】:2019-07-24 09:40:02
【问题描述】:

当我像这样查询时,我有一个包含 30 亿行的表

Select * from tsnew where time > 971128806382 and time <971172006000
limit 100

它工作正常,需要 0.2 秒 但是当向查询中添加订单时:

Select * from tsnew where time > 971128806382 and time <971172006000
order by time desc
limit 100

需要很长时间(超过 20 秒)。

create table tsnew(
ext_rec_num Nullable(UInt64),
xdr_id Nullable(UInt64),
xdr_grp Nullable(UInt64),
xdr_type Nullable(UInt64),
xdr_subtype Nullable(Int16),
xdr_direction Nullable(Int16),
xdr_location Nullable(Int16),
time UInt64,
stop_time UInt64,
transaction_duration Nullable(UInt64),
response_time Nullable(UInt64),
protocol Nullable(Int16),
chunk_count Nullable(Int16),
dpc Nullable(Int32), 
opc Nullable(Int32), 
first_link_id String,
last_dpc Nullable(Int32),
last_opc Nullable(Int32),
last_link_id String,
first_back_opc Nullable(Int32),
first_back_link_id String,
calling_ssn Nullable(Int16),
called_ssn Nullable(Int16),
called_sccp_address String,
calling_party_address String,
response_calling_address String,
root_end_code Nullable(Int32),
root_cause_code Nullable(Int32),
root_cause_pl Nullable(Int16),
root_failure Nullable(Int16),
root_equip Nullable(Int16)
)
ENGINE = MergeTree()
PARTITION BY toInt64(time/3600000)*3600000 
order by time
SETTINGS index_granularity = 8192

谁能帮我解决这个问题?

【问题讨论】:

  • 能否提供表定义(CREATE TABLE-query)?
  • 我用表格定义更新了问题

标签: clickhouse


【解决方案1】:

已知issue。希望它会被合并asap。订阅 PR 并在 PR 合并时升级您的 CH。

【讨论】:

  • 谢谢 slesh,您能否指导我如何升级我的 CH 以使用此 PR 中的修复程序,我通过此命令安装了 CH sudo apt-get install -y clickhouse-server clickhouse-client
  • 这取决于您的系统。最新版本的 CH 应该在您系统使用的包存储库中可用,请确保您在 sourcelist 中有 yandex 包存储库(请检查此guid)。作为替代方式,您可以 build 来自源的最新 CH
  • 我做了构建步骤,但我之前已经安装了它,现在我有 2 个实例?如果是,那么我如何运行最后一个(我构建的那个)?
  • 不,你只有一个。百分百确定,您可以卸载以前的 CH,然后安装一个新的。
猜你喜欢
  • 2010-10-23
  • 2011-02-25
  • 1970-01-01
  • 2017-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-20
  • 1970-01-01
相关资源
最近更新 更多