Suppose I have a table with column_a
and column_b
, containing 100k records.
I need to match either column_a
OR column_b
.
Will it be faster to create a new table containing only one column to match but twice the records?
Instead of this:
table_a
id column_a column_b
-- -------- --------
1 foo bar
SELECT ... WHERE "column_a" LIKE '%blah%' OR "column_b" LIKE '%blah%'
# will iterate through 100k records
I'll have this:
table_b
id column
-- ------
1 foo
2 bar
SELECT ... WHERE "column" LIKE '%blah%'
# will iterate through 200k records
What is cheaper, text matching or iteration?