File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "use of char versus varchar" Watch "use of char versus varchar" New topic
Author

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 ?



Thanks
Arvindh
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
Consultant @ Xebia. Sonny Gill Tweets
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30405
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: use of char versus varchar