You may catch this error when working with lists:
The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator
There are several fixes to this, most notably by updating the thresholds in the web application settings in Central Administration (on premise) but you can't do it on Online.
However, even working with both on-premise and online developing a 'recent file/folder/doc set' view tool, it became apparent that changing the view limits didn't make a difference anyway.
For little queries (a single list with a few thousand items) you don't usually see this. However, if you are doing web wide,SiteColllection or Recursive queries, this becomes a real problem in a live site setup.
It turns out that it's all in the CAML query - yes, yet another anomaly we find that's never documented. So the issue that in the CAML query, we have to be careful what we use in terms of nesting - a query can be really long (for example, filtering out using <Neq> to eliminate specific file types - for example, xml, xsl, css using the DocIcon field) or short HOWEVER, if your CAML query includes both <And> and <Or> viola, you get the error.
My assumption here is that the OR query portion means there's too much hashing going on to properly calculate the number of rows it will return (FYI Row Limit doesn't fix this).
The fix can be a pain but it works - make sure that you ONLY use <And>. This can complicate your queries but if you think them through, you can always work it out.
UPDATE: This MAY not fix it either. It turns out that if the database is exceedingly large (like over the limit), the error still occurs.
One other tidbit:
If you are looking for recently created or modified files (and folders, etc.), be sure to only use the Modified date in the query (if you use Created then Or Modified, the query blows up as above). Remember that the Created/Modified dates are always filled when created so you do have add some logic to split them (i.e. If Created = Modified the status is "created" - if Modified greater than Created, status = modified).