I have this query
select name || ' ' || sure_name from users
which has this result
'test test'
'test1 test1'
...
I need to create a filter for this query. But I’m wondering what would be best way of creating it. I came up with this:
select name || ' ' || sure_name from users
where name || ' ' || sure_name = 'test test'
But I’m wondering how efficient will be this query as the concating happens twice (in the select statement and also in the where statement)
EDIT
the filter could look like
like '%test t'
The concatenation itself is not the problem, but the access to the rows.
For example, if you have an index on sure_name or on name, it is better to query with separate columns.
But if you don’t have any indexes, don’t bother. The performance will be roughly the same with your query.
However, if you add an index
your query will perform better.