hummingBird hummingBird - 1 year ago 88
SQL Question

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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download