473,396 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Beginner: Enhancing postgresql performance

Context:
Pentium PIII, 128 MB RAM, 5400 RPM HD-10GB (of which 1.8 GB as swap
disk)
Debian linux testing, Postgresql 7.4.2 from the deb box.
Beginner with Postgresql but not with linux

At office, I'm on the verge of receiving (fragmented in text format
files) the readings of electricity load at each quarter of hour of
1,800 recorders for a couple of years. In a nutshell It means to store
and retrieve for study 1,800 * 365 *2 = 1,314,000 records exactly,
each made at least of the 96 readings + id-recorder +date.

After having convinced my IT-Dept morbidly prone to Micro$oft to
install in our lan an old PC doomed to perish with debian and
postgresql, I built on it a fake db, similar to that with which I'm
going to work, to have a go with PG and "taste" it. To be on the safe
side, you know.....

The db is made of 2 tables one as I told before and the other with all
the information on each recorder such as location, date of
installation, precision, etc. linked to the previous, cumbersome
table, the one made of 1,340,000 recs, each of which is composed by a
date field, an int4 as recorder code and 96 decimal field of 6 figure
after the point for the readings. By and large the db is 3.8 GB.

I'm astonished by the fact that, in spite of the poor hardware, a:

select sum(field1), avg(field2) from db;

takes roughly 5 min. only to be executed (mean of 20 trials always
changing the fields), leaving - in the process - 2.5 MB (out of 128
MB) of memory free and a mere 4 MB of the 1.8 GB of the swap area
occupied.

Nonetheless I'm asking your most revered help to try to improve
"dramatically" this performance.

Is there any action I could take to improve the performance of this
specific db?

Vittorio
Nov 23 '05 #1
2 1514
On 2004-07-26, Vittorio <vi***@email.it> wrote:

I'm astonished by the fact that, in spite of the poor hardware, a:

select sum(field1), avg(field2) from db;

takes roughly 5 min. only to be executed (mean of 20 trials always
changing the fields), leaving - in the process - 2.5 MB (out of 128
MB) of memory free and a mere 4 MB of the 1.8 GB of the swap area
occupied.

Is there any action I could take to improve the performance of this
specific db?


I know it's a bit non-purist, but something I've done for speeding up
the performance of a similar set of data is to have an extra table
containing pre-calculated values.

So in your case you might have a table containing the sum and avg for
each *day*. To calculate the sum and avg for a given time period you can
do a bit of work and only need the accurate values for the start and end
day. A little bit more manipulation but a significantly faster query
behind it.

In my case (around 1,000,000 records), this brought an individual
calculation down to under a second, from around a minute.

This assumes the "historical" data doesn't change much, perhaps only
being appended to. For cases where it can, even a nightly task
to recalculate the extra table can be worthwhile.

- Colin
Nov 23 '05 #2
"Colin Coghill" <mu******@under-the-fridge.com> wrote in message news:<sl*********************@www.under-the-fridge.com>...
On 2004-07-26, Vittorio <vi***@email.it> wrote:
.................................................. ...

I know it's a bit non-purist, but something I've done for speeding up
the performance of a similar set of data is to have an extra table
containing pre-calculated values.

So in your case you might have a table containing the sum and avg for
each *day*. To calculate the sum and avg for a given time period you can
do a bit of work and only need the accurate values for the start and end
day. A little bit more manipulation but a significantly faster query
behind it.

In my case (around 1,000,000 records), this brought an individual
calculation down to under a second, from around a minute.

This assumes the "historical" data doesn't change much, perhaps only
being appended to. For cases where it can, even a nightly task
to recalculate the extra table can be worthwhile.

- Colin


As a matter of fact I already wrote and have been using a function
(upon inserting & updating)which in another table puts the sum of the
96 readings (therefore the daily energy) by recorder and day. I could
do the same following your suggestion, summing up by day each of the
96 readings.

But before this "dirty", non-purist, solution is there any FURTHER
optimization I could carry out in terms of indexes, memory management,
etc.?

Again Vittorio
Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: gizmo | last post by:
I have a stored procedure that queries a database using a Select statement with some inner joins and conditions. With over 9 million records it takes 1 min 36 sec to complete. This is too slow...
10
by: Rada Chirkova | last post by:
Hi, at NC State University, my students and I are working on a project called "self-organizing databases," please see description below. I would like to use an open-source database system for...
33
by: Joshua D. Drake | last post by:
Hello, I think the below just about says it all: http://www.commandprompt.com/images/mammoth_versus_dolphin_500.jpg Sincerely, Joshua Drake
10
by: Josué Maldonado | last post by:
Hello list, I have 7.3.4 on RH 8, server hardware is a dual processor Intel Xeon 2.4 Ghz, 2G RAM. I was reading about tunning and would like to get some help from you, I changed some of the...
1
by: Ericson Smith | last post by:
Hi, We're thinking of moving to a 64 bit platform for our database. Does anyone have any stories of migration from 32 bit to 64 bits? * How did it impact performance? * Were there any gochas?...
1
by: Hought, Todd | last post by:
Hi all, trying to run a query against a table, to pull the date out, and order it. problem is, the date is stored in character (string) format, not as an actual timestamp, so parsing it back into...
9
by: Andy B | last post by:
If I bought one of these boxes/OS combos as a postgresql database server, would postgresql be able to make the best use of it with a huge (e.g. 40GB) database? Box: HP ProLiant DL585, with ...
17
by: Jim Strickland | last post by:
We currently are running a data intensive web service on a Mac using 4D. The developers of our site are looking at converting this web service to PostgreSQL. We will have a backup of our three...
0
by: Patvs | last post by:
I use poker software (HoldemManager) to keep track of the statistics (and show nice graphs) of millions of poker hand histories. This software (also PokerTracker 3) imports all the poker hands in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.