Very long strings as primary keys in a database for caching

Posted by Bill Zimmerman on Stack Overflow See other posts from Stack Overflow or by Bill Zimmerman
Published on 2010-04-01T18:39:48Z Indexed on 2010/04/01 18:43 UTC
Read the original article Hit count: 349

Filed under:
|
|

Hi,

I am working on a web app that allows users to create dynamic PDF files based on what they enter into a form (it is not very structured data).

The idea is that User 1 enters several words (arbitrary # of words, practically capped of course), for example:

A B C D E

There is no such string in the database, so I was thinking:

  1. Store this string as a primary key in a MySQL database (it could be maybe around 50-100k of text, but usually probably less than 200 words)

  2. Generate the PDF file, and create a link to it in the database

  3. When the next user requests A B C D E, then I can just serve the file instead of recreating it each time. (simple cache)

The PDF is cpu intensive to generate, so I am trying to cache as much as I can...

My questions are:

  1. Does anyone have any alternative ideas to my approach

  2. What will the database performance be like?

  3. Is there a better way to design the schema than using the input string as the primary key?

© Stack Overflow or respective owner

Related posts about database

Related posts about key