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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:09:03+00:00 2026-05-18T02:09:03+00:00

I have a MySQL DB containing entry for pages of a website. Let’s say

  • 0

I have a MySQL DB containing entry for pages of a website.
Let’s say it has fields like:

Table pages:

id  |  title  | content | date | author

Each of the pages can be voted by users, so I have two other tables

Table users:
id  |  name  | etc etc etc

Table votes:
id  |  id_user | id_page | vote

Now, I have a page where I show a list of the pages (10-50 at a time) with various information along with the average vote of the page.

So, I was wondering if it were better to:

a) Run the query to display the pages (note that this is already fairly heavy as it queries three tables) and then for each entry do another query to calculate the mean vote (or add a 4th join to the main query?).

or

b) Add an “average vote” column to the pages table, which I will update (along with the vote table) when an user votes the page.

nico

  • 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-18T02:09:04+00:00Added an answer on May 18, 2026 at 2:09 am

    Use the database for what it’s meant for; option a is by far your best bet. It’s worth noting that your query isn’t actually particularly heavy, joining three tables; SQL really excels at this sort of thing.

    Be cautious of this sort of attempt at premature optimization of SQL; SQL is far more efficient at what it does than most people think it is.

    Note that another benefit from using your option a is that there’s less code to maintain, and less chance of data diverging as code gets updated; it’s a lifecycle benefit, and they’re too often ignored for miniscule optimization benefits.

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

Sidebar

Related Questions

I have a MySQL table containing several fields; like this: id name ton dyr
I have a MySQL-InnoDB table with 350,000+ rows, containing a couple of things like
I have a mysql table containing a field name dtt_date and have values like
I have a MySQL db with a table containing two fields: check_date (of DATETIME
I have a mySQL table with fields containing copy that's being turned into XML.
I have a mysql table containing the values for 'display' and 'link'. I'd like
I have a MySql table containing stock quotes (stock_symbol, quote_date, open_price, high_price, low_price, close_price)
I have a MySQL table containing a listing of events that I am trying
I have a table watchlist containing today almost 3Mil records. mysql> select count(*) from
I have MySQL InnoDB table utf-8 encoded. This table has only id and name

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.