Skip site navigation (1) Skip section navigation (2)

Re: Database tuning

From: Antonio Fiol Bonnín <fiol(at)w3ping(dot)com>
To: Nevermind <never(at)nevermind(dot)kiev(dot)ua>, PostgreSQL General Mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Re: Database tuning
Date: 2001-12-21 20:11:41
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
>>XXX is a random value ranking from 0 (or 1) to the maximum id value. You 
>>generate it outside the database.
>Maximum id is not good solution, beacuse some of ids between 0 (or 1)
>could be missing for some reasons. You should:
>select id from table;
SEQ SCAN. Avoid for big tables.

>Then chose random one outside SQL, and then:
>select * from table where = '$random_id';
>This would be slower but will work for sure.
Probably even slower than original. Not sure, though.

>Another approach -- select random id outside SQL from 0 (or 1) to
>maximum_id and then trying to select with 'where =
>'$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.

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.

I guess The Bible is not updated very often. ;-)


In response to


pgsql-general by date

Next:From: NevermindDate: 2001-12-21 20:17:47
Subject: Re: Database tuning
Previous:From: Helge BahmannDate: 2001-12-21 20:09:24
Subject: udp port

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group