SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: char vs varchar

  1. #1
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I understand how they work, and I remember I've seen somewhere mentioned that varchar is slower than using char
    Is that right? And is that a big difference/slow-down if use varchar?

    Thanks
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  2. #2
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Kevin says in MySQL, there could be a possible slow down in reading records from a disk file. I don't think this will be much of an issue if you have a fast database server with decent drives.

    Personally after reviewing MySQL documentation more I can not determine an advantage of using a VARCHAR over a CHAR in that database since both are limited to a paltry 255 characters. The only way you would be able to tell is to run some timed tests of your own storing the same amount of data in both datatypes.

    The only time it would be a problem is when you sort your queries, since sorts are usually done in temporary disk files to conserve memory. And then only after there are thousands of rows.

    I have a query at work that pulls active customers out of a Sybase database. All the fields are VARCHAR fields and it takes about 5 minutes to process 1400 zip codes and find the active customers for those zip codes out of approximately 2 million rows. The results are then sorted by monthly payments. The resulting record set was then written to a flat textfile for distribution to Sales and Marketing. The resulting file contained over 250,000 records. All in five minutes.

    If I could get this data into MySQL it would make an awesome test.
    Wayne Luke
    ------------


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
  •