Categories
Development

Adjust GROUP_CONCAT() maximum length

I’m currently working on a redesign of a site of a good friend. He’s a professional photographer from Amsterdam and I built his first site in 2011. Back then, I build his site with nexCMS, my very own CMS, which was based on the Zend Framework. Throughout the years, my friend created almost 4000+ posts and uploaded 13.000+ images.

The nexCMS is a very lightweight CMS and only uses the following four database tables:

  • article
  • article_image
  • menu
  • user

Migrating 4000+ posts manually to WordPress, would take hundreds of hours, thus, I decided using the plugin WP All Import, which I can highly recommend. To use the plugin, however, I had to create a CSV file of the existing posts. To concatenate the article images into one row to import them as gallery images, I used the MySQL statement GROUP_CONCAT(). While the first imports went smooth, I suddenly saw a few posts where images were missing. After analysing this issue, I found out that GROUP_CONCAT() seems to have a maximum length of 1024 characters. Strange enough, on the MySQL reference I saw a maximum length of 1024 characters being mentioned.

Anyway, I faced an issue and found the reason. I just needed a solution for that issue. Thus, I looked up this issue and found out that I could increase the maximum character length for GROUP_CONCAT() by running the following query:

It took me a while to figure that out, thus, I hope that this post will help anyone that faces similar issues.

Leave a Reply