Reputation: 737
I am having trouble bulk inserting documents with the PHP SDK. I have to insert each one individually like
$temp = $db->upsert("key here", "value here");
I can achieve about 500 / second. I have attempted to use the cbcdocloader but I cant generate json faster than just using the SDK to insert them directly. I am trying to insert multiple documents with one insert so I dont have to generate all the traffic. Is there a way to do this with an array structure like below?
$data = array("key 1"=> "value 1", "key 2" => "value 2")
Upvotes: 0
Views: 702
Reputation: 21
I just did not believe it as I stumbled upon it somewhere a time ago, when I was searching for something else... But now I tried it, and it seems to work and I got a great performance increase (when doing a lot of inserts). It seems, you have to do it that way (using SDK 2.0 and upsert()
):
$bucket->upsert(array(
'key1' => array('value' => 'value1'),
'key2' => array('value' => array('jsonkey' => 'jsonvalue')));
You have to use 'value'
literally in the second array.
It seems, you also can specify options using:
$bucket->upsert(array(...), null, array('expiry' => 3600));
Maybe someone can verify this...
Upvotes: 2
Reputation: 6003
There is no bulk upload api call as such.
There is a semo of inserting in bulk http://docs.couchbase.com/couchbase-devguide-2.1/#performing-a-bulk-set.
Even, this does what you are already doing, in loops.
Upvotes: 0