Hi,
We are going to build a web site using Drupal. I am new to Drupal CMS. While going through the drupal tables, i found that the 'type' field in 'node_type' table is varchar. I am eager to know - why the type fields are varchars instead of integers. I would like to know this because varchars are slow in table joins and searching. I believe there is a specific reason in making the type fields - varchars. Please let me know.
Thank you in advance,
Regards, T.Melantias, Programmer Analyst, Olive Technology
In response to "melantias toomaate" melantias@gmail.com:
Hi,
We are going to build a web site using Drupal. I am new to Drupal CMS. While going through the drupal tables, i found that the 'type' field in 'node_type' table is varchar. I am eager to know - why the type fields are varchars instead of integers. I would like to know this because varchars are slow in table joins and searching.
That's a painfully arbitrary statement ... can you back it up?
I know that in PostgreSQL, varchars are not significantly slower unless you're lacking indexes, which is an easy mistake to fix. Since you don't mention the backend you're using, I'll play the statistics and guess it's MySQL, and I don't know if MySQL exhibits the problem you are concerned with.
We are going to build a web site using Drupal. I am new to Drupal CMS. While going through the drupal tables, i found that the 'type' field in 'node_type' table is varchar. I am eager to know - why the type fields are varchars instead of integers.
Because node types are not integers? Node types are "page" and "story" and "asshat", not 1, 2 and 3. The modules you install (or the CCK node types you create) define the name of the node type and, since node types can come from everywhere, numbering them sequentially is not plausible.
It all depends on what one means by "slow" I suppose. If slow simply means "slower than integers," then he's probably right, regardless of the database.
Yes, joining on a text field is slow in any DB, and searching "slower" in any db also. That said, I don't believe the "type" field is used in any join.
Further, this is just something inherent in Drupal, the "type" field being a varchar. It would take some core patching to enumerate the field. One say to fix this is to do just that though, have the DB "enumerate" the field internally; that kind of gets harry though, depending on your db because you'll have to alter/update the field whenever a "type" is created and/or removed. But that's a solution to that issue that I can think of off the top of my head.
I know from my own experience integer field is much faster, I'd dare to say twice as fast as an integer field.
- Souvent22
_____
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Chris Johnson Sent: Tuesday, April 03, 2007 10:30 AM To: support@drupal.org Subject: Re: [support] Database : why the type fields are varchars
It all depends on what one means by "slow" I suppose. If slow simply means "slower than integers," then he's probably right, regardless of the database.