No-result queries N1QLRequest clarification

Hi
In below ref I see we can do certain level of optimization in n1ql query .
https://docs.couchbase.com/python-sdk/current/n1ql-queries-with-sdk.html#options

Can you please help me understand this little bit ?

No-result queries

As a convenience for queries which are not intended to yield multiple rows, you may use the returned N1QLRequest object’s execute() method. For queries which are intended to return only a single result, you can use the get_single_result() method. Both of the aforementioned methods are wrappers that iterate over the object internally and are intended to provide additional clarity inside your application’s code.

bkt.n1ql_query("CREATE PRIMARY INDEX ON default").execute()

I am simply using : row_iter = cb.n1ql_query(query) to return the N1QLRequest object , what is additional benefit I will get if I do execute() as well ?

From what I can tell, the ‘execute’ isn’t an optimization, per se. It’s just a convenient way to execute a N1QL query when you don’t expect it to return any data (e.g. a CREATE, like in the example).

1 Like

thanks @matthew.groves . that explains …
do you know if I can leverage the power of Multi-thread of multi-processing while creating index using such statement to make it run faster with more power and parallelism ?

@eldorado,

Generally speaking, there are some other ways you can create indexes to optimize performance. See Index Replication and Index Partitioning. If you have further specific questions about those options, I recommend asking in the N1QL forum as these are not Python-related.

Sure … thanks … I will ask …