Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7532939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:35:49+00:00 2026-05-30T05:35:49+00:00

I have a table that caches data (shared hosting so no memcached) to a

  • 0

I have a table that caches data (shared hosting so no memcached) to a MySQL table.

The concept is this:

I have a page that loads (static) data and then cache then:

  • If the cache does not exist then it queries the page then render the HTML and save it to the cache table.
  • If a page does not exist in cache, it executes 12 queries (menu, page content, SEO, product list, etc.) then saves the rendered HTML in the table.

The cache table is like this:

=cache=
url varchar(255) - primary key
page mediumtext

Now I think I’m doing the right thing, based on what I have (shared host, no caching like memcached, etc.) but my question is this:

Because the URL is a varchar index but because numeric IDs (like int) are faster, is there a way to convert a URL like /contact-us/ or /product-category/product-name/ to a unique integer? Or is there any other way to optimize this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:35:51+00:00Added an answer on May 30, 2026 at 5:35 am

    I would create some form of hash which would allow a shorter key. In many cases something simple like a hash of the request path may be viable. Alternatively something even simpler like CRC32(‘/your/path/here’) may be suitable in your situation as a primary key. In this example the following columns would exist

     urlCRC INT(11) UNSIGNED NOT NULL (PRIMARY KEY)
     url VARCHAR(255) NOT NULL
     page MEDIUMTEXT
    

    You could then take this a step further, and add trigger BEFORE INSERT which would calculate the value for urlCRC, i.e. containing

    NEW.urlCRC = CRC32(NEW.url)
    

    You could then create a stored procedure which takes as argument inURL (string), and internally it would do

    SELECT * FROM cacheTable WHERE urlCRC = CRC32(inURL);
    

    If the number of rows returned is 0, then you can trigger logic to cache it.

    This may of course be overkill, but would provide you a numeric key to work on which, assuming there are no conflicts, would suffice. By storing the url as VARCHAR(255) also then if a conflict does occur, you can easily regenerate new hashes using a different algorithm.

    Just to be clear, I just use CRC32() as an example off the top of my head, chances are there are more suitable algorithms. The main point to take away is that a numeric key is more efficient to search so if you can convert your strings into unique numerics it would be more efficient when retrieving data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

good evening, i have a mysql table that contain the users data and i
I have table that I insert data with following query (from c# code): INSERT
I have a table that has redundant data and I'm trying to identify all
I have a table that is created in a DataList in ASP.Net. This table
I have a mysql table with over 4 million of data; well the problem
Say I have a table or 2 that contains data that will never or
I have a domain class in grails 1.5 that represents data from a table
Hey guys, I have a Table View that has been populated with 21 data:
I have a table in SQlite that I'm using to cache some data. I'm
I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.