Question: I have a table with 3 columns( name, objectroot\_dn, distinguishedname). Here **distinguishedname** is like a parent to **objectroot\_dn**. I have to find whether for each **objectroot\_dn** is there a child exists or not?

I can do this using the query below. It will return *True* if there is a child, *False* if there is not. But my problem is when the total dataset gets increased it takes lots of time.

For example, If the total number of row is 50,000 then it takes 10 mins for this query to complete.

Since I'm using a framework for different database, I can't index the columns.

```

SELECT
  name,
  objectroot_dn,
  distinguishedname,
  CASE
  WHEN (SELECT count(*)
        FROM (SELECT name
              FROM elaoucontainergeneraldetails
              WHERE objectroot_dn = dn.distinguishedname
              LIMIT 1) AS tabel1) > 0
    THEN 'True'
  ELSE 'False'
  END
FROM elaoucontainergeneraldetails AS dn
WHERE objectroot_dn = 'SOME_VALUE';
```

Please let me know how can I increase the speed of this query.

Thanks in advance. Appreciate all help.

Answer: 
It looks like you are passing the corpus into `wordcloud`, where you should just be passing a vector of the unique terms and their frequencies.

```
tdm<-TermDocumentMatrix(cleanFullCorpus)
termFreqs<-row_sums(tdm)

wordcloud(names(termFreqs), termFreqs, max.words = 100, random.order = FALSE, colors=brewer.pal(10,'Spectral'))

```
wordcloud() probably is NOT optimized to clean up for you. First get a vector of words and a vector of their associated counts for the ENTIRE CORPUS. Then pass this vector of length 100 to the wordcloud.