Yash Gupta
Yash Gupta

Reputation: 588

storing long text pieces

I am coding an online notes web application, and want to have support for notes ranging from 200 characters to very long ones (~more than 10000 characters). These notes should be searchable.

Upvotes: 1

Views: 311

Answers (3)

deceze
deceze

Reputation: 522530

Use one table, with one TEXT column. That's perfectly suitable, MySQL can handle that without breaking a sweat. Put a FULLTEXT index on it for medium-advanced searching capabilities.

Upvotes: 4

Ted Hopp
Ted Hopp

Reputation: 234857

10,000 characters isn't all that large for MySQL. You can use a TEXT column to store up to 216 bytes. That's enough if your text is ASCII. If it's Unicode, then you can use a LONGTEXT field to store up to 232 bytes per record.

Designing separate tables for different note lengths is, I think, a bad idea. It will make querying much more difficult.

MySQL also supports full text searching. If you create an ISAM table, you can create a FULLTEXT index on the notes field to speed up searches (quite a bit). Search for FULLTEXT in the manual page for CREATE TABLE for details.

Upvotes: 4

Toby Allen
Toby Allen

Reputation: 11211

  • No
  • No
  • No
  • Use full text search in mysql or just a like '%search%' which would be a bit slower.

This kind of size of document is a doddle to a modern database, just built it and dont worry about it.

Upvotes: 2

Related Questions