You have 3 tables doing the job: a table which stores node data, a table which stores paragraphs data, and a table which stores relation about node and paragraphs. Now you emptied the table which stores the paragraphs data, but the node-paragraph relation table is still there. So if you have added 4 paragraphs to a node and deleted that 4 paragraphs, still drupal assumes there should be 4 paragraphs attached to that node.
so if you want to delete them entirely you have to fetch node data which has "paragraph" field value, delete field value from each node and save it.
so here are steps :
you can run a database query on field table, and get all node-paragraph relations. now you have a list of all nodes that have a paragraphs, so having node ids and paragraph ids you can first remove paragraphs from node using a code like this:
$node = Node::load($nid);
$node->FIELD_NAME->setValue(array());
$node->save();
and then delete correspond paragraphs using a code like the one you mentioned. of course you don't need another query as you have paragraph ids.
if you don't mind removing all paragraph values from database and only don't like them to be shown in your node, then you can write an entityquery like this :
$query = \Drupal::entityQuery('node');
$query->exists('field_to_check');//Check A field value is NOT NULL
$ids = $query->execute();
so it gives you all nodes which has value for that field, then you only can run :
foreach($ids as $nid) {
$node = Node::load($nid);
$node->FIELD_NAME->setValue(array());
$node->save();
}