How to execute Couchbase queries when Query Workbench timeout ?

 

If you are executing a large query which is timing out from Query Workbench. You can use any one of the below two methods and run it in the background:

Execute Couchbase commands from a file:

/opt/couchbase/bin/cbq -e http://Any_Cluster_IP:8091 -u username -p 'Password' --file="<File_name_with_extension>" -o="output_filename.txt"

Example: /opt/couchbase/bin/cbq -e http://192.168.1.1:8091 -u Administrator -p 'Password' --file="create_indexes.txt" -o="output.log"

create_indexes.txt (each statement separated with ;(semi-colon))

CREATE PRIMARY INDEX `#primary` ON `bucket1` WITH { "num_replica":1 };
CREATE PRIMARY INDEX `#primary` ON `bucket2` WITH { "num_replica":1 };
   

Execute/Run a Couchbase Query in the backend (without timeout):


curl -u 'username:password' http://Query_Node_IP:8093/query/service -d 'statement=select query here;' > bucket_list.json

Example: curl -u 'Administrator:password' http://192.168.1.2:8093/query/service -d 'statement=select name from system:keyspaces;' > bucket_list.json

Note:

To trigger the command in the background, you can use

  • nohup <any of the above two curl commands> &

    [OR]

  •  curl -u 'username:password' http://Query_Node_IP:8093/query/service -d 'statement=select query here;' > bucket_list.json
  • Once above query started executing, (without quotes) press "ctrl + z"
    (you should see "stopped")
  • Immediately (without quotes) press, "bg"
    (Now the job will start in the background)
  • To monitor, (without quotes) press "jobs" (or) ps -ef | grep -i curl
  •  

────────────────────────────────────────

DISCLAIMER

The purpose of sharing the content on this website is to Educate. The author/owner of the content do not warrant that the information provided on this website is fully complete and shall not be responsible for any errors or omissions.The author/owner shall have neither liability nor responsibility to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the contents of this website. So, use the content of this website at your own risk.

For Copyright Content Removal Please Contact us by Email at besttechreads[at]gmail.com
 

Post a Comment

Previous Post Next Post