Closed (fixed)
Project:
Chatroom
Version:
5.x-1.x-dev
Component:
Code
Priority:
Minor
Category:
Task
Assigned:
Reporter:
Created:
1 May 2007 at 21:34 UTC
Updated:
15 Jul 2007 at 22:15 UTC
Jump to comment: Most recent file
The SQL statement in chatroom.install calls for the chatroom_msg.msg field to be longtext. This is not good. It wastes space and makes MySQL perform worse. Since chat messages are hardly ever in the vicinity of 4,294,967,296 bytes long, wouldn't it make more sense to speed the db up by defining that column as varchar(255), or, if you really need more, TEXT(512)?
$ok = $ok && db_query("CREATE TABLE {chatroom_msg} (
cmid int(11) NOT NULL AUTO_INCREMENT,
ccid int(11) NOT NULL,
uid int(11) NOT NULL,
msg_type varchar(64) NOT NULL,
/* msg longtext NOT NULL,*/
msg text(512) NOT NULL,
session_id varchar(255) NOT NULL,
recipient varchar(255) NOT NULL,
modified int(11) NOT NULL default '0',
PRIMARY KEY (cmid),
KEY ccid (ccid),
KEY session_id (session_id),
KEY recipient (recipient),
KEY modified (modified)
) $utf_declaration;");
$ok = $ok && db_query("CREATE TABLE {chatroom_msg_archive} (
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | chatroom.install_1-1.patch | 1.01 KB | apotek |
| #1 | chatroom.install_1.patch | 1.01 KB | darren oh |
Comments
Comment #1
darren ohComment #2
apotek commentedMy bad: I just remembered that TEXT(512) won't work, but VARCHAR(512) will. Text doesn't seem to respect any length indicator. So I would make the patch say VARCHAR(512).
I have tested with this change, and the appliation quite gracefully just truncates submitted text. However, maybe we ought to think of a way to use an alert message when someone submits a string longer than n characters.
But this is a good start. Will definitely improve performance.
Comment #3
apotek commentedHere's the modified patch for setting the msg column to varchar(512).
Comment #4
darren ohFixed in CVS commit 71985. I limited the number of characters that users can enter into the text field to 128 to prevent messages from being truncated.
Comment #5
(not verified) commented