2017-07-20 56 views
0

默認情況下,prestodb通過執行區分大小寫的組。但我想知道如何做不區分大小寫的。一種方法是將所有的東西,在柱爲小寫,然後即Case Insensitive group by in prestodb

select * from (select lower(name_of_the_column)), other_columns from table) 
where conditions.. 
group by name_of_the_column 

的一種方式,我們可以減少時間是通過將條件括號內的選擇statment執行組。有沒有更好的方法?

+1

您是否使用子查詢測量了包裝減少了時間? AFAIK'選擇較低(name_of_the_column),... group by lower(name_of_the_column)'應該工作相同。 –

+0

yaa有效。謝謝。 – arman

+0

然後,我會將我的評論轉換爲答案 –

回答

0

您不需要將lower(...)推入子查詢中。如果你只是寫:

select lower(name_of_the_column), ... 
from ... 
group by lower(name_of_the_column) 

presto將做每個行只有一次(不是兩次)的小寫轉換。