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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:05:02+00:00 2026-06-09T20:05:02+00:00

I have a system that saves statistics for servers in a network. Later a

  • 0

I have a system that saves statistics for servers in a network. Later a user is able to consume all the data and plan their growth. Thus it is important to summarize the data into a graph ie across an hour, day, week, year, etc.

I’m trying to do something like this:

select created_time / 60, count(*)
from pm_server_stat
group by (created_time / 60);

--with this index
CREATE INDEX pm_server_stat_created_time_60
  ON pm_server_stat
  USING btree
  ((created_time / 60));

This is the explain i get

"GroupAggregate  (cost=189822.36..213951.06 rows=1206435 width=8)"
"  Output: ((created_time / 60)), count(*)"
"  ->  Sort  (cost=189822.36..192838.45 rows=1206435 width=8)"
"        Output: created_time, ((created_time / 60))"
"        Sort Key: ((pm_server_stat.created_time / 60))"
"        ->  Seq Scan on public.pm_server_stat  (cost=0.00..34967.44 rows=1206435 width=8)"
"              Output: created_time, (created_time / 60)"

Does anyone know why this happens? I suspect that the types might be different?

  • 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-09T20:05:03+00:00Added an answer on June 9, 2026 at 8:05 pm

    PostgreSQL doesn’t have “covering” indexes in 9.1 or before. That means it’s going to have to access the rows anyway, in which case it might as well scan them. They’re due to appear in 9.2 (currently in beta testing if you want to try it out) but I’m not sure they’d be smart enough for this anyway.

    It’ll never work once you want “total files served” or “total packets transmitted” anyway.

    Typically, for this sort of summarizing task you’d have one or more summary tables: stats_minute, stats_hour, stats_day, stats_week etc. How many you’d have would depend on total data size / performance requirements. Keep the summaries up to date with a simple cron-job. If data is going to be coming in with “late” timestamps you might need a slight lag or allow for recalculation.

    Then you can just have a union of the summary table with an actual sum of all the rows since the start of the current hour. That’s much less data to query and can be as fast as you might need.

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

Sidebar

Related Questions

I have a system that takes dynamic data, puts it in HTML for layout
I have a system that stores vectors and allows a user to find the
I have a session scoped class that contains an object to manage user statistics.
I have a wall posting system on a social network that I am currently
We have system here that uses Java JNI to call a function in a
I have big system that make my system crash hard. When I boot up,
I have a system that runs like this: main.exe runs sub.exe runs sub2.exe and
I have a system that will generate messages sporadically, and I would like to
We have a system that has some Bash scripts running besides Java code. Since
We have a system that runs in IIS. The system should always run using

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.