I have 3 indexed fields in a query: int
, int
, and varchar(250)
.
The query performs well when all 3 conditions are specified with real values. The int
columns always have values, but there are plenty of empty string varchar
values. Queries with the empty string varchar
parameter perform 2-3x slower than those that search a real string (e.g. 'hello'). The query against the varchar
column is a straight WHERE
clause (i.e. no LIKE
, just =
).
I've searched around a bit but really only seem to see academic type discussions around this and I, frankly, don't really care about how they can mean different things. I only care about the performance of the queries against a NULL
or empty string varchar
column.
Is this empty string the cause of the slowness? Would a NULL
in it's place improve things? I can easily turn existing empty strings into NULL
s and put some new logic in to make sure empty strings are always put in as NULL
s. I just figured I'd ask here to get the expert opinion on this.
I'll be toying around with this anyway but it'd be nice to get an outside view telling me if I'm just spinning my wheels on it, if that's the case.
empty string
is, for example, a third of the total values on the column? More? Less? We need more information...