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

  • Home
  • SEARCH
  • 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 6206985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:32:50+00:00 2026-05-24T05:32:50+00:00

Lets imagine that there are three tables – ‘users’, ‘products’ and ‘faves’ . In

  • 0

Lets imagine that there are three tables – 'users', 'products' and 'faves'. In user table are stored all users with something like 'id', 'username', 'email'; in 'products' : 'id', 'name', 'price'; in 'faves' : 'id', 'product_id' (ID of product, related with 'products'), 'user_id' (ID of user who added fave, related with ‘users’), 'modified_on'. Its dummy example and made only to illustrate what I’m talking about… (:

I often see that there are one more column for ‘products’ table. Its called ‘count_of_faves’ or something like that. Why does its needed? I mean, its easily possible to count faves for specified post like on-the-fly, right? Is it somehow related to speed of counting them when there are very many data?

Extra question:

Is there any better, more automatic, way to do +1 and -1 to ‘count_of_faves’ then each time making new query that updates that row?

  • 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-24T05:32:50+00:00Added an answer on May 24, 2026 at 5:32 am

    On a large-scaled system, you can save a lot of processing time by quickly retrieving the count_of_faves rather than having to recalculate the aggregate COUNT() on some rowset every time you need it. If you were, for example, to display the count_of_faves on each page, you would either need to recalculate it each time, or cache it somewhere. You can choose to cache it in your application code, in the session for example, or you can cache it in the database.

    Caching it in the database has a few benefits – when creating reports of your data outside your application code, the values are readily available for use.

    The operation:

    UPDATE table SET count_of_favs = count_of_favs + 1 WHERE id='whatever';
    

    is far less expensive to perform than it is to be recalculating the aggregate COUNT() all the time.

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

Sidebar

Related Questions

Let's imagine that I have to make a table with the following structure with
The issue I'm facing is that I have a stored procedure (lets call it
Lets imagine I have three projects in my solution. The first one is exe
Let's imagine: there's a website, a kind of job board. Products are virtual there.
Imagine that we have a website where users can read articles, view photos, watch
I have a JavaFX 2 table that is displaying contact details for people, lets
Imagine a three-column table, let's say TRAVELS with the columns NAME , and COUNTRY
Let's imagine that I have list of files at host1 find /path/to -name *.jpg
Let's imagine that I have a result of evaluating XPath expression //node/@*. MSXML6 returns
Let's imagine I want to make a templated function that returns the first element

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.