Re: Database tuning

From: Nevermind <never(at)nevermind(dot)kiev(dot)ua>
To: Antonio Fiol Bonnin <fiol(at)w3ping(dot)com>
Cc: PostgreSQL General Mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Re: Database tuning
Date: 2001-12-21 20:17:47
Message-ID: 20011221221747.A43509@nevermind.kiev.ua
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello, Antonio Fiol Bonnin!

On Fri, Dec 21, 2001 at 09:11:41PM +0100, you wrote:

> >Then chose random one outside SQL, and then:
> >
> >select * from table where table.id = '$random_id';
> >
> >This would be slower but will work for sure.
> >
> Probably even slower than original. Not sure, though.
No, it should be faster that 9 seconds even if count of rows is very big
:) Just verified on 100,000 records. It is about 1 second on my PIII-800/512Mb
using perl as frontend.

>
> >Another approach -- select random id outside SQL from 0 (or 1) to
> >maximum_id and then trying to select with 'where table.id =
> >'$random_id'' until you've got > 0 rows in result.
> >
> The only drawback that I see to this approach is that it may not find a
> result in a finite time.
If IDs in table are pretty "Compressed" (c) you, as it is in our case it
will work in VERY finite time :>
>
> Better: "Compress" your table so that it holds all continuous IDs. This
> may be painful and long, but it will pay off in the end, if your table
> is not updated often, so this operation only needs to be done once.
Yes, I agree it will be _very_ painful if you have a lot of crosslinks
in tables.
>
> I guess The Bible is not updated very often. ;-)
We never should assume this. We don't know if God is preparing new
release or just abandoned this book, maybe he has CVS somewhere...

--
NEVE-RIPE

In response to

Browse pgsql-general by date

  From Date Subject
Next Message SHELTON,MICHAEL (Non-HP-Boise,ex1) 2001-12-21 20:27:30 Stored procedures vs Functions
Previous Message Antonio Fiol Bonnín 2001-12-21 20:11:41 Re: Database tuning