Let's assume i have this MySQL database under the name records. Table scheme would be as follows, where id is an index key and url is unique:
id BINGINT(20) UNSIGNED AUTO_INCREMENT
num_chars SMALLINT(4) UNSIGNED
url VARCHAR(1000) UNIQUE
This would be the table's data representation, basicaly:
-------------------------------------------
| id | num_chars | url |
-------------------------------------------
| 1 | 22 | https://www.google.com |
| 2 | 17 | https://yahoo.com |
| 3 | 16 | https://bing.com |
-------------------------------------------
num_chars is the url's number of characters.
My question is, considering the fact that this table will probably hit several millions of records: is there a performance improvement of this query:
SELECT * FROM records WHERE num_chars = 17 AND url = 'https://yahoo.com';
Over this one:
SELECT * FROM records WHERE url = 'https://yahoo.com';
I know that integer based queries are more efficient than string based ones (correct me if i'm wrong), therefore i wonder if filtering by num_chars before url would represent a efficiency improvement.
By the way, the advantage in this case is that i can easily calculate num_chars from url before performing the MySQL query, using PHP, Java, Python, etc.