N1QL Query without Primary Index

Is it possible to use N1QL Query without Primary Index( or any Index)??

{ClientContextId: 1::2Message: Error: 4000 No primary index on keyspace {***}. Use CREATE PRIMARY INDEX to create one.}

If your query uses existing indexes, yes.

We intentionally removed primary index on our production to prevent unexpected full scan.

1 Like

My bucket has no indexes and I don’t want to create index too. Is it possible to use N1QL query ??

If you don’t have indexes at all, and your’e doing N1ql queries – well I haven’t tried that, but performance wise this would seem like a bad idea. You’re going to be forcing the DB to look through every single document every single time, so performance wise I’m not sure this will be much better than storing all of your documents in an array in memory and scanning over them each time. O(n) each time, which is what indexes are trying to prevent

In addition to the good answers above, you can also at the USE KEYS syntax in N1QL. USE KEYS does not use any index.