Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004
    Posts
    762
    Plugin Contributions
    0

    Default Database Collation - Can they be mixed?

    For years, our database was latin1_swedish_ci collation.

    Sometime last year, in order to curb some of the linkpoint_api errors we were getting with invalid XML characters due to foreign addresses, we changed many tables to be utf8_unicode_ci collation.

    Now that we have upgraded to 1.5.1, I notice that our database is still a mixture of both these collations. Some tables are UTF8, others are Latin1.

    We are experiencing major MySQL hangups that are slowing down and crippling our server recently, and I'm trying to narrow down anything that could be causing it.

    MY QUESTION: was is the RECOMMENDED collation for all database tables in ZenCart? Should I go ahead and make sure ALL TABLES are utf8_unicode_ci, or should I revert everything back to latin1_swedish_ci?

    For the record, I noticed that in the zencart Config files, the following variable is set: define('DB_CHARSET', 'utf8');

    Looking forward to a response!

    - Jeff
    - Jeff

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Database Collation - Can they be mixed?

    Some fields (text/binary/varchar) have a collation, some don't. If the fields are never used in SQL joins with other fields using a different collation, then there's no *technical* requirement for them to all be the same. Knowing what joins are used requires detailed query analysis of all database activity, and of course that's not likely something you have intimate knowledge of. I mention it because you asked whether things need to match: answer is yes and no.

    If you are having database problems related to collation, then you'll be getting SQL errors, which should be visible in PHP logs including those redirected by Zen Cart to the /logs/ folder.

    Merely changing the collation at the "database" level or the "table" level only establishes what collation will be used when additional tables/fields are created, and does not directly change existing fields or existing tables.
    That is to say: collation only really matters at the "field" level.
    ... which then begs the warning:
    Converting fields from one collation to another can be risky since any multibyte characters already in those fields will be damaged when ALTERing the field structure unless you take special specific precautions to preserve things correctly.

    Of course, as you say, there's a lot to be said for consistency and of course it's cleaner and simpler if everything's using the same collation. And of course having it consistent rules out that piece as a contributing factor to any other problems.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. mixed sql collation
    By plc613 in forum General Questions
    Replies: 4
    Last Post: 24 Apr 2014, 02:26 PM
  2. Replies: 3
    Last Post: 6 Feb 2012, 12:59 PM
  3. v150 Character set/database collation/date settings
    By mi16chap in forum General Questions
    Replies: 2
    Last Post: 1 Feb 2012, 01:19 AM
  4. Database Collation
    By Ninja Scott in forum Upgrading to 1.5.x
    Replies: 0
    Last Post: 4 Jan 2012, 08:09 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR