Today our site started giving fatal error(DB Error: unknown error) screen when trying to view contact. Nothing recorded in php or apache log, but found below error in my CiviCRM logs

[nativecode=1116 ** Too many tables; MariaDB can only use 61 tables in a join]

Found a relevant issue/blog for this but none of them have provided any solutions. Is it a known issue in CiviCRM?

https://forum.civicrm.org/index.php%3Ftopic=34205.0.html https://issues.civicrm.org/jira/browse/CRM-21491

CiviCRM version: 5.15.2

CMS - Drupal

CiviCRM logging - OFF

Backtrace : https://pastebin.com/6vV59YDM

Any help or pointers would be appreciated.

  • 2
    I assume the CiviCRM logs has more context than this, like the backtrace. Could you please post it? Also list any extensions you're using? I haven't seen this before personally Aug 12, 2019 at 22:02
  • I remember seeing this on a Drupal 6 site, related to the search perhaps (in my case, not necessarily for you). I'd try looking in your mysql logs for more details (and follow Jon's advice for seeing where in the code this sql is getting generated). Since it's coming up while looking at a contact, I'd guess you've got some CMS integration or extension that's generating so many table joins.
    – Alan Dixon
    Aug 13, 2019 at 19:43
  • 1
    Updated my question to include backtrace link. I have renamed the table names in backtrace Aug 18, 2019 at 11:02

1 Answer 1


It looks like from your backtrace, its a bug in GDPR extension because its not possible to replicate in CiviCRM. Your system has many custom group for activity, and the extension code breaks when trying to retrieve results, Mysql supports max 61 joins in a query.

Possible solution:

  1. Disable custom group for activity which is not required.

  2. Restructure your custom group by moving custom fields into new/existing custom group and delete the ones not required. This is bit risky and will take lots of effort since UI may not allow you to move custom field if its defined for subtype. And if you have already used this field in webforms than probably you may need to retain the custom field ID.

  3. Apply the fix from here.



  • 1
    Yes agreed, we have 114/160+ custom sets for Activity. Option 1 is void since we need all of them, Option 2 sounds like danger of loosing data. We have turned off GDPR extension, but we need to have it enable ASAP as we have big event next week and we are expecting more than 20k volunteers applying for the position. Would it be a simple fix for the extension? Any pointers on how we can debug or fix the problem? Is there any other extension similar to GDPR? Aug 18, 2019 at 11:26
  • 1
    I have submitted a fix for this and have updated my answer to include the PR Link. Can you please try if it fixes your problem? Aug 18, 2019 at 11:59
  • Thank you so much pradeep, the fix worked for us. You are a life saver. Aug 18, 2019 at 20:16
  • cheers!!....... Aug 18, 2019 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.