I have a query like this:
( SELECT * FROM mytable WHERE author_id = ? AND seen IS NULL )
UNION
( SELECT * FROM mytable WHERE author_id = ? AND date_time > ? )
I also have these two indexes:
(author_id, seen)
(author_id, date_time)
I read somewhere:
Typically, a query can use only one index for each table when processing a proposal. WHERE
As you can see in my request, there are two divided sentences WHERE. So I want to know that “only one index per table” means that my query can use only one of these two indexes, or can it use one of these indexes for each subquery and both indexes are useful?
In other words, is this sentence true?
"one of these indices will always be used, and the other is useless"
source
share