I'd like to filter my rows based on a numeric column. Problem is that the input is a pattern - for e.g. - a number starting with 2045 or something. I could do this:
select *
from my_table
where num_column like '2045%';
It works but that doesn't let me use index on the column. The implicit to_char
on num_column reduces the performance.
Is there a more suitable way in which I could query the same and still use indexes?
This assumes the number always start with the given input (not in between or end) and the value in the column is of variable number of digits.
CONCAT(your_input, num_column)
– Ankit Bajpai Oct 3 '17 at 11:41