I have a field in my table that has a text data type.
Is there any performance difference for the following two sql queries:
select * from tablename where fieldname="xyz%";
select * from tablename where fieldname="%zyx";
If we execute these queries, this is what I think we will need to do:
We must match two regular expressions (xyz * and * zyx).
We will need to check string characters starting from the beginning.
For the first query, we will need to read the first three characters to see if there is a match, but for the second we will need to read until we get the end of the line to determine if a match has occurred. But if we have the length of the string stored somewhere, we can directly read the last three characters, giving similar performance, as in the first case.
My question is whether commercial databases like mysql and oracle have any performance difference when querying.
source
share