File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes use of char versus varchar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "use of char versus varchar" Watch "use of char versus varchar" New topic

use of char versus varchar

arvindh seshadri
Ranch Hand

Joined: May 10, 2005
Posts: 45
Hi ,

we are performing a batch operations of insert and update . The volume of records is around 500,000. We found that the performance degrades if we use char against varchar in the tables.why is it so and What is the best practice ?

Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Probabely because, CHAR uses fixed sizes. Which means, for example, if you store 'ABCD' in a CHAR(50) field, it will be stored as 'ABCD' padded with 46 spaces.

The future is here. It's just not evenly distributed yet. - William Gibson
Sonny Gill LinkedIn
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32844

More specifically, this means that you can get less database rows per block of memory. The computer has to read from disk more times to get the same number of results.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: use of char versus varchar
It's not a secret anymore!