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
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:
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)
Generate the PDF file, and create a link to it in the database
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:
Does anyone have any alternative ideas to my approach
What will the database performance be like?
Is there a better way to design the schema than using the input string as the primary key?
© Stack Overflow or respective owner