-
-
Notifications
You must be signed in to change notification settings - Fork 262
Description
Submitted by: Tim Kelly (m00bh000)
Relate to CORE3460
I execute the following query often:
Select * FROM PEOPLE WHERE REGION_ID IN (:A, :B, :C)
:A = 'A2D3', :B = 'C1D4', :C = 'FFE3'
but the number of params which make up the IN predicate of the query changes very often, so the next time it might be:
Select * FROM PEOPLE WHERE REGION_ID IN (:A, :B, :C, :D, :E)
:A = 'A2D3', :B = 'C1D4', :C = 'FFE3', :D = '127D', :E = '123A'
This makes the query impossible to "PREPARE" / cache since there are many different versions of it depending upon the number of paramaters that are required. It would be much better just to have one query with a parameter which is a string-list, which could be converted into a set (as required by IN) using a function, say STR_LIST_TO_SET(<string_list>):
Select * FROM PEOPLE WHERE REGION_ID IN STR_LIST_TO_SET(:A)
:A = '''A2D3'', ''C1D4'', ''FFE3'', ''127D'',''123A'''
Why don't I just use regular-expressions? Because experimenting they are grossly inefficient compared with using IN \in this type of scenario.
What do people think?