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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:17:41+00:00 2026-06-03T01:17:41+00:00

Have a legacy LAMP application that I’m in the process of converting over to

  • 0

Have a legacy LAMP application that I’m in the process of converting over to the JVM.

The problem in question entails a scoring table with @250K records. Currently the “scoreType” column is represented as a tinyint, where 1 = goal, 2 = assist1, 3 = assist2.

For scoring leaders, to get goal/assist1/assist2 totals for each player, query snippet looks like:

SUM(IF(scoreType=1,1,0)) AS goals, SUM(IF(scoreType=2,1,IF(scoreType=3,1,0))) AS assists

Fair enough, does the job, but I’m wondering if, in terms of general schema design where query context will entail SUM, COUNT, etc. operations, it is better to break out limited choice sets like goal/assist1/assist2, win/loss/tie, etc. into separate columns rather than the tinyint approach?

In separate columns the query then becomes:

SUM(goal) AS goal, SUM(assist1) AS assist1, SUM(assist2) AS assist2

Which is a performance win (no need for if(cond,a,b) match) at the cost of slightly increased storage (3 columns vs. 1).

At the application layer one potential big win is moving from ORM non-supported SUM(if()) to column.Sum(); otherwise, I’ll need to keep non-statically typed string SQL queries with the all-in-one-column approach

Thoughts? How would you address, leave as is, or migrate DB and application code to 3 column approach?

Thanks for feedback!

  • 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-06-03T01:17:42+00:00Added an answer on June 3, 2026 at 1:17 am
    SELECT scoreType, COUNT(scoreType)
    FROM ...
    GROUP BY scoreType
    

    Wouldn’t it?


    For an honest timing to compare the alternatives, use the more verbose;

    SELECT COUNT(CASE WHEN scoreType = 1 THEN id ELSE NULL END) AS goals,
           ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have legacy C++ code that changes a process DACL and am trying to
Sorry if this is a silly question :-) Background I have legacy code that
I have a legacy object model that has content objects and a table designed
We have a legacy forms application that runs a bunch of 32 bit C++
I have a legacy Struts 1.2.8 application that I'm maintaining and porting from Oracle
I have a legacy VB6 application that was built using MSDE. As many client's
I have legacy DB that store dates that means no-date as 9999-21-31, The column
Ok, question does not really make sense. Here is the situation. I have legacy
I have a legacy MFC C++ application for Win CE 4.2 (x86 ONLY) which
I have one legacy web application based on struts2 (primarily using annotation). While debugging

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.