N1ql Select query performance


#1

Hello. I just needed to know if there is any performance improvement in a select query with part of the ID of the document along with fields in the where clause verses only few fields without specifying the ID in the where clause of the query.


#2

The more specific the query, the better. And the more specific the index, the better. If you know the full id, that is best.


#3

For example, consider the below two queries.

select * from Employee where empId=123

select * from Employee E where meta(E).id like ‘EMP%2016-08-10’ and empId=123

Among the above two cases, will there be a performance improvement in the second case?


#4

This index will make your second query faster, especially on the upcoming Couchbase 4.5.1.

CREATE INDEX idx ON Employee( empId, META().id );


#5

Thanks @geraldss :slight_smile: