简体   繁体   中英

Apache Hive LIKE 'string%' or substr?

I'm doing a query that counts % of https entries in a log. I can do it using substr or by using LIKE 'https%' :

  1. IF(url LIKE 'https%', 'https', 'http')
  2. IF(substr(url, 1, 5) = 'https', 'https', 'http')

Which of the two is better? I'm open to other alternatives.

The log itself is relatively big - several gigabytes.

Both work functionally, In my opinion the first one is more readable.

However I suggest you run a test and see if there is any significant performance difference between the two. Otherwise, just pick your favourite.

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