Delete 1 Billion doc having doc's key- company_name_employeeid

I have a situation in my production couchbase cluster having version 6.0.1.
I have a doc_type = “eventing_history” which is having 4 years customer event data. Size of this doc_type is 2TB and docs in this doc_type is approx 1 Billion.

Now I want to delete the data for this doc_type and leave only current month data.

I tried n1ql delete syntax but it was getting time out after some time. and I don’t think that N1QL can delete 1 billion docs.

Please suggest correct approach to delete 1 billion docs having same key prefix.

Best option will be use covered index and get the document keys.
Then USE SDK set/touch the document expiration to 1sec. Let the document expiration run through at his own time in background and delete.

Vishal_Sharma - Another method would be to use the Eventing Service to do this example (will work for 6.5+):

// 1. Bucket Alias
// 2. src_bkt
// 3. <<your bucket to purge data from>>
// 4. read+write
function OnUpdate(doc, meta) {
  // filter out non-interesting docs
  if (doc.type !== "eventing_history") return;

  // this is a bucket DEL operation.
  delete src_bkt[meta.id];
}

The above is just a slight modification to " basicBucketOps" from Examples: Terse Scriptlets in the Eventing documents.

Even better you can apply some additional logic and do a “Cascade Delete” if needed to clean up associated documents.