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 843515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:08:25+00:00 2026-05-15T06:08:25+00:00

We are using a table with a structure imposed upon us more than 10

  • 0

We are using a table with a structure imposed upon us more than 10 years ago. We are allowed to add columns, but urged not to change existing columns.

Certain columns are meant to represent dates, but are put in different format. Amongst others:

 * CHAR(6): YYMMDD
 * CHAR(6): DDMMYY
 * CHAR(8): YYYYMMDD
 * CHAR(8): DDMMYYYY
 * DATE
 * DATETIME

Since we now would like to do some more complex queries, using advanced date functions, my manager proposed to duplicate those problem columns to a proper FORMATTED_OLDCOLUMNNAME column using a DATE or DATETIME format.

Is this the way to go? Couldn’t we just use the STR_TO_DATE function each time we accessed the columns? To avoid every query having to copy-paste the function, I could still work with a view or a stored procedure, but duplicating data to avoid recalculation sounds wrong.

Solutions I see (I guess I prefer 2.2.1)

1. Physically duplicate columns
1.1 In the same table
1.1.1 Added by each script that does a modification (INSERT/UPDATE/REPLACE/...)
1.1.2 Maintained by a trigger on each modification
1.2 In a separate table
1.2.1 Added by each script that does a modification (INSERT/UPDATE/REPLACE/...)
1.2.2 Maintained by a trigger on each modification
2. On-demand transformation
2.1 Each query has to perform the transformation
2.1.1 Using copy-paste in the source code
2.1.2 Using a library
2.1.3 Using a STORED PROCEDURE
2.2 A view performs the transformation 
2.2.1 A separate table replacing the entire table
2.2.2 A separate table just adding the date-fields for the primary keys

Am I right to say it’s better to recalculate than to store? And would a view be a good solution?

  • 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-15T06:08:25+00:00Added an answer on May 15, 2026 at 6:08 am

    I’ve been testing this all morning. I’ve duplicated the table 2 times:

    • once for using a view which
      transforms the VARCHAR field into a
      DATE field on each query, using
      STR_TO_DATE
    • once for adding a column and doing an UPDATE using STR_TO_DATE

    Afterwards I let loose a lot of different queries – the view performs a bit slower, as expected, but only tens of milliseconds.

    Since it does take me 7Mb extra to store the extra column, (and that has its implications on disk usage and RAM usage), and our server has CPU power to spare but not RAM/io, I’m leaning towards the “transform the CHAR into DATE on each query” solution.

    I’m not sure about using a VIEW, a Stored Procedure or just putting the STR_TO_DATE in each query I’ll be writing – but that’s more a “coding best practice” than an optimization.

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

Sidebar

Related Questions

I have this table structure and would like to map it using Fluent Hibernate
I'm using Hibernate 3.3.1 and am following along in modelling this sample table structure
I am using a MySQL table called login with the following structure: loginid, username,
Setup: Contact database using 4 tables Contacts Cities States Zips Structure: CREATE TABLE `contacts`
I'm using a particular database table like a Set data structure, i.e., you can
I'm building multi tenant application with shared table structure using Microsoft SQL Server. I
I'm using a table to save some text data with this structure: CREATE TABLE
Using the following database table structure: Order Table: OrderId OrderName OrderItem Table: OrderId ItemId
i'm using curl to retrieve a page which has a table structure as below.
I am trying to model the following table structure in Symfony 2.0 using annotations.

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.